mirror of
https://github.com/monero-project/monero.git
synced 2026-01-01 07:26:15 -08:00
rpc: is_key_image_spent now checks the tx pool too
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user