Skip to content

Commit

Permalink
Add agent to escrow dispute and release operation steemit#143
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Sep 10, 2016
1 parent fe1b0c1 commit 06193c3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions libraries/app/impacted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ){}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ namespace steemit { namespace chain {
{
string from;
string to;
string agent;
string who;
uint32_t escrow_id = 0;

Expand All @@ -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
Expand Down Expand Up @@ -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) );
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions libraries/wallet/include/steemit/wallet/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,13 +624,15 @@ 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
*/
annotated_signed_transaction escrow_dispute(
string from,
string to,
string agent,
string who,
uint32_t escrow_id,
bool broadcast = false
Expand All @@ -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
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 06193c3

Please sign in to comment.