Private keys management fixed (cli_wallet)
This commit is contained in:
parent
329c75668f
commit
d07d3bb9fc
1 changed files with 17 additions and 1 deletions
|
|
@ -273,9 +273,10 @@ public:
|
|||
private:
|
||||
void claim_registered_account(const account_object& account)
|
||||
{
|
||||
std::vector<std::string> import_keys;
|
||||
auto it = _wallet.pending_account_registrations.find( account.name );
|
||||
FC_ASSERT( it != _wallet.pending_account_registrations.end() );
|
||||
for (const std::string& wif_key : it->second)
|
||||
for (const std::string& wif_key : it->second) {
|
||||
if( !import_key( account.name, wif_key ) )
|
||||
{
|
||||
// somebody else beat our pending registration, there is
|
||||
|
|
@ -288,8 +289,23 @@ private:
|
|||
// possibility of migrating to a fork where the
|
||||
// name is available, the user can always
|
||||
// manually re-register)
|
||||
} else {
|
||||
import_keys.push_back( wif_key );
|
||||
}
|
||||
}
|
||||
_wallet.pending_account_registrations.erase( it );
|
||||
|
||||
for( const auto& k : import_keys ) {
|
||||
fc::optional<fc::ecc::private_key> optional_private_key = wif_to_key( k );
|
||||
if (!optional_private_key)
|
||||
FC_THROW("Invalid private key");
|
||||
string shorthash = detail::address_to_shorthash(optional_private_key->get_public_key());
|
||||
copy_wallet_file( "before-import-key-" + shorthash );
|
||||
|
||||
save_wallet_file();
|
||||
copy_wallet_file( "after-import-key-" + shorthash );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// after a witness registration succeeds, this saves the private key in the wallet permanently
|
||||
|
|
|
|||
Loading…
Reference in a new issue