forked from lthn/blockchain
added get_integrated_address to daemon
This commit is contained in:
parent
d4cc1bd6ff
commit
bafae7b120
3 changed files with 73 additions and 0 deletions
|
|
@ -1510,6 +1510,50 @@ namespace currency
|
|||
#undef LOCAL_CHECK
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::on_get_integrated_address(const COMMAND_RPC_GET_INTEGRATED_ADDRESS::request& req, COMMAND_RPC_GET_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx)
|
||||
{
|
||||
std::string payment_id;
|
||||
if (!epee::string_tools::parse_hexstr_to_binbuff(req.payment_id, payment_id))
|
||||
{
|
||||
error_resp.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||
error_resp.message = std::string("invalid payment id given: \'") + req.payment_id + "\', hex-encoded string was expected";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!currency::is_payment_id_size_ok(payment_id))
|
||||
{
|
||||
error_resp.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||
error_resp.message = std::string("given payment id is too long: \'") + req.payment_id + "\'";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (payment_id.empty())
|
||||
{
|
||||
payment_id = std::string(8, ' ');
|
||||
crypto::generate_random_bytes(payment_id.size(), &payment_id.front());
|
||||
}
|
||||
|
||||
|
||||
std::string payment_id_from_provided_addr; // won't be used
|
||||
account_public_address addr = AUTO_VAL_INIT(addr);
|
||||
if (!get_account_address_and_payment_id_from_str(addr, payment_id_from_provided_addr, req.regular_address))
|
||||
{
|
||||
error_resp.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
|
||||
error_resp.message = std::string("invalid address provided: \'") + req.regular_address + "\', Zano address expected";
|
||||
return false;
|
||||
}
|
||||
if (payment_id_from_provided_addr.size())
|
||||
{
|
||||
error_resp.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
|
||||
error_resp.message = std::string("invalid address provided: \'") + req.regular_address + "\', Zano address expected be regular and NOT integrated address";
|
||||
return false;
|
||||
}
|
||||
|
||||
res.integrated_address = currency::get_account_address_and_payment_id_as_str(addr, payment_id);
|
||||
res.payment_id = epee::string_tools::buff_to_hex_nodelimer(payment_id);
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::on_aliases_by_address(const COMMAND_RPC_GET_ALIASES_BY_ADDRESS::request& req, COMMAND_RPC_GET_ALIASES_BY_ADDRESS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx)
|
||||
{
|
||||
account_public_address addr = AUTO_VAL_INIT(addr);
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ namespace currency
|
|||
bool on_get_alt_blocks_details(const COMMAND_RPC_GET_ALT_BLOCKS_DETAILS::request& req, COMMAND_RPC_GET_ALT_BLOCKS_DETAILS::response& res, connection_context& cntx);
|
||||
bool on_get_est_height_from_date(const COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE::request& req, COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE::response& res, connection_context& cntx);
|
||||
bool on_find_outs_in_recent_blocks(const COMMAND_RPC_FIND_OUTS_IN_RECENT_BLOCKS::request& req, COMMAND_RPC_FIND_OUTS_IN_RECENT_BLOCKS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
|
||||
bool on_get_integrated_address(const COMMAND_RPC_GET_INTEGRATED_ADDRESS::request& req, COMMAND_RPC_GET_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
|
||||
bool on_validate_signature(const COMMAND_VALIDATE_SIGNATURE::request& req, COMMAND_VALIDATE_SIGNATURE::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
|
||||
|
||||
|
|
@ -141,6 +142,7 @@ namespace currency
|
|||
MAP_JON_RPC_WE("get_alias_reward", on_get_alias_reward, COMMAND_RPC_GET_ALIAS_REWARD)
|
||||
MAP_JON_RPC ("get_est_height_from_date", on_get_est_height_from_date, COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE)
|
||||
MAP_JON_RPC_WE("find_outs_in_recent_blocks", on_find_outs_in_recent_blocks, COMMAND_RPC_FIND_OUTS_IN_RECENT_BLOCKS)
|
||||
MAP_JON_RPC_WE("get_integrated_address", on_get_integrated_address, COMMAND_RPC_GET_INTEGRATED_ADDRESS)
|
||||
|
||||
//block explorer api
|
||||
MAP_JON_RPC ("get_blocks_details", on_rpc_get_blocks_details, COMMAND_RPC_GET_BLOCKS_DETAILS)
|
||||
|
|
|
|||
|
|
@ -442,6 +442,33 @@ namespace currency
|
|||
};
|
||||
};
|
||||
//-----------------------------------------------
|
||||
struct COMMAND_RPC_GET_INTEGRATED_ADDRESS
|
||||
{
|
||||
DOC_COMMAND("Make integrated address from regular address");
|
||||
|
||||
struct request
|
||||
{
|
||||
std::string payment_id; // hex-encoded
|
||||
std::string regular_address; // hex-encoded
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(payment_id) DOC_DSCR("Hex-encoded Payment ID to be associated with the this address. If empty then wallet would generate new payment id using system random library") DOC_EXMP("1dfe5a88ff9effb3") DOC_END
|
||||
KV_SERIALIZE(regular_address) DOC_DSCR("Zano wallet address to be used as a base for integrated address") DOC_EXMP("ZxCSpsGGeJsS8fwvQ4HktDU3qBeauoJTR6j73jAWWZxFXdF7XTbGm4YfS2kXJmAP4Rf5BVsSQ9iZ45XANXEYsrLN2L2W77dH7") DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct response
|
||||
{
|
||||
std::string integrated_address;
|
||||
std::string payment_id; // hex-encoded
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(integrated_address) DOC_DSCR("Integrated address combining a standard address and payment ID, if applicable.") DOC_EXMP("iZ2EMyPD7g28hgBfboZeCENaYrHBYZ1bLFi5cgWvn4WJLaxfgs4kqG6cJi9ai2zrXWSCpsvRXit14gKjeijx6YPCLJEv6Fx4rVm1hdAGQFis") DOC_END
|
||||
KV_SERIALIZE(payment_id) DOC_DSCR("Payment ID associated with the this address.") DOC_EXMP("1dfe5a88ff9effb3") DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
//-----------------------------------------------
|
||||
struct COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES
|
||||
{
|
||||
DOC_COMMAND("Obtain global outputs' indexes for the given txs.")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue