diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 5cab6b2eb..dc64b25e2 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -3499,12 +3499,10 @@ bool Blockchain::have_tx_keyimges_as_spent(const transaction &tx) const LOG_PRINT_L3("Blockchain::" << __func__); for (const txin_v& in: tx.vin) { - if (in.type() != typeid(txin_to_key)) - continue; - const auto &tokey_in = boost::get(in); - if(have_tx_keyimg_as_spent(tokey_in.k_image)) + CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, in_to_key, true); + 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(tokey_in.k_image)); + LOG_PRINT_L1("Key image already spent in blockchain: " << epee::string_tools::pod_to_hex(in_to_key)); return true; } } diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index a01ca5409..e233a1b64 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -234,6 +234,26 @@ namespace cryptonote return false; } + if (!check_inputs_types_supported(tx)) + { + // TODO: do more cheap semantics checks earlier. This is here so the have_tx_keyimges_as_spent below can only fail when expected. + MERROR("Unsupported input types for tx id= " << id); + tvc.m_verifivation_failed = true; + tvc.m_invalid_input = true; + return false; + } + + if (version && version > HF_VERSION_FCMP_PLUS_PLUS) + { + // TODO: do more cheap semantics checks earlier. This is here to protect overloading have_tx_keyimges_as_spent with many DB reads. + if (tx.vin.empty() || tx.vin.size() > FCMP_PLUS_PLUS_MAX_INPUTS) + { + tvc.m_verifivation_failed = true; + tvc.m_invalid_input = true; + return false; + } + } + // if the transaction came from a block popped from the chain, // don't check if we have its key images as spent. // TODO: Investigate why not?