aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
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/rpc
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/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp29
-rw-r--r--src/rpc/core_rpc_server.h2
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h25
3 files changed, 56 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();
diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h
index 6152dea03..3213e6b1c 100644
--- a/src/rpc/core_rpc_server.h
+++ b/src/rpc/core_rpc_server.h
@@ -77,6 +77,7 @@ namespace cryptonote
MAP_URI_AUTO_BIN2("/get_o_indexes.bin", on_get_indexes, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES)
MAP_URI_AUTO_BIN2("/getrandom_outs.bin", on_get_random_outs, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS)
MAP_URI_AUTO_JON2("/gettransactions", on_get_transactions, COMMAND_RPC_GET_TRANSACTIONS)
+ MAP_URI_AUTO_JON2("/is_key_image_spent", on_is_key_image_spent, COMMAND_RPC_IS_KEY_IMAGE_SPENT)
MAP_URI_AUTO_JON2("/sendrawtransaction", on_send_raw_tx, COMMAND_RPC_SEND_RAW_TX)
MAP_URI_AUTO_JON2("/start_mining", on_start_mining, COMMAND_RPC_START_MINING)
MAP_URI_AUTO_JON2("/stop_mining", on_stop_mining, COMMAND_RPC_STOP_MINING)
@@ -108,6 +109,7 @@ namespace cryptonote
bool on_get_height(const COMMAND_RPC_GET_HEIGHT::request& req, COMMAND_RPC_GET_HEIGHT::response& res);
bool on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res);
bool on_get_transactions(const COMMAND_RPC_GET_TRANSACTIONS::request& req, COMMAND_RPC_GET_TRANSACTIONS::response& res);
+ bool on_is_key_image_spent(const COMMAND_RPC_IS_KEY_IMAGE_SPENT::request& req, COMMAND_RPC_IS_KEY_IMAGE_SPENT::response& res);
bool on_get_indexes(const COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::request& req, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::response& res);
bool on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res);
bool on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res);
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index b6a2edd0b..beb7b81e6 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -117,6 +117,31 @@ namespace cryptonote
};
//-----------------------------------------------
+ struct COMMAND_RPC_IS_KEY_IMAGE_SPENT
+ {
+ struct request
+ {
+ std::vector<std::string> key_images;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(key_images)
+ END_KV_SERIALIZE_MAP()
+ };
+
+
+ struct response
+ {
+ std::vector<bool> spent_status;
+ std::string status;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(spent_status)
+ KV_SERIALIZE(status)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
+
+ //-----------------------------------------------
struct COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES
{
struct request