1
0
Fork 0
forked from lthn/blockchain

Implemented basic code for ionic_swap rpc

This commit is contained in:
cryptozoidberg 2023-03-23 19:24:23 +01:00
parent 94861608cf
commit 2b9227c0f1
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
3 changed files with 91 additions and 0 deletions

View file

@ -1178,6 +1178,74 @@ namespace wallet_public
};
};
struct COMMAND_IONIC_SWAP_GENERATE_PROPOSAL
{
struct request
{
view::ionic_swap_proposal_info proposal;
std::string destination_address;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(proposal)
KV_SERIALIZE(destination_address)
END_KV_SERIALIZE_MAP()
};
struct response
{
std::string hex_raw_proposal;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(hex_raw_proposal)
END_KV_SERIALIZE_MAP()
};
};
struct COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO
{
struct request
{
std::string hex_raw_proposal;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(hex_raw_proposal)
END_KV_SERIALIZE_MAP()
};
struct response
{
view::ionic_swap_proposal_info proposal;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(proposal)
END_KV_SERIALIZE_MAP()
};
};
struct COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL
{
struct request
{
std::string hex_raw_proposal;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(hex_raw_proposal)
END_KV_SERIALIZE_MAP()
};
struct response
{
crypto::hash result_tx_id;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_POD_AS_HEX_STRING(result_tx_id)
END_KV_SERIALIZE_MAP()
};
};
struct assets_whitelist
{
std::vector<currency::asset_descriptor_with_id> assets;

View file

@ -926,6 +926,21 @@ namespace tools
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_ionic_swap_generate_proposal(const wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL& req, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx)
{
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_ionic_swap_get_proposal_info(const wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO& req, wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx)
{
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_ionic_swap_accept_proposal(const wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL& req, wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx)
{
}
//------------------------------------------------------------------------------------------------------------------------------
} // namespace tools

View file

@ -73,6 +73,10 @@ namespace tools
MAP_JON_RPC_WE("atomics_redeem_htlc", on_redeem_htlc, wallet_public::COMMAND_REDEEM_HTLC)
MAP_JON_RPC_WE("atomics_check_htlc_redeemed", on_check_htlc_redeemed, wallet_public::COMMAND_CHECK_HTLC_REDEEMED)
//IONIC_SWAPS API
MAP_JON_RPC_WE("ionic_swap_generate_proposal", on_ionic_swap_generate_proposal, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL)
MAP_JON_RPC_WE("ionic_swap_get_proposal_info", on_ionic_swap_get_proposal_info, wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO)
MAP_JON_RPC_WE("ionic_swap_accept_proposal", on_ionic_swap_accept_proposal, wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL)
END_JSON_RPC_MAP()
END_URI_MAP2()
@ -114,6 +118,10 @@ namespace tools
bool on_redeem_htlc(const wallet_public::COMMAND_REDEEM_HTLC::request& req, wallet_public::COMMAND_REDEEM_HTLC::response& res, epee::json_rpc::error& er, connection_context& cntx);
bool on_check_htlc_redeemed(const wallet_public::COMMAND_CHECK_HTLC_REDEEMED::request& req, wallet_public::COMMAND_CHECK_HTLC_REDEEMED::response& res, epee::json_rpc::error& er, connection_context& cntx);
bool on_ionic_swap_generate_proposal(const wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL& req, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx);
bool on_ionic_swap_get_proposal_info(const wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO& req, wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx);
bool on_ionic_swap_accept_proposal(const wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL& req, wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx);
bool handle_command_line(const boost::program_options::variables_map& vm);