From 06193c3db07f275e9b916713d9ee68836075f31a Mon Sep 17 00:00:00 2001 From: abitmore Date: Sat, 10 Sep 2016 21:59:22 +0000 Subject: [PATCH] Add agent to escrow dispute and release operation #143 --- libraries/app/impacted.cpp | 2 ++ .../include/steemit/chain/protocol/steem_operations.hpp | 6 ++++-- libraries/chain/steem_evaluator.cpp | 2 ++ libraries/wallet/include/steemit/wallet/wallet.hpp | 4 ++++ libraries/wallet/wallet.cpp | 4 ++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libraries/app/impacted.cpp b/libraries/app/impacted.cpp index f08ef5ee90..9b968c396e 100644 --- a/libraries/app/impacted.cpp +++ b/libraries/app/impacted.cpp @@ -214,12 +214,14 @@ struct get_impacted_account_visitor { _impacted.insert( op.from ); _impacted.insert( op.to ); + _impacted.insert( op.agent ); } void operator()( const escrow_release_operation& op ) { _impacted.insert( op.from ); _impacted.insert( op.to ); + _impacted.insert( op.agent ); } //void operator()( const operation& op ){} diff --git a/libraries/chain/include/steemit/chain/protocol/steem_operations.hpp b/libraries/chain/include/steemit/chain/protocol/steem_operations.hpp index 8fd213d057..766943035d 100644 --- a/libraries/chain/include/steemit/chain/protocol/steem_operations.hpp +++ b/libraries/chain/include/steemit/chain/protocol/steem_operations.hpp @@ -291,6 +291,7 @@ namespace steemit { namespace chain { { string from; string to; + string agent; string who; uint32_t escrow_id = 0; @@ -312,6 +313,7 @@ namespace steemit { namespace chain { { string from; string to; ///< the account that should receive funds (might be from, might be to + string agent; string who; ///< the account that is attempting to release the funds, determines valid 'to' uint32_t escrow_id = 0; asset sbd_amount = asset( 0, SBD_SYMBOL ); ///< the amount of sbd to release @@ -973,8 +975,8 @@ FC_REFLECT( steemit::chain::comment_options_operation, (author)(permlink)(max_ac FC_REFLECT( steemit::chain::escrow_transfer_operation, (from)(to)(sbd_amount)(steem_amount)(escrow_id)(agent)(fee)(json_meta)(ratification_deadline)(escrow_expiration) ); FC_REFLECT( steemit::chain::escrow_approve_operation, (from)(to)(agent)(who)(escrow_id)(approve) ); -FC_REFLECT( steemit::chain::escrow_dispute_operation, (from)(to)(who)(escrow_id) ); -FC_REFLECT( steemit::chain::escrow_release_operation, (from)(to)(who)(escrow_id)(sbd_amount)(steem_amount) ); +FC_REFLECT( steemit::chain::escrow_dispute_operation, (from)(to)(agent)(who)(escrow_id) ); +FC_REFLECT( steemit::chain::escrow_release_operation, (from)(to)(agent)(who)(escrow_id)(sbd_amount)(steem_amount) ); FC_REFLECT( steemit::chain::challenge_authority_operation, (challenger)(challenged)(require_owner) ); FC_REFLECT( steemit::chain::prove_authority_operation, (challenged)(require_owner) ); FC_REFLECT( steemit::chain::request_account_recovery_operation, (recovery_account)(account_to_recover)(new_owner_authority)(extensions) ); diff --git a/libraries/chain/steem_evaluator.cpp b/libraries/chain/steem_evaluator.cpp index c86349d2d7..d51f9d40e8 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -581,6 +581,7 @@ void escrow_dispute_evaluator::do_apply( const escrow_dispute_operation& o ) FC_ASSERT( e.to_approved && e.agent_approved, "escrow must be approved by all parties before a dispute can be raised" ); FC_ASSERT( !e.disputed, "escrow is already under dispute" ); FC_ASSERT( e.to == o.to, "op 'to' does not match escrow 'to'"); + FC_ASSERT( e.agent == o.agent, "op 'agent' does not match escrow 'agent'" ); db().modify( e, [&]( escrow_object& esc ) { @@ -604,6 +605,7 @@ void escrow_release_evaluator::do_apply( const escrow_release_operation& o ) FC_ASSERT( e.steem_balance >= o.steem_amount, "Release amount exceeds escrow balance" ); FC_ASSERT( e.sbd_balance >= o.sbd_amount, "Release amount exceeds escrow balance" ); FC_ASSERT( o.to == e.from || o.to == e.to, "Funds must be released to 'from' or 'to'" ); + FC_ASSERT( e.agent == o.agent, "op 'agent' does not match escrow 'agent'" ); FC_ASSERT( e.to_approved && e.agent_approved, "Funds cannot be released prior to escrow approval" ); // If there is a dispute regardless of expiration, the agent can release funds to either party diff --git a/libraries/wallet/include/steemit/wallet/wallet.hpp b/libraries/wallet/include/steemit/wallet/wallet.hpp index 425043a248..98b1bd1d52 100644 --- a/libraries/wallet/include/steemit/wallet/wallet.hpp +++ b/libraries/wallet/include/steemit/wallet/wallet.hpp @@ -624,6 +624,7 @@ class wallet_api * * @param from The account that funded the escrow * @param to The destination of the escrow + * @param agent The account acting as the agent in case of dispute * @param who The account raising the dispute (either 'from' or 'to') * @param escrow_id A unique id for the escrow transfer * @param broadcast true if you wish to broadcast the transaction @@ -631,6 +632,7 @@ class wallet_api annotated_signed_transaction escrow_dispute( string from, string to, + string agent, string who, uint32_t escrow_id, bool broadcast = false @@ -641,6 +643,7 @@ class wallet_api * * @param from The account that funded the escrow * @param to The account that will receive funds being released + * @param agent The account acting as the agent in case of dispute * @param who The account authorizing the release * @param escrow_id A unique id for the escrow transfer * @param sbd_amount The amount of SBD that will be released @@ -650,6 +653,7 @@ class wallet_api annotated_signed_transaction escrow_release( string from, string to, + string agent, string who, uint32_t escrow_id, asset sbd_amount, diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 4d887e35c4..7c3eacba78 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1764,6 +1764,7 @@ annotated_signed_transaction wallet_api::escrow_approve( annotated_signed_transaction wallet_api::escrow_dispute( string from, string to, + string agent, string who, uint32_t escrow_id, bool broadcast @@ -1772,6 +1773,7 @@ annotated_signed_transaction wallet_api::escrow_dispute( escrow_dispute_operation op; op.from = from; op.to = to; + op.agent = agent; op.who = who; op.escrow_id = escrow_id; @@ -1839,6 +1841,7 @@ annotated_signed_transaction wallet_api::cancel_transfer_from_savings( string fr annotated_signed_transaction wallet_api::escrow_release( string from, string to, + string agent, string who, uint32_t escrow_id, asset sbd_amount, @@ -1849,6 +1852,7 @@ annotated_signed_transaction wallet_api::escrow_release( escrow_release_operation op; op.from = from; op.to = to; + op.agent = agent; op.who = who; op.escrow_id = escrow_id; op.sbd_amount = sbd_amount;