aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet_rpc_server.cpp
diff options
context:
space:
mode:
authorZachary Michaels <mikezackles@gmail.com>2014-07-22 12:00:25 -0400
committerZachary Michaels <mikezackles@gmail.com>2014-07-22 12:16:15 -0400
commit12596ad566b23c0b88678c01c0d1871167fefc79 (patch)
tree3d70b64f7f529681672facc1a5d766b076ef8bc8 /src/wallet/wallet_rpc_server.cpp
parentMerge pull request #65 from tewinget/daemon_rpc (diff)
downloadmonero-12596ad566b23c0b88678c01c0d1871167fefc79.tar.xz
Add get_bulk_payments rpc call
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r--src/wallet/wallet_rpc_server.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index ec31d4625..228e43678 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -268,9 +268,10 @@ namespace tools
res.payments.clear();
std::list<wallet2::payment_details> payment_list;
m_wallet.get_payments(payment_id, payment_list);
- for (auto payment : payment_list)
+ for (auto & payment : payment_list)
{
wallet_rpc::payment_details rpc_payment;
+ rpc_payment.payment_id = req.payment_id;
rpc_payment.tx_hash = epee::string_tools::pod_to_hex(payment.m_tx_hash);
rpc_payment.amount = payment.m_amount;
rpc_payment.block_height = payment.m_block_height;
@@ -281,6 +282,51 @@ namespace tools
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_get_bulk_payments(const wallet_rpc::COMMAND_RPC_GET_BULK_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_BULK_PAYMENTS::response& res, epee::json_rpc::error& er, connection_context& cntx)
+ {
+ res.payments.clear();
+
+ for (auto & payment_id_str : req.payment_ids)
+ {
+ crypto::hash payment_id;
+ cryptonote::blobdata payment_id_blob;
+
+ // TODO - should the whole thing fail because of one bad id?
+
+ if(!epee::string_tools::parse_hexstr_to_binbuff(payment_id_str, payment_id_blob))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
+ er.message = "Payment ID has invalid format: " + payment_id_str;
+ return false;
+ }
+
+ if(sizeof(payment_id) != payment_id_blob.size())
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
+ er.message = "Payment ID has invalid size: " + payment_id_str;
+ return false;
+ }
+
+ payment_id = *reinterpret_cast<const crypto::hash*>(payment_id_blob.data());
+
+ std::list<wallet2::payment_details> payment_list;
+ m_wallet.get_payments(payment_id, payment_list, req.min_block_height);
+
+ for (auto & payment : payment_list)
+ {
+ wallet_rpc::payment_details rpc_payment;
+ rpc_payment.payment_id = payment_id_str;
+ rpc_payment.tx_hash = epee::string_tools::pod_to_hex(payment.m_tx_hash);
+ rpc_payment.amount = payment.m_amount;
+ rpc_payment.block_height = payment.m_block_height;
+ rpc_payment.unlock_time = payment.m_unlock_time;
+ res.payments.push_back(std::move(rpc_payment));
+ }
+ }
+
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_incoming_transfers(const wallet_rpc::COMMAND_RPC_INCOMING_TRANSFERS::request& req, wallet_rpc::COMMAND_RPC_INCOMING_TRANSFERS::response& res, epee::json_rpc::error& er, connection_context& cntx)
{
if(req.transfer_type.compare("all") != 0 && req.transfer_type.compare("available") != 0 && req.transfer_type.compare("unavailable") != 0)