From 649709f5db0bbeab2da6f14033b489625e29372b Mon Sep 17 00:00:00 2001 From: crypto-ape <43807588+crypto-ape@users.noreply.github.com> Date: Wed, 26 Jun 2019 12:21:03 +0200 Subject: [PATCH] small refactor of cli_wallet to get rid of transaction expiration constant duplicities --- libraries/wallet/wallet.cpp | 49 ++----------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index a2783a8584..2f964bb811 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -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 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) ) } @@ -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 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,