From 3f62223b18b569c3ca0c27698c02e9f36fa70972 Mon Sep 17 00:00:00 2001 From: Roman Olearski Date: Sat, 20 May 2017 11:36:00 +0200 Subject: [PATCH] added betting methods to the cli_wallet 2 --- .../wallet/include/graphene/wallet/wallet.hpp | 18 ++++++ libraries/wallet/wallet.cpp | 56 +++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 47b0e5c4..db6dfd1e 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1453,6 +1453,22 @@ class wallet_api asset_id_type asset_id, bool broadcast = false); + signed_transaction place_bet( + const string& betting_account, + betting_market_id_type betting_market_id, + bet_type back_or_lay, + asset amount_to_bet, + bet_multiplier_type backer_multiplier, + share_type amount_reserved_for_fees, + bool broadcast = false); + + signed_transaction propose_resolve_betting_market( + const string& proposing_account, + fc::time_point_sec expiration_time, + betting_market_id_type betting_market_id, + betting_market_resolution_type resolution, + bool broadcast = false); + void dbg_make_uia(string creator, string symbol); void dbg_make_mia(string creator, string symbol); void flood_network(string prefix, uint32_t number_of_transactions); @@ -1651,4 +1667,6 @@ FC_API( graphene::wallet::wallet_api, (propose_create_event) (propose_create_betting_market_group) (propose_create_betting_market) + (place_bet) + (propose_resolve_betting_market) ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 6b272286..359bfa01 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -4298,6 +4298,62 @@ signed_transaction wallet_api::propose_create_betting_market( return my->sign_transaction(tx, broadcast); } +signed_transaction wallet_api::place_bet( + const string& betting_account, + betting_market_id_type betting_market_id, + bet_type back_or_lay, + asset amount_to_bet, + bet_multiplier_type backer_multiplier, + share_type amount_reserved_for_fees, + bool broadcast /*= false*/) +{ + FC_ASSERT( !is_locked() ); + const chain_parameters& current_params = get_global_properties().parameters; + + bet_place_operation bet_place_op; + bet_place_op.bettor_id = get_account(betting_account).id; + bet_place_op.betting_market_id = betting_market_id; + bet_place_op.amount_to_bet = amount_to_bet; + bet_place_op.backer_multiplier = backer_multiplier; + bet_place_op.amount_reserved_for_fees = amount_reserved_for_fees; + bet_place_op.back_or_lay = back_or_lay; + + signed_transaction tx; + tx.operations.push_back(bet_place_op); + my->set_operation_fees(tx, current_params.current_fees); + tx.validate(); + + return my->sign_transaction(tx, broadcast); +} + +signed_transaction wallet_api::propose_resolve_betting_market( + const string& proposing_account, + fc::time_point_sec expiration_time, + betting_market_id_type betting_market_id, + betting_market_resolution_type resolution, + bool broadcast /*= false*/) +{ + FC_ASSERT( !is_locked() ); + const chain_parameters& current_params = get_global_properties().parameters; + + betting_market_resolve_operation betting_market_resolve_op; + betting_market_resolve_op.betting_market_id = betting_market_id; + betting_market_resolve_op.resolution = resolution; + + proposal_create_operation prop_op; + prop_op.expiration_time = expiration_time; + prop_op.review_period_seconds = current_params.committee_proposal_review_period; + prop_op.fee_paying_account = get_account(proposing_account).id; + prop_op.proposed_ops.emplace_back( betting_market_resolve_op ); + current_params.current_fees->set_fee( prop_op.proposed_ops.back().op ); + + signed_transaction tx; + tx.operations.push_back(prop_op); + my->set_operation_fees(tx, current_params.current_fees); + tx.validate(); + + return my->sign_transaction(tx, broadcast); +} // default ctor necessary for FC_REFLECT signed_block_with_info::signed_block_with_info()