From 8613bab257d392139febb022cba2f8c8e53562f4 Mon Sep 17 00:00:00 2001 From: pbattu123 Date: Thu, 29 Aug 2019 10:34:15 -0300 Subject: [PATCH] issue - 154: Don't allow to vote when vesting balance is 0 --- libraries/wallet/wallet.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 812740e6..46acf25e 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1995,6 +1995,13 @@ public: bool approve, bool broadcast /* = false */) { try { + std::vector vbo_info = get_vesting_balances(voting_account); + std::vector::iterator vbo_iter; + + vbo_iter = std::find_if(vbo_info.begin(), vbo_info.end(), [](vesting_balance_object_with_info const& obj){return obj.balance_type == vesting_balance_type::gpos;}); + if( vbo_info.size() == 0 || vbo_iter == vbo_info.end()) + FC_THROW("Account *** ${account} *** have insufficient or 0 vested balance(GPOS) to vote", ("account", voting_account)); + account_object voting_account_object = get_account(voting_account); account_id_type committee_member_owner_account_id = get_account_id(committee_member); fc::optional committee_member_obj = _remote_db->get_committee_member_by_account(committee_member_owner_account_id); @@ -2029,6 +2036,13 @@ public: bool approve, bool broadcast /* = false */) { try { + std::vector vbo_info = get_vesting_balances(voting_account); + std::vector::iterator vbo_iter; + + vbo_iter = std::find_if(vbo_info.begin(), vbo_info.end(), [](vesting_balance_object_with_info const& obj){return obj.balance_type == vesting_balance_type::gpos;}); + if( vbo_info.size() == 0 || vbo_iter == vbo_info.end()) + FC_THROW("Account *** ${account} *** have insufficient or 0 vested balance(GPOS) to vote", ("account", voting_account)); + account_object voting_account_object = get_account(voting_account); account_id_type witness_owner_account_id = get_account_id(witness); fc::optional witness_obj = _remote_db->get_witness_by_account(witness_owner_account_id);