aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-25 22:11:21 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-25 22:11:21 +0000
commitf294be35bce2fff97d85a657347871685990f792 (patch)
treed3ae74e858a2e2f74b8ce1910ed2a7da98143aa7
parentblockchain: make some flag twiddling code closer to the original (diff)
downloadmonero-f294be35bce2fff97d85a657347871685990f792.tar.xz
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.
-rw-r--r--src/cryptonote_core/blockchain.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 86efc8821..e3ce66073 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);