forked from lthn/blockchain
implemented marketplace api, some fixes of contract api calls
This commit is contained in:
parent
95d007e3fa
commit
3679c7e638
16 changed files with 337 additions and 285 deletions
|
|
@ -21,7 +21,6 @@
|
|||
#include "crypto/crypto.h"
|
||||
#include "crypto/hash.h"
|
||||
#include "difficulty.h"
|
||||
//#include "offers_services_helpers.h"
|
||||
#include "rpc/core_rpc_server_commands_defs.h"
|
||||
#include "bc_payments_id_service.h"
|
||||
#include "bc_attachments_helpers_basic.h"
|
||||
|
|
@ -29,6 +28,7 @@
|
|||
#include "currency_format_utils_blocks.h"
|
||||
#include "currency_format_utils_transactions.h"
|
||||
|
||||
|
||||
// ------ get_tx_type_definition -------------
|
||||
#define GUI_TX_TYPE_NORMAL 0
|
||||
#define GUI_TX_TYPE_PUSH_OFFER 1
|
||||
|
|
|
|||
|
|
@ -125,4 +125,69 @@ namespace bc_services
|
|||
|
||||
|
||||
typedef boost::variant<offer_details, update_offer, cancel_offer> offers_attachment_t;
|
||||
|
||||
inline std::string transform_double_to_string(const double& a)
|
||||
{
|
||||
return std::to_string(a);
|
||||
}
|
||||
|
||||
inline double transform_string_to_double(const std::string& d)
|
||||
{
|
||||
double n = 0;
|
||||
epee::string_tools::get_xtype_from_string(n, d);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
struct core_offers_filter
|
||||
{
|
||||
uint64_t order_by;
|
||||
bool reverse;
|
||||
uint64_t offset;
|
||||
uint64_t limit;
|
||||
//filter entry
|
||||
uint64_t timestamp_start;
|
||||
uint64_t timestamp_stop;
|
||||
uint64_t offer_type_mask;
|
||||
uint64_t amount_low_limit;
|
||||
uint64_t amount_up_limit;
|
||||
double rate_low_limit;
|
||||
double rate_up_limit;
|
||||
std::list<std::string> payment_types;
|
||||
std::string location_country;
|
||||
std::string location_city;
|
||||
std::string target;
|
||||
std::string primary;
|
||||
bool bonus;
|
||||
std::string category;
|
||||
std::string keyword;
|
||||
bool fake;
|
||||
uint64_t current_time;
|
||||
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(order_by)
|
||||
KV_SERIALIZE(reverse)
|
||||
KV_SERIALIZE(offset)
|
||||
KV_SERIALIZE(limit)
|
||||
KV_SERIALIZE(timestamp_start)
|
||||
KV_SERIALIZE(timestamp_stop)
|
||||
KV_SERIALIZE(offer_type_mask)
|
||||
KV_SERIALIZE(amount_low_limit)
|
||||
KV_SERIALIZE(amount_up_limit)
|
||||
KV_SERIALIZE_CUSTOM(rate_low_limit, std::string, bc_services::transform_double_to_string, bc_services::transform_string_to_double)
|
||||
KV_SERIALIZE_CUSTOM(rate_up_limit, std::string, bc_services::transform_double_to_string, bc_services::transform_string_to_double)
|
||||
KV_SERIALIZE(payment_types)
|
||||
KV_SERIALIZE(location_country)
|
||||
KV_SERIALIZE(location_city)
|
||||
KV_SERIALIZE(target)
|
||||
KV_SERIALIZE(primary)
|
||||
KV_SERIALIZE(bonus)
|
||||
KV_SERIALIZE(category)
|
||||
KV_SERIALIZE(keyword)
|
||||
KV_SERIALIZE(fake)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -17,17 +17,7 @@
|
|||
|
||||
namespace bc_services
|
||||
{
|
||||
std::string transform_double_to_string(const double& a)
|
||||
{
|
||||
return std::to_string(a);
|
||||
}
|
||||
|
||||
double transform_string_to_double(const std::string& d)
|
||||
{
|
||||
double n = 0;
|
||||
epee::string_tools::get_xtype_from_string(n, d);
|
||||
return n;
|
||||
}
|
||||
|
||||
bool order_offers_by_timestamp(const offer_details_ex* a, const offer_details_ex* b)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,60 +18,6 @@
|
|||
namespace bc_services
|
||||
{
|
||||
|
||||
std::string transform_double_to_string(const double& a);
|
||||
double transform_string_to_double(const std::string& d);
|
||||
|
||||
|
||||
struct core_offers_filter
|
||||
{
|
||||
uint64_t order_by;
|
||||
bool reverse;
|
||||
uint64_t offset;
|
||||
uint64_t limit;
|
||||
//filter entry
|
||||
uint64_t timestamp_start;
|
||||
uint64_t timestamp_stop;
|
||||
uint64_t offer_type_mask;
|
||||
uint64_t amount_low_limit;
|
||||
uint64_t amount_up_limit;
|
||||
double rate_low_limit;
|
||||
double rate_up_limit;
|
||||
std::list<std::string> payment_types;
|
||||
std::string location_country;
|
||||
std::string location_city;
|
||||
std::string target;
|
||||
std::string primary;
|
||||
bool bonus;
|
||||
std::string category;
|
||||
std::string keyword;
|
||||
bool fake;
|
||||
uint64_t current_time;
|
||||
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(order_by)
|
||||
KV_SERIALIZE(reverse)
|
||||
KV_SERIALIZE(offset)
|
||||
KV_SERIALIZE(limit)
|
||||
KV_SERIALIZE(timestamp_start)
|
||||
KV_SERIALIZE(timestamp_stop)
|
||||
KV_SERIALIZE(offer_type_mask)
|
||||
KV_SERIALIZE(amount_low_limit)
|
||||
KV_SERIALIZE(amount_up_limit)
|
||||
KV_SERIALIZE_CUSTOM(rate_low_limit, std::string, bc_services::transform_double_to_string, bc_services::transform_string_to_double)
|
||||
KV_SERIALIZE_CUSTOM(rate_up_limit, std::string, bc_services::transform_double_to_string, bc_services::transform_string_to_double)
|
||||
KV_SERIALIZE(payment_types)
|
||||
KV_SERIALIZE(location_country)
|
||||
KV_SERIALIZE(location_city)
|
||||
KV_SERIALIZE(target)
|
||||
KV_SERIALIZE(primary)
|
||||
KV_SERIALIZE(bonus)
|
||||
KV_SERIALIZE(category)
|
||||
KV_SERIALIZE(keyword)
|
||||
KV_SERIALIZE(fake)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct offer_id
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1168,6 +1168,7 @@ std::string daemon_backend::create_proposal(const view::create_proposal_param_gu
|
|||
return API_RETURN_CODE_INTERNAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
std::string daemon_backend::accept_proposal(size_t wallet_id, const crypto::hash& contract_id)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, w);
|
||||
|
|
@ -1400,10 +1401,10 @@ std::string daemon_backend::push_update_offer(const bc_services::update_offer_de
|
|||
}
|
||||
}
|
||||
|
||||
// std::string daemon_backend::get_all_offers(currency::COMMAND_RPC_GET_ALL_OFFERS::response& od)
|
||||
// std::string daemon_backend::get_all_offers(currency::COMMAND_RPC_GET_OFFERS_EX::response& od)
|
||||
// {
|
||||
// currency::COMMAND_RPC_GET_ALL_OFFERS::request rq = AUTO_VAL_INIT(rq);
|
||||
// m_rpc_proxy->call_COMMAND_RPC_GET_ALL_OFFERS(rq, od);
|
||||
// currency::COMMAND_RPC_GET_OFFERS_EX::request rq = AUTO_VAL_INIT(rq);
|
||||
// m_rpc_proxy->call_COMMAND_RPC_GET_OFFERS_EX(rq, od);
|
||||
// return API_RETURN_CODE_OK;
|
||||
// }
|
||||
|
||||
|
|
@ -1515,7 +1516,7 @@ void daemon_backend::wallet_vs_options::worker_func()
|
|||
auto w_ptr = *w; // get locked exclusive access to the wallet first (it's more likely that wallet is locked for a long time than 'offers')
|
||||
auto offers_list_proxy = *offers; // than get locked exclusive access to offers
|
||||
offers_list_proxy->clear();
|
||||
(*w_ptr)->get_actual_offers(*offers_list_proxy, false);
|
||||
(*w_ptr)->get_actual_offers(*offers_list_proxy);
|
||||
}
|
||||
|
||||
wallet_state = wsi.wallet_state = view::wallet_status_info::wallet_state_ready;
|
||||
|
|
|
|||
|
|
@ -88,10 +88,6 @@ public:
|
|||
std::string get_recent_transfers(size_t wallet_id, uint64_t offset, uint64_t count, view::transfers_array& tr_hist);
|
||||
std::string get_wallet_info(size_t wallet_id, view::wallet_info& wi);
|
||||
std::string get_contracts(size_t wallet_id, std::vector<tools::wallet_public::escrow_contract_details>& contracts);
|
||||
std::string create_proposal(size_t wallet_id, const bc_services::contract_private_details& escrow, const std::string& payment_id,
|
||||
uint64_t expiration_period,
|
||||
uint64_t fee,
|
||||
uint64_t b_fee);
|
||||
std::string create_proposal(const view::create_proposal_param_gui& cpp);
|
||||
std::string accept_proposal(size_t wallet_id, const crypto::hash& contract_id);
|
||||
std::string release_contract(size_t wallet_id, const crypto::hash& contract_id, const std::string& contract_over_type);
|
||||
|
|
@ -104,7 +100,7 @@ public:
|
|||
std::string push_offer(size_t wallet_id, const bc_services::offer_details_ex& od, currency::transaction& res_tx);
|
||||
std::string cancel_offer(const view::cancel_offer_param& co, currency::transaction& res_tx);
|
||||
std::string push_update_offer(const bc_services::update_offer_details& uo, currency::transaction& res_tx);
|
||||
//std::string get_all_offers(currency::COMMAND_RPC_GET_ALL_OFFERS::response& od);
|
||||
//std::string get_all_offers(currency::COMMAND_RPC_GET_OFFERS_EX::response& od);
|
||||
std::string get_offers_ex(const bc_services::core_offers_filter& cof, std::list<bc_services::offer_details_ex>& offers, uint64_t& total_count);
|
||||
std::string get_aliases(view::alias_set& al_set);
|
||||
std::string get_alias_info_by_address(const std::string& addr, currency::alias_rpc_details& res_details);
|
||||
|
|
|
|||
|
|
@ -1333,7 +1333,7 @@ QString MainWindow::get_log_level(const QString& param)
|
|||
// return MAKE_RESPONSE(ar);
|
||||
// }
|
||||
//
|
||||
// currency::COMMAND_RPC_GET_ALL_OFFERS::response rp = AUTO_VAL_INIT(rp);
|
||||
// currency::COMMAND_RPC_GET_OFFERS_EX::response rp = AUTO_VAL_INIT(rp);
|
||||
// ar.error_code = m_backend.get_all_offers(rp);
|
||||
//
|
||||
// std::string buff = epee::serialization::store_t_to_json(rp);
|
||||
|
|
@ -1435,7 +1435,7 @@ QString MainWindow::create_proposal(const QString& param)
|
|||
LOG_API_TIMING();
|
||||
PREPARE_ARG_FROM_JSON(view::create_proposal_param_gui, cpp);
|
||||
PREPARE_RESPONSE(tools::wallet_public::contracts_array, ar);
|
||||
ar.error_code = m_backend.create_proposal(cpp.wallet_id, cpp.details, cpp.payment_id, cpp.expiration_period, cpp.fee, cpp.b_fee);
|
||||
ar.error_code = m_backend.create_proposal(cpp);
|
||||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
}
|
||||
|
|
@ -1534,7 +1534,7 @@ QString MainWindow::get_my_offers(const QString& param)
|
|||
LOG_API_TIMING();
|
||||
//return que_call2<view::open_wallet_request>("open_wallet", param, [this](const view::open_wallet_request& owd, view::api_response& ar){
|
||||
PREPARE_ARG_FROM_JSON(bc_services::core_offers_filter, f);
|
||||
PREPARE_RESPONSE(currency::COMMAND_RPC_GET_ALL_OFFERS::response, ar);
|
||||
PREPARE_RESPONSE(currency::COMMAND_RPC_GET_OFFERS_EX::response, ar);
|
||||
ar.error_code = m_backend.get_my_offers(f, ar.response_data.offers);
|
||||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
|
|
@ -1544,7 +1544,7 @@ QString MainWindow::get_fav_offers(const QString& param)
|
|||
TRY_ENTRY();
|
||||
LOG_API_TIMING();
|
||||
PREPARE_ARG_FROM_JSON(view::get_fav_offers_request, f);
|
||||
PREPARE_RESPONSE(currency::COMMAND_RPC_GET_ALL_OFFERS::response, ar);
|
||||
PREPARE_RESPONSE(currency::COMMAND_RPC_GET_OFFERS_EX::response, ar);
|
||||
ar.error_code = m_backend.get_fav_offers(f.ids, f.filter, ar.response_data.offers);
|
||||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
|
|
@ -1587,7 +1587,7 @@ QString MainWindow::get_offers_ex(const QString& param)
|
|||
LOG_API_TIMING();
|
||||
//return que_call2<bc_services::core_offers_filter>("get_offers_ex", param, [this](const bc_services::core_offers_filter& f, view::api_response& ar){
|
||||
PREPARE_ARG_FROM_JSON(bc_services::core_offers_filter, f);
|
||||
PREPARE_RESPONSE(currency::COMMAND_RPC_GET_ALL_OFFERS::response, ar);
|
||||
PREPARE_RESPONSE(currency::COMMAND_RPC_GET_OFFERS_EX::response, ar);
|
||||
ar.error_code = m_backend.get_offers_ex(f, ar.response_data.offers, ar.response_data.total_offers);
|
||||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
|
|
@ -1602,7 +1602,6 @@ QString MainWindow::push_offer(const QString& param)
|
|||
PREPARE_ARG_FROM_JSON(view::push_offer_param, a);
|
||||
PREPARE_RESPONSE(view::transfer_response, ar);
|
||||
|
||||
|
||||
currency::transaction res_tx = AUTO_VAL_INIT(res_tx);
|
||||
|
||||
ar.error_code = m_backend.push_offer(a.wallet_id, a.od, res_tx);
|
||||
|
|
|
|||
|
|
@ -450,12 +450,12 @@ namespace currency
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
// bool core_rpc_server::on_rpc_get_all_offers(const COMMAND_RPC_GET_ALL_OFFERS::request& req, COMMAND_RPC_GET_ALL_OFFERS::response& res, connection_context& cntx)
|
||||
// {
|
||||
// m_core.get_blockchain_storage().get_all_offers(res.offers);
|
||||
// res.status = CORE_RPC_STATUS_OK;
|
||||
// return true;
|
||||
// }
|
||||
bool core_rpc_server::on_get_offers_ex(const COMMAND_RPC_GET_OFFERS_EX::request& req, COMMAND_RPC_GET_OFFERS_EX::response& res, epee::json_rpc::error& error_resp, connection_context& cntx)
|
||||
{
|
||||
m_of.get_offers_ex(req.filter, res.offers, res.total_offers, m_core.get_blockchain_storage().get_core_runtime_config().get_core_time());
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::on_get_pos_mining_details(const COMMAND_RPC_GET_POS_MINING_DETAILS::request& req, COMMAND_RPC_GET_POS_MINING_DETAILS::response& res, connection_context& cntx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace currency
|
|||
bool on_scan_pos(const COMMAND_RPC_SCAN_POS::request& req, COMMAND_RPC_SCAN_POS::response& res, connection_context& cntx);
|
||||
bool on_rpc_get_blocks_details(const COMMAND_RPC_GET_BLOCKS_DETAILS::request& req, COMMAND_RPC_GET_BLOCKS_DETAILS::response& res, connection_context& cntx);
|
||||
bool on_force_relaey_raw_txs(const COMMAND_RPC_FORCE_RELAY_RAW_TXS::request& req, COMMAND_RPC_FORCE_RELAY_RAW_TXS::response& res, connection_context& cntx);
|
||||
//bool on_rpc_get_all_offers(const COMMAND_RPC_GET_ALL_OFFERS::request& req, COMMAND_RPC_GET_ALL_OFFERS::response& res, connection_context& cntx);
|
||||
bool on_get_offers_ex(const COMMAND_RPC_GET_OFFERS_EX::request& req, COMMAND_RPC_GET_OFFERS_EX::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
|
||||
|
||||
|
||||
//json_rpc
|
||||
|
|
@ -151,6 +151,9 @@ namespace currency
|
|||
//
|
||||
MAP_JON_RPC ("reset_transaction_pool", on_reset_transaction_pool, COMMAND_RPC_RESET_TX_POOL)
|
||||
MAP_JON_RPC ("get_current_core_tx_expiration_median", on_get_current_core_tx_expiration_median, COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN)
|
||||
//
|
||||
MAP_JON_RPC_WE("get_offers_ex", on_get_offers_ex, COMMAND_RPC_GET_OFFERS_EX)
|
||||
|
||||
//remote miner rpc
|
||||
MAP_JON_RPC_N(on_login, mining::COMMAND_RPC_LOGIN)
|
||||
MAP_JON_RPC_N(on_getjob, mining::COMMAND_RPC_GETJOB)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include "storages/portable_storage_base.h"
|
||||
#include "currency_core/offers_service_basics.h"
|
||||
#include "currency_core/basic_api_response_codes.h"
|
||||
|
||||
namespace currency
|
||||
{
|
||||
//-----------------------------------------------
|
||||
|
|
@ -1505,12 +1504,13 @@ namespace currency
|
|||
};
|
||||
|
||||
|
||||
struct COMMAND_RPC_GET_ALL_OFFERS
|
||||
struct COMMAND_RPC_GET_OFFERS_EX
|
||||
{
|
||||
struct request
|
||||
{
|
||||
|
||||
bc_services::core_offers_filter filter;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(filter)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace tools
|
|||
virtual bool call_COMMAND_RPC_SUBMITBLOCK(const currency::COMMAND_RPC_SUBMITBLOCK::request& req, currency::COMMAND_RPC_SUBMITBLOCK::response& rsp){ return false; }
|
||||
virtual bool call_COMMAND_RPC_GET_POS_MINING_DETAILS(const currency::COMMAND_RPC_GET_POS_MINING_DETAILS::request& req, currency::COMMAND_RPC_GET_POS_MINING_DETAILS::response& rsp){ return false; }
|
||||
virtual bool call_COMMAND_RPC_GET_BLOCKS_DETAILS(const currency::COMMAND_RPC_GET_BLOCKS_DETAILS::request& req, currency::COMMAND_RPC_GET_BLOCKS_DETAILS::response& res){ return false; }
|
||||
virtual bool call_COMMAND_RPC_GET_ALL_OFFERS(const currency::COMMAND_RPC_GET_ALL_OFFERS::request& req, currency::COMMAND_RPC_GET_ALL_OFFERS::response& res){ return false; }
|
||||
virtual bool call_COMMAND_RPC_GET_OFFERS_EX(const currency::COMMAND_RPC_GET_OFFERS_EX::request& req, currency::COMMAND_RPC_GET_OFFERS_EX::response& res){ return false; }
|
||||
virtual bool call_COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN(const currency::COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN::request& req, currency::COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN::response& res){ return false; }
|
||||
virtual bool call_COMMAND_RPC_GET_POOL_INFO(const currency::COMMAND_RPC_GET_POOL_INFO::request& req, currency::COMMAND_RPC_GET_POOL_INFO::response& res) { return false; }
|
||||
|
||||
|
|
|
|||
|
|
@ -3661,10 +3661,9 @@ bool wallet2::select_my_offers(std::list<bc_services::offer_details_ex>& offers)
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::get_actual_offers(std::list<bc_services::offer_details_ex>& offers, bool fake)
|
||||
bool wallet2::get_actual_offers(std::list<bc_services::offer_details_ex>& offers)
|
||||
{
|
||||
select_my_offers(offers);
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#include "wallet_errors.h"
|
||||
#include "eos/portable_archive.hpp"
|
||||
#include "currency_core/core_runtime_config.h"
|
||||
#include "currency_core/offers_services_helpers.h"
|
||||
#include "currency_core/bc_offers_serialization.h"
|
||||
#include "currency_core/bc_escrow_service.h"
|
||||
#include "common/pod_array_file_container.h"
|
||||
|
|
@ -697,7 +696,7 @@ namespace tools
|
|||
bool backup_keys(const std::string& path);
|
||||
bool reset_password(const std::string& pass);
|
||||
bool is_password_valid(const std::string& pass);
|
||||
bool get_actual_offers(std::list<bc_services::offer_details_ex>& offers, bool fake = false);
|
||||
bool get_actual_offers(std::list<bc_services::offer_details_ex>& offers);
|
||||
bool get_fake_offers(std::list<bc_services::offer_details_ex>& offers, uint64_t amount);
|
||||
bool process_contract_info(wallet_public::wallet_transfer_info& wti, const std::vector<currency::payload_items_v>& decrypted_attach);
|
||||
bool handle_proposal(wallet_public::wallet_transfer_info& wti, const bc_services::proposal_body& prop);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
#include "wallet_rpc_server_error_codes.h"
|
||||
#include "currency_core/offers_service_basics.h"
|
||||
#include "currency_core/bc_escrow_service.h"
|
||||
#include "rpc/core_rpc_server_commands_defs.h"
|
||||
|
||||
namespace tools
|
||||
{
|
||||
namespace wallet_public
|
||||
|
|
@ -540,7 +542,7 @@ namespace wallet_public
|
|||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct COMMAND_SUBMIT_CONTRACT_PROPOSAL
|
||||
struct COMMAND_CONTRACTS_SEND_PROPOSAL
|
||||
{
|
||||
typedef create_proposal_param request;
|
||||
|
||||
|
|
@ -555,7 +557,7 @@ namespace wallet_public
|
|||
|
||||
|
||||
|
||||
struct COMMAND_SUBMIT_CONTRACT_ACCEPT
|
||||
struct COMMAND_CONTRACTS_ACCEPT_PROPOSAL
|
||||
{
|
||||
struct request
|
||||
{
|
||||
|
|
@ -576,7 +578,7 @@ namespace wallet_public
|
|||
};
|
||||
};
|
||||
|
||||
struct COMMAND_GET_CONTRACTS
|
||||
struct COMMAND_CONTRACTS_GET_ALL
|
||||
{
|
||||
struct request
|
||||
{
|
||||
|
|
@ -587,7 +589,7 @@ namespace wallet_public
|
|||
typedef contracts_array response;
|
||||
};
|
||||
|
||||
struct COMMAND_RELEASE_CONTRACT
|
||||
struct COMMAND_CONTRACTS_RELEASE
|
||||
{
|
||||
struct request
|
||||
{
|
||||
|
|
@ -608,7 +610,7 @@ namespace wallet_public
|
|||
};
|
||||
};
|
||||
|
||||
struct COMMAND_REQUEST_CANCEL_CONTRACT
|
||||
struct COMMAND_CONTRACTS_REQUEST_CANCEL
|
||||
{
|
||||
struct request
|
||||
{
|
||||
|
|
@ -631,7 +633,7 @@ namespace wallet_public
|
|||
};
|
||||
};
|
||||
|
||||
struct COMMAND_ACCEPT_CANCEL_CONTRACT
|
||||
struct COMMAND_CONTRACTS_ACCEPT_CANCEL
|
||||
{
|
||||
struct request
|
||||
{
|
||||
|
|
@ -651,6 +653,90 @@ namespace wallet_public
|
|||
};
|
||||
};
|
||||
|
||||
//--------------------
|
||||
typedef currency::COMMAND_RPC_GET_OFFERS_EX COMMAND_MARKETPLACE_GET_MY_OFFERS;
|
||||
|
||||
struct COMMAND_MARKETPLACE_PUSH_OFFER
|
||||
{
|
||||
struct request
|
||||
{
|
||||
bc_services::offer_details_ex od;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(od)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct response
|
||||
{
|
||||
std::string tx_hash;
|
||||
uint64_t tx_blob_size;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tx_hash)
|
||||
KV_SERIALIZE(tx_blob_size)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
struct COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER
|
||||
{
|
||||
struct request
|
||||
{
|
||||
crypto::hash tx_id;
|
||||
uint64_t no;
|
||||
bc_services::offer_details_ex od;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(tx_id)
|
||||
KV_SERIALIZE(no)
|
||||
KV_SERIALIZE(od)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct response
|
||||
{
|
||||
std::string tx_hash;
|
||||
uint64_t tx_blob_size;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tx_hash)
|
||||
KV_SERIALIZE(tx_blob_size)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
struct COMMAND_MARKETPLACE_CANCEL_OFFER
|
||||
{
|
||||
struct request
|
||||
{
|
||||
crypto::hash tx_id;
|
||||
uint64_t no;
|
||||
uint64_t fee;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(tx_id)
|
||||
KV_SERIALIZE(no)
|
||||
KV_SERIALIZE(fee)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct response
|
||||
{
|
||||
std::string tx_hash;
|
||||
uint64_t tx_blob_size;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tx_hash)
|
||||
KV_SERIALIZE(tx_blob_size)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
inline std::string get_escrow_contract_state_name(uint32_t state)
|
||||
{
|
||||
switch (state)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,22 @@ using namespace epee;
|
|||
#include "crypto/hash.h"
|
||||
#include "wallet_rpc_server_error_codes.h"
|
||||
|
||||
#define WALLET_RPC_BEGIN_TRY_ENTRY() try {
|
||||
#define WALLET_RPC_CATCH_TRY_ENTRY() } \
|
||||
catch (const std::exception& e) \
|
||||
{ \
|
||||
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR; \
|
||||
er.message = e.what(); \
|
||||
return false; \
|
||||
} \
|
||||
catch (...) \
|
||||
{ \
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; \
|
||||
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR"; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
|
||||
namespace tools
|
||||
{
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
|
@ -246,16 +262,9 @@ namespace tools
|
|||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_store(const wallet_public::COMMAND_RPC_STORE::request& req, wallet_public::COMMAND_RPC_STORE::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_wallet.store();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = e.what();
|
||||
return false;
|
||||
}
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
m_wallet.store();
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
@ -380,34 +389,21 @@ namespace tools
|
|||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_sign_transfer(const wallet_public::COMMAND_SIGN_TRANSFER::request& req, wallet_public::COMMAND_SIGN_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
try
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
currency::transaction tx = AUTO_VAL_INIT(tx);
|
||||
std::string tx_unsigned_blob;
|
||||
if (!string_tools::parse_hexstr_to_binbuff(req.tx_unsigned_hex, tx_unsigned_blob))
|
||||
{
|
||||
currency::transaction tx = AUTO_VAL_INIT(tx);
|
||||
std::string tx_unsigned_blob;
|
||||
if (!string_tools::parse_hexstr_to_binbuff(req.tx_unsigned_hex, tx_unsigned_blob))
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_ARGUMENT;
|
||||
er.message = "tx_unsigned_hex is invalid";
|
||||
return false;
|
||||
}
|
||||
std::string tx_signed_blob;
|
||||
m_wallet.sign_transfer(tx_unsigned_blob, tx_signed_blob, tx);
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_ARGUMENT;
|
||||
er.message = "tx_unsigned_hex is invalid";
|
||||
return false;
|
||||
}
|
||||
std::string tx_signed_blob;
|
||||
m_wallet.sign_transfer(tx_unsigned_blob, tx_signed_blob, tx);
|
||||
|
||||
res.tx_signed_hex = epee::string_tools::buff_to_hex_nodelimer(tx_signed_blob);
|
||||
res.tx_hash = epee::string_tools::pod_to_hex(currency::get_transaction_hash(tx));
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
|
||||
er.message = e.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
|
||||
return false;
|
||||
}
|
||||
res.tx_signed_hex = epee::string_tools::buff_to_hex_nodelimer(tx_signed_blob);
|
||||
res.tx_hash = epee::string_tools::pod_to_hex(currency::get_transaction_hash(tx));
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
@ -421,161 +417,122 @@ namespace tools
|
|||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
currency::transaction tx = AUTO_VAL_INIT(tx);
|
||||
m_wallet.submit_transfer(tx_signed_blob, tx);
|
||||
res.tx_hash = epee::string_tools::pod_to_hex(currency::get_transaction_hash(tx));
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
|
||||
er.message = e.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
|
||||
return false;
|
||||
}
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
currency::transaction tx = AUTO_VAL_INIT(tx);
|
||||
m_wallet.submit_transfer(tx_signed_blob, tx);
|
||||
res.tx_hash = epee::string_tools::pod_to_hex(currency::get_transaction_hash(tx));
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_submit_contract_proposal(const wallet_public::COMMAND_SUBMIT_CONTRACT_PROPOSAL::request& req, wallet_public::COMMAND_SUBMIT_CONTRACT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_contracts_send_proposal(const wallet_public::COMMAND_CONTRACTS_SEND_PROPOSAL::request& req, wallet_public::COMMAND_CONTRACTS_SEND_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
try
|
||||
{
|
||||
currency::transaction tx = AUTO_VAL_INIT(tx);
|
||||
currency::transaction template_tx = AUTO_VAL_INIT(template_tx);
|
||||
m_wallet.send_escrow_proposal(req, tx, template_tx);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
|
||||
er.message = e.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
|
||||
return false;
|
||||
}
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
currency::transaction tx = AUTO_VAL_INIT(tx);
|
||||
currency::transaction template_tx = AUTO_VAL_INIT(template_tx);
|
||||
m_wallet.send_escrow_proposal(req, tx, template_tx);
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_submit_contract_accept(const wallet_public::COMMAND_SUBMIT_CONTRACT_ACCEPT::request& req, wallet_public::COMMAND_SUBMIT_CONTRACT_ACCEPT::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_contracts_accept_proposal(const wallet_public::COMMAND_CONTRACTS_ACCEPT_PROPOSAL::request& req, wallet_public::COMMAND_CONTRACTS_ACCEPT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_wallet.accept_proposal(req.contract_id, req.acceptance_fee);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
|
||||
er.message = e.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
|
||||
return false;
|
||||
}
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
m_wallet.accept_proposal(req.contract_id, req.acceptance_fee);
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_get_contracts(const wallet_public::COMMAND_GET_CONTRACTS::request& req, wallet_public::COMMAND_GET_CONTRACTS::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_contracts_get_all(const wallet_public::COMMAND_CONTRACTS_GET_ALL::request& req, wallet_public::COMMAND_CONTRACTS_GET_ALL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
try
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
tools::wallet2::escrow_contracts_container ecc;
|
||||
m_wallet.get_contracts(ecc);
|
||||
res.contracts.resize(ecc.size());
|
||||
size_t i = 0;
|
||||
for (auto& c : ecc)
|
||||
{
|
||||
tools::wallet2::escrow_contracts_container ecc;
|
||||
m_wallet.get_contracts(ecc);
|
||||
res.contracts.resize(ecc.size());
|
||||
size_t i = 0;
|
||||
for (auto& c : ecc)
|
||||
{
|
||||
static_cast<tools::wallet_public::escrow_contract_details_basic&>(res.contracts[i]) = c.second;
|
||||
res.contracts[i].contract_id = c.first;
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
|
||||
er.message = e.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
|
||||
return false;
|
||||
static_cast<tools::wallet_public::escrow_contract_details_basic&>(res.contracts[i]) = c.second;
|
||||
res.contracts[i].contract_id = c.first;
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
bool wallet_rpc_server::on_release_contract(const wallet_public::COMMAND_RELEASE_CONTRACT::request& req, wallet_public::COMMAND_RELEASE_CONTRACT::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_contracts_release(const wallet_public::COMMAND_CONTRACTS_RELEASE::request& req, wallet_public::COMMAND_CONTRACTS_RELEASE::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_wallet.finish_contract(req.contract_id, req.release_type);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
|
||||
er.message = e.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
|
||||
return false;
|
||||
}
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
m_wallet.finish_contract(req.contract_id, req.release_type);
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
bool wallet_rpc_server::on_request_cancel_contract(const wallet_public::COMMAND_REQUEST_CANCEL_CONTRACT::request& req, wallet_public::COMMAND_REQUEST_CANCEL_CONTRACT::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_contracts_request_cancel(const wallet_public::COMMAND_CONTRACTS_REQUEST_CANCEL::request& req, wallet_public::COMMAND_CONTRACTS_REQUEST_CANCEL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_wallet.request_cancel_contract(req.contract_id, req.fee, req.expiration_period);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
|
||||
er.message = e.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
|
||||
return false;
|
||||
}
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
m_wallet.request_cancel_contract(req.contract_id, req.fee, req.expiration_period);
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
bool wallet_rpc_server::on_accept_cancel_contract(const wallet_public::COMMAND_ACCEPT_CANCEL_CONTRACT::request& req, wallet_public::COMMAND_ACCEPT_CANCEL_CONTRACT::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_contracts_accept_cancel(const wallet_public::COMMAND_CONTRACTS_ACCEPT_CANCEL::request& req, wallet_public::COMMAND_CONTRACTS_ACCEPT_CANCEL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_wallet.accept_cancel_contract(req.contract_id);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
|
||||
er.message = e.what();
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
|
||||
return false;
|
||||
}
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
m_wallet.accept_cancel_contract(req.contract_id);
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_marketplace_get_my_offers(const wallet_public::COMMAND_MARKETPLACE_GET_MY_OFFERS::request& req, wallet_public::COMMAND_MARKETPLACE_GET_MY_OFFERS::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
m_wallet.get_actual_offers(res.offers);
|
||||
size_t offers_count_before_filtering = res.offers.size();
|
||||
bc_services::filter_offers_list(res.offers, req.filter, m_wallet.get_core_runtime_config().get_core_time());
|
||||
LOG_PRINT("get_my_offers(): " << res.offers.size() << " offers returned (" << offers_count_before_filtering << " was before filter)", LOG_LEVEL_1);
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_marketplace_push_offer(const wallet_public::COMMAND_MARKETPLACE_PUSH_OFFER::request& req, wallet_public::COMMAND_MARKETPLACE_PUSH_OFFER::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
currency::transaction res_tx = AUTO_VAL_INIT(res_tx);
|
||||
m_wallet.push_offer(req.od, res_tx);
|
||||
|
||||
res.tx_hash = string_tools::pod_to_hex(currency::get_transaction_hash(res_tx));
|
||||
res.tx_blob_size = currency::get_object_blobsize(res_tx);
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_marketplace_push_update_offer(const wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER::request& req, wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
currency::transaction res_tx = AUTO_VAL_INIT(res_tx);
|
||||
m_wallet.update_offer_by_id(req.tx_id, req.no, req.od, res_tx);
|
||||
|
||||
res.tx_hash = string_tools::pod_to_hex(currency::get_transaction_hash(res_tx));
|
||||
res.tx_blob_size = currency::get_object_blobsize(res_tx);
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_marketplace_cancel_offer(const wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER::request& req, wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
WALLET_RPC_BEGIN_TRY_ENTRY();
|
||||
currency::transaction res_tx = AUTO_VAL_INIT(res_tx);
|
||||
m_wallet.cancel_offer_by_id(req.tx_id, req.no, req.fee, res_tx);
|
||||
|
||||
res.tx_hash = string_tools::pod_to_hex(currency::get_transaction_hash(res_tx));
|
||||
res.tx_blob_size = currency::get_object_blobsize(res_tx);
|
||||
return true;
|
||||
WALLET_RPC_CATCH_TRY_ENTRY();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace tools
|
||||
|
|
|
|||
|
|
@ -49,13 +49,18 @@ namespace tools
|
|||
MAP_JON_RPC_WE("split_integrated_address", on_split_integrated_address, wallet_public::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS)
|
||||
MAP_JON_RPC_WE("sign_transfer", on_sign_transfer, wallet_public::COMMAND_SIGN_TRANSFER)
|
||||
MAP_JON_RPC_WE("submit_transfer", on_submit_transfer, wallet_public::COMMAND_SUBMIT_TRANSFER)
|
||||
//market API
|
||||
MAP_JON_RPC_WE("contracts_send_proposal", on_submit_contract_proposal, wallet_public::COMMAND_SUBMIT_CONTRACT_PROPOSAL)
|
||||
MAP_JON_RPC_WE("contracts_accept_proposal", on_submit_contract_accept, wallet_public::COMMAND_SUBMIT_CONTRACT_ACCEPT)
|
||||
MAP_JON_RPC_WE("contracts_get_all", on_get_contracts, wallet_public::COMMAND_GET_CONTRACTS)
|
||||
MAP_JON_RPC_WE("contracts_release", on_release_contract, wallet_public::COMMAND_RELEASE_CONTRACT)
|
||||
MAP_JON_RPC_WE("contracts_request_cancel", on_request_cancel_contract, wallet_public::COMMAND_REQUEST_CANCEL_CONTRACT)
|
||||
MAP_JON_RPC_WE("contracts_accept_cancel", on_accept_cancel_contract, wallet_public::COMMAND_ACCEPT_CANCEL_CONTRACT)
|
||||
//contracts API
|
||||
MAP_JON_RPC_WE("contracts_send_proposal", on_contracts_send_proposal, wallet_public::COMMAND_CONTRACTS_SEND_PROPOSAL)
|
||||
MAP_JON_RPC_WE("contracts_accept_proposal", on_contracts_accept_proposal, wallet_public::COMMAND_CONTRACTS_ACCEPT_PROPOSAL)
|
||||
MAP_JON_RPC_WE("contracts_get_all", on_contracts_get_all, wallet_public::COMMAND_CONTRACTS_GET_ALL)
|
||||
MAP_JON_RPC_WE("contracts_release", on_contracts_release, wallet_public::COMMAND_CONTRACTS_RELEASE)
|
||||
MAP_JON_RPC_WE("contracts_request_cancel", on_contracts_request_cancel, wallet_public::COMMAND_CONTRACTS_REQUEST_CANCEL)
|
||||
MAP_JON_RPC_WE("contracts_accept_cancel", on_contracts_accept_cancel, wallet_public::COMMAND_CONTRACTS_ACCEPT_CANCEL)
|
||||
//marketplace API
|
||||
MAP_JON_RPC_WE("marketplace_get_offers_ex", on_marketplace_get_my_offers, wallet_public::COMMAND_MARKETPLACE_GET_MY_OFFERS)
|
||||
MAP_JON_RPC_WE("marketplace_push_offer", on_marketplace_push_offer, wallet_public::COMMAND_MARKETPLACE_PUSH_OFFER)
|
||||
MAP_JON_RPC_WE("marketplace_push_update_offer", on_marketplace_push_update_offer, wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER)
|
||||
MAP_JON_RPC_WE("marketplace_cancel_offer", on_marketplace_cancel_offer, wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER)
|
||||
END_JSON_RPC_MAP()
|
||||
END_URI_MAP2()
|
||||
|
||||
|
|
@ -70,12 +75,18 @@ namespace tools
|
|||
bool on_split_integrated_address(const wallet_public::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS::request& req, wallet_public::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_sign_transfer(const wallet_public::COMMAND_SIGN_TRANSFER::request& req, wallet_public::COMMAND_SIGN_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_submit_transfer(const wallet_public::COMMAND_SUBMIT_TRANSFER::request& req, wallet_public::COMMAND_SUBMIT_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_submit_contract_proposal(const wallet_public::COMMAND_SUBMIT_CONTRACT_PROPOSAL::request& req, wallet_public::COMMAND_SUBMIT_CONTRACT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_submit_contract_accept(const wallet_public::COMMAND_SUBMIT_CONTRACT_ACCEPT::request& req, wallet_public::COMMAND_SUBMIT_CONTRACT_ACCEPT::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_get_contracts(const wallet_public::COMMAND_GET_CONTRACTS::request& req, wallet_public::COMMAND_GET_CONTRACTS::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_release_contract(const wallet_public::COMMAND_RELEASE_CONTRACT::request& req, wallet_public::COMMAND_RELEASE_CONTRACT::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_request_cancel_contract(const wallet_public::COMMAND_REQUEST_CANCEL_CONTRACT::request& req, wallet_public::COMMAND_REQUEST_CANCEL_CONTRACT::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_accept_cancel_contract(const wallet_public::COMMAND_ACCEPT_CANCEL_CONTRACT::request& req, wallet_public::COMMAND_ACCEPT_CANCEL_CONTRACT::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
|
||||
bool on_contracts_send_proposal(const wallet_public::COMMAND_CONTRACTS_SEND_PROPOSAL::request& req, wallet_public::COMMAND_CONTRACTS_SEND_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_contracts_accept_proposal(const wallet_public::COMMAND_CONTRACTS_ACCEPT_PROPOSAL::request& req, wallet_public::COMMAND_CONTRACTS_ACCEPT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_contracts_get_all(const wallet_public::COMMAND_CONTRACTS_GET_ALL::request& req, wallet_public::COMMAND_CONTRACTS_GET_ALL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_contracts_release(const wallet_public::COMMAND_CONTRACTS_RELEASE::request& req, wallet_public::COMMAND_CONTRACTS_RELEASE::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_contracts_request_cancel(const wallet_public::COMMAND_CONTRACTS_REQUEST_CANCEL::request& req, wallet_public::COMMAND_CONTRACTS_REQUEST_CANCEL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_contracts_accept_cancel(const wallet_public::COMMAND_CONTRACTS_ACCEPT_CANCEL::request& req, wallet_public::COMMAND_CONTRACTS_ACCEPT_CANCEL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
|
||||
bool on_marketplace_get_my_offers(const wallet_public::COMMAND_MARKETPLACE_GET_MY_OFFERS::request& req, wallet_public::COMMAND_MARKETPLACE_GET_MY_OFFERS::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_marketplace_push_offer(const wallet_public::COMMAND_MARKETPLACE_PUSH_OFFER::request& req, wallet_public::COMMAND_MARKETPLACE_PUSH_OFFER::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_marketplace_push_update_offer(const wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER::request& req, wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_marketplace_cancel_offer(const wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER::request& req, wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
|
||||
|
||||
bool handle_command_line(const boost::program_options::variables_map& vm);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue