From 5bf245ee6c897a48f58884f99bb356b7c9073387 Mon Sep 17 00:00:00 2001 From: sierra19XX <15652887+sierra19XX@users.noreply.github.com> Date: Thu, 2 Apr 2020 21:22:05 +1100 Subject: [PATCH] SON-297_SON-336 - SON vesting functionality broken after graphene merge (#331) Co-authored-by: satyakoneru <15652887+satyakoneru@users.noreply.github.com> --- libraries/chain/vesting_balance_evaluator.cpp | 4 ++-- libraries/wallet/wallet.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/chain/vesting_balance_evaluator.cpp b/libraries/chain/vesting_balance_evaluator.cpp index dc91a449..56eef193 100644 --- a/libraries/chain/vesting_balance_evaluator.cpp +++ b/libraries/chain/vesting_balance_evaluator.cpp @@ -139,7 +139,7 @@ void_result vesting_balance_withdraw_evaluator::do_evaluate( const vesting_balan const time_point_sec now = d.head_block_time(); const vesting_balance_object& vbo = op.vesting_balance( d ); - if(vbo.balance_type == vesting_balance_type::normal) + if(vbo.balance_type == vesting_balance_type::normal || vbo.balance_type == vesting_balance_type::son) { FC_ASSERT( op.owner == vbo.owner, "", ("op.owner", op.owner)("vbo.owner", vbo.owner) ); FC_ASSERT( vbo.is_withdraw_allowed( now, op.amount ), "Account has insufficient ${balance_type} Vested Balance to withdraw", @@ -179,7 +179,7 @@ void_result vesting_balance_withdraw_evaluator::do_apply( const vesting_balance_ //Handling all GPOS withdrawls separately from normal and SONs(future extension). // One request/transaction would be sufficient to withdraw from multiple vesting balance ids const vesting_balance_object& vbo = op.vesting_balance( d ); - if(vbo.balance_type == vesting_balance_type::normal) + if(vbo.balance_type == vesting_balance_type::normal || vbo.balance_type == vesting_balance_type::son) { // Allow zero balance objects to stick around, (1) to comply // with the chain's "objects live forever" design principle, (2) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index e6cd6291..a00636cc 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2414,8 +2414,8 @@ public: vesting_balance_object vbo = get_object< vesting_balance_object >( *vbid ); - if(vbo.balance_type != vesting_balance_type::normal) - FC_THROW("Allowed to withdraw only Normal type vest balances with this method"); + if(vbo.balance_type == vesting_balance_type::gpos) + FC_THROW("Allowed to withdraw only Normal and Son type vest balances with this method"); vesting_balance_withdraw_operation vesting_balance_withdraw_op; @@ -6729,7 +6729,8 @@ vesting_balance_object_with_info::vesting_balance_object_with_info( const vestin : vesting_balance_object( vbo ) { allowed_withdraw = get_allowed_withdraw( now ); - if(vbo.balance_type == vesting_balance_type::gpos) + if(vbo.balance_type == vesting_balance_type::gpos || + ((vbo.balance_type == vesting_balance_type::son) && (vbo.policy.which() == vesting_policy::tag::value))) allowed_withdraw_time = vbo.policy.get().begin_timestamp + vbo.policy.get().vesting_cliff_seconds; else allowed_withdraw_time = now;