From f294be35bce2fff97d85a657347871685990f792 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 25 Dec 2015 22:11:21 +0000 Subject: [PATCH] blockchain: reinstate double spending checks in check_tx_inputs This fixes some double spending tests. This may or may not be unneeded in normal (non test) circumstances, to be determined later. Keeping these for now may be slower, but safer. --- src/cryptonote_core/blockchain.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 86efc882..e3ce6607 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2008,9 +2008,7 @@ bool Blockchain::have_tx_keyimges_as_spent(const transaction &tx) const return false; } //------------------------------------------------------------------ -// This function validates transaction inputs and their keys. Previously -// it also performed double spend checking, but that has been moved to its -// own function. +// This function validates transaction inputs and their keys. bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_block_height) { LOG_PRINT_L3("Blockchain::" << __func__); @@ -2112,6 +2110,12 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc // make sure tx output has key offset(s) (is signed to be used) CHECK_AND_ASSERT_MES(in_to_key.key_offsets.size(), false, "empty in_to_key.key_offsets in transaction with id " << get_transaction_hash(tx)); + if(have_tx_keyimg_as_spent(in_to_key.k_image)) + { + LOG_PRINT_L1("Key image already spent in blockchain: " << epee::string_tools::pod_to_hex(in_to_key.k_image)); + return false; + } + // basically, make sure number of inputs == number of signatures CHECK_AND_ASSERT_MES(sig_index < tx.signatures.size(), false, "wrong transaction: not signature entry for input with index= " << sig_index);