diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-08-11 10:49:15 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-08-11 10:52:41 +0100 |
commit | 83bbea4c7f47d05933ec1b5baca2e9724561e49c (patch) | |
tree | acc999b802091f32227e66e677ae483398fe1d93 /src/rpc/core_rpc_server.cpp | |
parent | blockchain: remove dead code (diff) | |
download | monero-83bbea4c7f47d05933ec1b5baca2e9724561e49c.tar.xz |
Add a is_key_image_spent daemon command and RPC call
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 24c7d242f..0c8384306 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -241,6 +241,35 @@ namespace cryptonote return true; } //------------------------------------------------------------------------------------------------------------------------------ + bool core_rpc_server::on_is_key_image_spent(const COMMAND_RPC_IS_KEY_IMAGE_SPENT::request& req, COMMAND_RPC_IS_KEY_IMAGE_SPENT::response& res) + { + CHECK_CORE_BUSY(); + std::vector<crypto::key_image> key_images; + BOOST_FOREACH(const auto& ki_hex_str, req.key_images) + { + blobdata b; + if(!string_tools::parse_hexstr_to_binbuff(ki_hex_str, b)) + { + res.status = "Failed to parse hex representation of key image"; + return true; + } + if(b.size() != sizeof(crypto::key_image)) + { + res.status = "Failed, size of data mismatch"; + } + key_images.push_back(*reinterpret_cast<const crypto::key_image*>(b.data())); + } + bool r = m_core.are_key_images_spent(key_images, res.spent_status); + if(!r) + { + res.status = "Failed"; + return true; + } + + res.status = CORE_RPC_STATUS_OK; + return true; + } + //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res) { CHECK_CORE_READY(); |