Prevent the wallet from complaining when creating a new account, it
was falsely reporting that someone else had registered your account first. I still don't think it's working correctly, but it's better than it was.
This commit is contained in:
parent
9cb9d2e07f
commit
cc1348bf91
2 changed files with 31 additions and 11 deletions
|
|
@ -325,7 +325,7 @@ class wallet_api
|
||||||
*
|
*
|
||||||
* The keys are printed in WIF format. You can import these keys into another wallet
|
* The keys are printed in WIF format. You can import these keys into another wallet
|
||||||
* using \c import_key()
|
* using \c import_key()
|
||||||
* @returns a map containing the private keys, indexed by their key_id
|
* @returns a map containing the private keys, indexed by their public key
|
||||||
*/
|
*/
|
||||||
map<public_key_type, string> dump_private_keys();
|
map<public_key_type, string> dump_private_keys();
|
||||||
|
|
||||||
|
|
@ -1017,7 +1017,9 @@ FC_API( graphene::wallet::wallet_api,
|
||||||
(whitelist_account)
|
(whitelist_account)
|
||||||
(create_delegate)
|
(create_delegate)
|
||||||
(get_witness)
|
(get_witness)
|
||||||
|
(get_delegate)
|
||||||
(list_witnesses)
|
(list_witnesses)
|
||||||
|
(list_delegates)
|
||||||
(create_witness)
|
(create_witness)
|
||||||
(vote_for_delegate)
|
(vote_for_delegate)
|
||||||
(vote_for_witness)
|
(vote_for_witness)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include <boost/range/adaptor/map.hpp>
|
#include <boost/range/adaptor/map.hpp>
|
||||||
|
#include <boost/range/algorithm_ext/insert.hpp>
|
||||||
|
|
||||||
#include <fc/io/fstream.hpp>
|
#include <fc/io/fstream.hpp>
|
||||||
#include <fc/io/json.hpp>
|
#include <fc/io/json.hpp>
|
||||||
|
|
@ -504,25 +505,37 @@ public:
|
||||||
return get_private_key(active_keys.front());
|
return get_private_key(active_keys.front());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// imports the private key into the wallet, and associate it in some way (?) with the
|
||||||
|
// given account name.
|
||||||
|
// @returns true if the key matches a current active/owner/memo key for the named
|
||||||
|
// account, false otherwise (but it is stored either way)
|
||||||
bool import_key(string account_name_or_id, string wif_key)
|
bool import_key(string account_name_or_id, string wif_key)
|
||||||
{
|
{
|
||||||
auto opt_priv_key = wif_to_key(wif_key);
|
fc::optional<fc::ecc::private_key> optional_private_key = wif_to_key(wif_key);
|
||||||
FC_ASSERT( opt_priv_key.valid() );
|
if (!optional_private_key)
|
||||||
graphene::chain::public_key_type wif_pub_key = opt_priv_key->get_public_key();
|
FC_THROW("Invalid private key ${key}", ("key", wif_key));
|
||||||
|
graphene::chain::public_key_type wif_pub_key = optional_private_key->get_public_key();
|
||||||
|
|
||||||
|
account_object account = get_account( account_name_or_id );
|
||||||
|
|
||||||
|
// make a list of all current public keys for the named account
|
||||||
|
flat_set<public_key_type> all_keys_for_account;
|
||||||
|
boost::insert(all_keys_for_account, account.active.get_keys());
|
||||||
|
boost::insert(all_keys_for_account, account.owner.get_keys());
|
||||||
|
all_keys_for_account.insert(account.options.memo_key);
|
||||||
|
|
||||||
_keys[wif_pub_key] = wif_key;
|
_keys[wif_pub_key] = wif_key;
|
||||||
|
|
||||||
auto acnt = get_account( account_name_or_id );
|
if( _wallet.update_account(account) )
|
||||||
|
|
||||||
if( _wallet.update_account(acnt) )
|
|
||||||
_remote_db->subscribe_to_objects([this](const fc::variant& v) {
|
_remote_db->subscribe_to_objects([this](const fc::variant& v) {
|
||||||
_wallet.update_account(v.as<account_object>());
|
_wallet.update_account(v.as<account_object>());
|
||||||
}, {acnt.id});
|
}, {account.id});
|
||||||
|
|
||||||
_wallet.extra_keys[acnt.id].insert(wif_pub_key);
|
_wallet.extra_keys[account.id].insert(wif_pub_key);
|
||||||
|
|
||||||
return false;
|
return all_keys_for_account.find(wif_pub_key) != all_keys_for_account.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool load_wallet_file(string wallet_filename = "")
|
bool load_wallet_file(string wallet_filename = "")
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
@ -2023,6 +2036,11 @@ witness_object wallet_api::get_witness(string owner_account)
|
||||||
return my->get_witness(owner_account);
|
return my->get_witness(owner_account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delegate_object wallet_api::get_delegate(string owner_account)
|
||||||
|
{
|
||||||
|
return my->get_delegate(owner_account);
|
||||||
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::create_witness(string owner_account,
|
signed_transaction wallet_api::create_witness(string owner_account,
|
||||||
string url,
|
string url,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue