get_payments short ID
Add support for short/integrated/encrypted IDs to get_payments RPC
This commit is contained in:
parent
a7310031f4
commit
e2b7e55be6
1 changed files with 17 additions and 8 deletions
|
@ -461,6 +461,7 @@ namespace tools
|
||||||
bool wallet_rpc_server::on_get_payments(const wallet_rpc::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_PAYMENTS::response& res, epee::json_rpc::error& er)
|
bool wallet_rpc_server::on_get_payments(const wallet_rpc::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_PAYMENTS::response& res, epee::json_rpc::error& er)
|
||||||
{
|
{
|
||||||
crypto::hash payment_id;
|
crypto::hash payment_id;
|
||||||
|
crypto::hash8 payment_id8;
|
||||||
cryptonote::blobdata payment_id_blob;
|
cryptonote::blobdata payment_id_blob;
|
||||||
if(!epee::string_tools::parse_hexstr_to_binbuff(req.payment_id, payment_id_blob))
|
if(!epee::string_tools::parse_hexstr_to_binbuff(req.payment_id, payment_id_blob))
|
||||||
{
|
{
|
||||||
|
@ -469,15 +470,23 @@ namespace tools
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sizeof(payment_id) != payment_id_blob.size())
|
if(sizeof(payment_id) == payment_id_blob.size())
|
||||||
|
{
|
||||||
|
payment_id = *reinterpret_cast<const crypto::hash*>(payment_id_blob.data());
|
||||||
|
}
|
||||||
|
else if(sizeof(payment_id8) == payment_id_blob.size())
|
||||||
|
{
|
||||||
|
payment_id8 = *reinterpret_cast<const crypto::hash8*>(payment_id_blob.data());
|
||||||
|
memcpy(payment_id.data, payment_id8.data, 8);
|
||||||
|
memset(payment_id.data + 8, 0, 24);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||||
er.message = "Payment ID has invalid size";
|
er.message = "Payment ID has invalid size: " + req.payment_id;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
payment_id = *reinterpret_cast<const crypto::hash*>(payment_id_blob.data());
|
|
||||||
|
|
||||||
res.payments.clear();
|
res.payments.clear();
|
||||||
std::list<wallet2::payment_details> payment_list;
|
std::list<wallet2::payment_details> payment_list;
|
||||||
m_wallet.get_payments(payment_id, payment_list);
|
m_wallet.get_payments(payment_id, payment_list);
|
||||||
|
|
Loading…
Reference in a new issue