From 610266481b29e01ff5ca8cf7c2286af3bfb9262d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Tue, 22 Jan 2019 16:19:13 -0300 Subject: [PATCH] add create_vesting_balance command to cli wallet --- .../wallet/include/graphene/wallet/wallet.hpp | 15 +++++++++ libraries/wallet/wallet.cpp | 31 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 0ba0782b..a7189138 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1795,6 +1795,20 @@ class wallet_api rock_paper_scissors_gesture gesture, bool broadcast); + /** Create a vesting balance including gpos vesting balance after HARDFORK_GPOS_TIME + * @param owner vesting balance owner and creator + * @param amount amount to vest + * @param asset_symbol the symbol of the asset to vest + * @param is_gpos True if the balance is of gpos type + * @param broadcast true if you wish to broadcast the transaction + * @return the signed version of the transaction + */ + signed_transaction create_vesting_balance(string owner, + string amount, + string asset_symbol, + bool is_gpos, + bool broadcast); + void dbg_make_uia(string creator, string symbol); void dbg_make_mia(string creator, string symbol); void dbg_push_blocks( std::string src_filename, uint32_t count ); @@ -2031,6 +2045,7 @@ FC_API( graphene::wallet::wallet_api, (tournament_join) (tournament_leave) (rps_throw) + (create_vesting_balance) (get_upcoming_tournaments) (get_tournaments) (get_tournaments_by_state) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 74c285bf..812740e6 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -5756,6 +5756,37 @@ signed_transaction wallet_api::rps_throw(game_id_type game_id, return my->sign_transaction( tx, broadcast ); } +signed_transaction wallet_api::create_vesting_balance(string owner, + string amount, + string asset_symbol, + bool is_gpos, + bool broadcast) +{ + FC_ASSERT( !is_locked() ); + + account_object owner_account = get_account(owner); + account_id_type owner_id = owner_account.id; + + fc::optional asset_obj = get_asset(asset_symbol); + + auto type = vesting_balance_type::unspecified; + if(is_gpos) + type = vesting_balance_type::gpos; + + vesting_balance_create_operation op; + op.creator = owner_id; + op.owner = owner_id; + op.amount = asset_obj->amount_from_string(amount); + op.balance_type = type; + + signed_transaction trx; + trx.operations.push_back(op); + my->set_operation_fees( trx, my->_remote_db->get_global_properties().parameters.current_fees ); + trx.validate(); + + return my->sign_transaction( trx, broadcast ); +} + // default ctor necessary for FC_REFLECT signed_block_with_info::signed_block_with_info() {