aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet_rpc_server.cpp
diff options
context:
space:
mode:
authormydesktop <dev.mc2@gmail.com>2014-05-03 12:19:43 -0400
committermydesktop <dev.mc2@gmail.com>2014-05-03 12:19:43 -0400
commit333f975760c156727dd7408f87e937af856d8bf1 (patch)
tree1928b27eaac60f0b528f17abbc52d5ad812013d0 /src/wallet/wallet_rpc_server.cpp
parentMerge branch 'master' of github.com:monero-project/bitmonero (diff)
downloadmonero-333f975760c156727dd7408f87e937af856d8bf1.tar.xz
initial [broken] update
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r--src/wallet/wallet_rpc_server.cpp49
1 files changed, 43 insertions, 6 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index a89cc4e72..f1766c3b4 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -11,6 +11,7 @@ using namespace epee;
#include "cryptonote_core/cryptonote_format_utils.h"
#include "cryptonote_core/account.h"
#include "misc_language.h"
+#include "string_tools.h"
#include "crypto/hash.h"
namespace tools
@@ -74,7 +75,7 @@ namespace tools
{
std::vector<cryptonote::tx_destination_entry> dsts;
- for (auto it = req.destinations.begin(); it != req.destinations.end(); it++)
+ for (auto it = req.destinations.begin(); it != req.destinations.end(); it++)
{
cryptonote::tx_destination_entry de;
if(!get_account_address_from_str(de.addr, it->address))
@@ -89,7 +90,7 @@ namespace tools
try
{
cryptonote::transaction tx;
- m_wallet.transfer(dsts, req.mixin, req.unlock_time, req.fee, tx);
+ m_wallet.transfer(dsts, req.mixin, req.unlock_time, req.fee, std::vector<uint8_t>(), tx);
res.tx_hash = boost::lexical_cast<std::string>(cryptonote::get_transaction_hash(tx));
return true;
}
@@ -97,19 +98,19 @@ namespace tools
{
er.code = WALLET_RPC_ERROR_CODE_DAEMON_IS_BUSY;
er.message = e.what();
- return false;
+ return false;
}
catch (const std::exception& e)
{
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
er.message = e.what();
- return false;
+ return false;
}
catch (...)
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
- return false;
+ return false;
}
return true;
}
@@ -129,4 +130,40 @@ namespace tools
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
-} \ No newline at end of file
+ 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, connection_context& cntx)
+ {
+ crypto::hash payment_id;
+ cryptonote::blobdata payment_id_blob;
+ if(!epee::string_tools::parse_hexstr_to_binbuff(req.payment_id, payment_id_blob))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
+ er.message = "Payment ID has invald format";
+ 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";
+ return false;
+ }
+
+ payment_id = *reinterpret_cast<const crypto::hash*>(payment_id_blob.data());
+
+ res.payments.clear();
+ std::list<wallet2::payment_details> payment_list;
+ m_wallet.get_payments(payment_id, payment_list);
+ for (auto payment : payment_list)
+ {
+ wallet_rpc::payment_details rpc_payment;
+ 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(rpc_payment);
+ }
+
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
+}