fc::ecc::private_key wallet_db::new_private_key( const fc::sha512& password, const address& parent_account_address, bool store_key ) { FC_ASSERT( wallet_master_key.valid() ); const auto master_ext_priv_key = wallet_master_key->decrypt_key( password ); const auto key_index = new_key_child_index(parent_account_address); auto new_priv_key = master_ext_priv_key.child( key_index ); if( key_index >= 10000 ) { fc::sha256::encoder enc; fc::raw::pack( enc, parent_account_address ); fc::raw::pack( enc, key_index ); new_priv_key = master_ext_priv_key.child( enc.result() ); } if( !store_key ) return new_priv_key; key_data new_key; new_key.account_address = parent_account_address; new_key.encrypt_private_key( password, new_priv_key ); new_key.gen_seq_number = key_index; // if there is no parent account address, then the account_address of this key is itself if( parent_account_address == address() ) { new_key.account_address = address( new_key.public_key ); } this->store_key( new_key ); return new_priv_key; }
fc::ecc::private_key wallet_db::new_private_key( const fc::sha512& password, const address& parent_account_address ) { FC_ASSERT( wallet_master_key.valid() ); auto master_ext_priv_key = wallet_master_key->decrypt_key( password ); auto new_priv_key = master_ext_priv_key.child( new_key_child_index() ); key_data new_key; new_key.account_address = parent_account_address; new_key.encrypt_private_key( password, new_priv_key ); // if there is no parent account address, then the account_address of this key is itself if (parent_account_address == address()) { new_key.account_address = address(new_key.public_key); } store_key( new_key ); return new_priv_key; }