diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 993c043e..9baaebc3 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -273,9 +273,10 @@ public: private: void claim_registered_account(const account_object& account) { + std::vector 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 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