Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CLI register_account and create_account_with_private_key commands, remove duplicate code #1811

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 2 additions & 47 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,35 +1159,11 @@ class wallet_api_impl
account_create_op.options.memo_key = active;

signed_transaction tx;

tx.operations.push_back( account_create_op );

set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() );

vector<public_key_type> paying_keys = registrar_account_object.active.get_keys();

auto dyn_props = get_dynamic_global_properties();
tx.set_reference_block( dyn_props.head_block_id );
tx.set_expiration( dyn_props.time + fc::seconds(30) );
tx.validate();

for( public_key_type& key : paying_keys )
{
auto it = _keys.find(key);
if( it != _keys.end() )
{
fc::optional< fc::ecc::private_key > privkey = wif_to_key( it->second );
if( !privkey.valid() )
{
FC_ASSERT( false, "Malformed private key in _keys" );
}
tx.sign( *privkey, _chain_id );
}
}

if( broadcast )
_remote_net_broadcast->broadcast_transaction( tx );
return tx;
return sign_transaction(tx, broadcast);
} FC_CAPTURE_AND_RETHROW( (name)(owner)(active)(registrar_account)
(referrer_account)(referrer_percent)(broadcast) ) }

Expand Down Expand Up @@ -1284,38 +1260,17 @@ class wallet_api_impl
// account_create_op.fee = account_create_op.calculate_fee(db.current_fee_schedule());

signed_transaction tx;

tx.operations.push_back( account_create_op );

set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees());

vector<public_key_type> paying_keys = registrar_account_object.active.get_keys();

auto dyn_props = get_dynamic_global_properties();
tx.set_reference_block( dyn_props.head_block_id );
tx.set_expiration( dyn_props.time + fc::seconds(30) );
tx.validate();

for( public_key_type& key : paying_keys )
{
auto it = _keys.find(key);
if( it != _keys.end() )
{
fc::optional< fc::ecc::private_key > privkey = wif_to_key( it->second );
FC_ASSERT( privkey.valid(), "Malformed private key in _keys" );
tx.sign( *privkey, _chain_id );
}
}

// we do not insert owner_privkey here because
// it is intended to only be used for key recovery
_wallet.pending_account_registrations[account_name].push_back(key_to_wif( active_privkey ));
_wallet.pending_account_registrations[account_name].push_back(key_to_wif( memo_privkey ));
if( save_wallet )
save_wallet_file();
if( broadcast )
_remote_net_broadcast->broadcast_transaction( tx );
return tx;
return sign_transaction(tx, broadcast);
} FC_CAPTURE_AND_RETHROW( (account_name)(registrar_account)(referrer_account)(broadcast) ) }

signed_transaction create_account_with_brain_key(string brain_key,
Expand Down