[SON-312] Refactor create_son to assign owner account public key as a signing_key
remove key derivation from create son (#323) Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
This commit is contained in:
parent
0f97241f1b
commit
e170676ff9
2 changed files with 2 additions and 43 deletions
|
|
@ -188,7 +188,6 @@ struct wallet_data
|
|||
// incomplete account regs
|
||||
map<string, vector<string> > pending_account_registrations;
|
||||
map<string, string> pending_witness_registrations;
|
||||
map<string, string> pending_son_registrations;
|
||||
|
||||
key_label_index_type labeled_keys;
|
||||
blind_receipt_index_type blind_receipts;
|
||||
|
|
@ -2121,7 +2120,7 @@ FC_REFLECT( graphene::wallet::wallet_data,
|
|||
(my_accounts)
|
||||
(cipher_keys)
|
||||
(extra_keys)
|
||||
(pending_account_registrations)(pending_witness_registrations)(pending_son_registrations)
|
||||
(pending_account_registrations)(pending_witness_registrations)
|
||||
(labeled_keys)
|
||||
(blind_receipts)
|
||||
(committed_game_moves)
|
||||
|
|
|
|||
|
|
@ -294,23 +294,6 @@ private:
|
|||
_wallet.pending_account_registrations.erase( it );
|
||||
}
|
||||
|
||||
// after a son registration succeeds, this saves the private key in the wallet permanently
|
||||
//
|
||||
void claim_registered_son(const std::string& son_name)
|
||||
{
|
||||
auto iter = _wallet.pending_son_registrations.find(son_name);
|
||||
FC_ASSERT(iter != _wallet.pending_son_registrations.end());
|
||||
std::string wif_key = iter->second;
|
||||
|
||||
// get the list key id this key is registered with in the chain
|
||||
fc::optional<fc::ecc::private_key> son_private_key = wif_to_key(wif_key);
|
||||
FC_ASSERT(son_private_key);
|
||||
|
||||
auto pub_key = son_private_key->get_public_key();
|
||||
_keys[pub_key] = wif_key;
|
||||
_wallet.pending_son_registrations.erase(iter);
|
||||
}
|
||||
|
||||
// after a witness registration succeeds, this saves the private key in the wallet permanently
|
||||
//
|
||||
void claim_registered_witness(const std::string& witness_name)
|
||||
|
|
@ -372,24 +355,6 @@ private:
|
|||
claim_registered_witness(optional_account->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_wallet.pending_son_registrations.empty())
|
||||
{
|
||||
// make a vector of the owner accounts for sons pending registration
|
||||
std::vector<string> pending_son_names = boost::copy_range<std::vector<string> >(boost::adaptors::keys(_wallet.pending_son_registrations));
|
||||
|
||||
// look up the owners on the blockchain
|
||||
std::vector<fc::optional<graphene::chain::account_object>> owner_account_objects = _remote_db->lookup_account_names(pending_son_names);
|
||||
|
||||
// if any of them have registered sons, claim them
|
||||
for( const fc::optional<graphene::chain::account_object>& optional_account : owner_account_objects )
|
||||
if (optional_account)
|
||||
{
|
||||
fc::optional<son_object> son_obj = _remote_db->get_son_by_account(optional_account->id);
|
||||
if (son_obj)
|
||||
claim_registered_son(optional_account->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return true if any of my_accounts are players in this tournament
|
||||
|
|
@ -1870,10 +1835,7 @@ public:
|
|||
{ try {
|
||||
fc::scoped_lock<fc::mutex> lock(_resync_mutex);
|
||||
account_object son_account = get_account(owner_account);
|
||||
fc::ecc::private_key active_private_key = get_private_key_for_account(son_account);
|
||||
int son_key_index = find_first_unused_derived_key_index(active_private_key);
|
||||
fc::ecc::private_key son_private_key = derive_private_key(key_to_wif(active_private_key), son_key_index);
|
||||
graphene::chain::public_key_type son_public_key = son_private_key.get_public_key();
|
||||
auto son_public_key = son_account.active.get_keys()[0];
|
||||
|
||||
son_create_operation son_create_op;
|
||||
son_create_op.owner_account = son_account.id;
|
||||
|
|
@ -1891,8 +1853,6 @@ public:
|
|||
set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees);
|
||||
tx.validate();
|
||||
|
||||
_wallet.pending_son_registrations[owner_account] = key_to_wif(son_private_key);
|
||||
|
||||
return sign_transaction( tx, broadcast );
|
||||
} FC_CAPTURE_AND_RETHROW( (owner_account)(broadcast) ) }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue