aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/rpc_command_executor.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-08-11 14:19:41 +0200
committerRiccardo Spagni <ric@spagni.net>2015-08-11 14:19:55 +0200
commit01e81205e07408da03340de9f2bd113e9801ca77 (patch)
tree1f636f1a59c16163b591a7555c988e10dabd31a7 /src/daemon/rpc_command_executor.cpp
parentMerge pull request #364 (diff)
parentblockchain_db: match tx addition semantics to original code (diff)
downloadmonero-01e81205e07408da03340de9f2bd113e9801ca77.tar.xz
Merge pull request #365
e63b854 blockchain_db: match tx addition semantics to original code (moneromooo-monero) 83bbea4 Add a is_key_image_spent daemon command and RPC call (moneromooo-monero) 35abef1 blockchain: remove dead code (moneromooo-monero)
Diffstat (limited to 'src/daemon/rpc_command_executor.cpp')
-rw-r--r--src/daemon/rpc_command_executor.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 2f3a6b4d5..62f254c76 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -520,6 +520,42 @@ bool t_rpc_command_executor::print_transaction(crypto::hash transaction_hash) {
return true;
}
+bool t_rpc_command_executor::is_key_image_spent(const crypto::key_image &ki) {
+ cryptonote::COMMAND_RPC_IS_KEY_IMAGE_SPENT::request req;
+ cryptonote::COMMAND_RPC_IS_KEY_IMAGE_SPENT::response res;
+
+ std::string fail_message = "Problem checkking key image";
+
+ req.key_images.push_back(epee::string_tools::pod_to_hex(ki));
+ if (m_is_rpc)
+ {
+ if (!m_rpc_client->rpc_request(req, res, "/is_key_image_spent", fail_message.c_str()))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if (!m_rpc_server->on_is_key_image_spent(req, res))
+ {
+ tools::fail_msg_writer() << fail_message.c_str();
+ return true;
+ }
+ }
+
+ if (1 == res.spent_status.size())
+ {
+ // first as hex
+ tools::success_msg_writer() << ki << ": " << (res.spent_status.front() ? "spent" : "unspent");
+ }
+ else
+ {
+ tools::fail_msg_writer() << "key image status could not be determined" << std::endl;
+ }
+
+ return true;
+}
+
bool t_rpc_command_executor::print_transaction_pool_long() {
cryptonote::COMMAND_RPC_GET_TRANSACTION_POOL::request req;
cryptonote::COMMAND_RPC_GET_TRANSACTION_POOL::response res;