aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-01-05 21:57:43 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-01-05 22:16:24 +0000
commita44d94d390158a04db9bfd84bacd5ca1d7233ba0 (patch)
treea7d619810f867a637f527647c422c9004f152af1 /src/rpc
parentMerge branch 'LMDB-tweaks' (diff)
downloadmonero-a44d94d390158a04db9bfd84bacd5ca1d7233ba0.tar.xz
rpc: is_key_image_spent now checks the tx pool too
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp32
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h6
2 files changed, 37 insertions, 1 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index e6973b0b8..021c12d6e 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -304,7 +304,37 @@ namespace cryptonote
}
res.spent_status.clear();
for (size_t n = 0; n < spent_status.size(); ++n)
- res.spent_status.push_back(spent_status[n]);
+ res.spent_status.push_back(spent_status[n] ? COMMAND_RPC_IS_KEY_IMAGE_SPENT::SPENT_IN_BLOCKCHAIN : COMMAND_RPC_IS_KEY_IMAGE_SPENT::UNSPENT);
+
+ // check the pool too
+ std::vector<cryptonote::tx_info> txs;
+ std::vector<cryptonote::spent_key_image_info> ki;
+ r = m_core.get_pool_transactions_and_spent_keys_info(txs, ki);
+ if(!r)
+ {
+ res.status = "Failed";
+ return true;
+ }
+ for (std::vector<cryptonote::spent_key_image_info>::const_iterator i = ki.begin(); i != ki.end(); ++i)
+ {
+ crypto::hash hash;
+ crypto::key_image spent_key_image;
+ if (parse_hash256(i->id_hash, hash))
+ {
+ memcpy(&spent_key_image, &hash, sizeof(hash)); // a bit dodgy, should be other parse functions somewhere
+ for (size_t n = 0; n < res.spent_status.size(); ++n)
+ {
+ if (res.spent_status[n] == COMMAND_RPC_IS_KEY_IMAGE_SPENT::UNSPENT)
+ {
+ if (key_images[n] == spent_key_image)
+ {
+ res.spent_status[n] = COMMAND_RPC_IS_KEY_IMAGE_SPENT::SPENT_IN_POOL;
+ break;
+ }
+ }
+ }
+ }
+ }
res.status = CORE_RPC_STATUS_OK;
return true;
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index 209378e5a..dcacffbb9 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -123,6 +123,12 @@ namespace cryptonote
//-----------------------------------------------
struct COMMAND_RPC_IS_KEY_IMAGE_SPENT
{
+ enum STATUS {
+ UNSPENT = 0,
+ SPENT_IN_BLOCKCHAIN = 1,
+ SPENT_IN_POOL = 2,
+ };
+
struct request
{
std::vector<std::string> key_images;