diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index a68c8260..9b89b024 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -136,21 +136,6 @@ void account_statistics_object::pay_fee( share_type core_fee, share_type cashbac pending_vested_fees += core_fee; } -void account_object::options_type::validate() const -{ - auto needed_witnesses = num_witness; - auto needed_committee = num_committee; - - for( vote_id_type id : votes ) - if( id.type() == vote_id_type::witness && needed_witnesses ) - --needed_witnesses; - else if ( id.type() == vote_id_type::committee && needed_committee ) - --needed_committee; - - FC_ASSERT( needed_witnesses == 0 && needed_committee == 0, - "May not specify fewer witnesses or committee members than the number voted for."); -} - set account_member_index::get_account_members(const account_object& a)const { set result; diff --git a/libraries/chain/protocol/account.cpp b/libraries/chain/protocol/account.cpp index 019a6851..902c5d58 100644 --- a/libraries/chain/protocol/account.cpp +++ b/libraries/chain/protocol/account.cpp @@ -158,6 +158,21 @@ bool is_cheap_name( const string& n ) return false; } +void account_options::validate() const +{ + auto needed_witnesses = num_witness; + auto needed_committee = num_committee; + + for( vote_id_type id : votes ) + if( id.type() == vote_id_type::witness && needed_witnesses ) + --needed_witnesses; + else if ( id.type() == vote_id_type::committee && needed_committee ) + --needed_committee; + + FC_ASSERT( needed_witnesses == 0 && needed_committee == 0, + "May not specify fewer witnesses or committee members than the number voted for."); +} + share_type account_create_operation::calculate_fee( const fee_parameters_type& k )const { auto core_fee_required = k.basic_fee; diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 8766b525..61ff835d 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -447,9 +447,21 @@ class wallet_api /** * @ingroup Transaction Builder API */ - signed_transaction propose_builder_transaction(transaction_handle_type handle, - time_point_sec expiration = time_point::now() + fc::minutes(1), - uint32_t review_period_seconds = 0, bool broadcast = true); + signed_transaction propose_builder_transaction( + transaction_handle_type handle, + time_point_sec expiration = time_point::now() + fc::minutes(1), + uint32_t review_period_seconds = 0, + bool broadcast = true + ); + + signed_transaction propose_builder_transaction2( + transaction_handle_type handle, + string account_name_or_id, + time_point_sec expiration = time_point::now() + fc::minutes(1), + uint32_t review_period_seconds = 0, + bool broadcast = true + ); + /** * @ingroup Transaction Builder API */ @@ -1483,6 +1495,7 @@ FC_API( graphene::wallet::wallet_api, (preview_builder_transaction) (sign_builder_transaction) (propose_builder_transaction) + (propose_builder_transaction2) (remove_builder_transaction) (is_new) (is_locked) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 7e5aa121..994f254e 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -862,9 +862,10 @@ public: return _builder_transactions[transaction_handle] = sign_transaction(_builder_transactions[transaction_handle], broadcast); } - signed_transaction propose_builder_transaction(transaction_handle_type handle, - time_point_sec expiration = time_point::now() + fc::minutes(1), - uint32_t review_period_seconds = 0, bool broadcast = true) + signed_transaction propose_builder_transaction( + transaction_handle_type handle, + time_point_sec expiration = time_point::now() + fc::minutes(1), + uint32_t review_period_seconds = 0, bool broadcast = true) { FC_ASSERT(_builder_transactions.count(handle)); proposal_create_operation op; @@ -879,6 +880,28 @@ public: return trx = sign_transaction(trx, broadcast); } + + signed_transaction propose_builder_transaction2( + transaction_handle_type handle, + string account_name_or_id, + time_point_sec expiration = time_point::now() + fc::minutes(1), + uint32_t review_period_seconds = 0, bool broadcast = true) + { + FC_ASSERT(_builder_transactions.count(handle)); + proposal_create_operation op; + op.fee_paying_account = get_account(account_name_or_id).get_id(); + op.expiration_time = expiration; + signed_transaction& trx = _builder_transactions[handle]; + std::transform(trx.operations.begin(), trx.operations.end(), std::back_inserter(op.proposed_ops), + [](const operation& op) -> op_wrapper { return op; }); + if( review_period_seconds ) + op.review_period_seconds = review_period_seconds; + trx.operations = {op}; + _remote_db->get_global_properties().parameters.current_fees->set_fee( trx.operations.front() ); + + return trx = sign_transaction(trx, broadcast); + } + void remove_builder_transaction(transaction_handle_type handle) { _builder_transactions.erase(handle); @@ -2726,11 +2749,25 @@ signed_transaction wallet_api::sign_builder_transaction(transaction_handle_type return my->sign_builder_transaction(transaction_handle, broadcast); } -signed_transaction wallet_api::propose_builder_transaction(transaction_handle_type handle, time_point_sec expiration, uint32_t review_period_seconds, bool broadcast) +signed_transaction wallet_api::propose_builder_transaction( + transaction_handle_type handle, + time_point_sec expiration, + uint32_t review_period_seconds, + bool broadcast) { return my->propose_builder_transaction(handle, expiration, review_period_seconds, broadcast); } +signed_transaction wallet_api::propose_builder_transaction2( + transaction_handle_type handle, + string account_name_or_id, + time_point_sec expiration, + uint32_t review_period_seconds, + bool broadcast) +{ + return my->propose_builder_transaction2(handle, account_name_or_id, expiration, review_period_seconds, broadcast); +} + void wallet_api::remove_builder_transaction(transaction_handle_type handle) { return my->remove_builder_transaction(handle);