From caf8a0a96225697bd3ef59ea467254d1c9f2ebb3 Mon Sep 17 00:00:00 2001 From: auruya Date: Thu, 4 Sep 2025 22:43:16 +0300 Subject: [PATCH] fix-prevalidate-protocol-tx-for-carrot (#57) --- src/cryptonote_core/blockchain.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index d16950de2..f538e1abc 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1403,16 +1403,15 @@ bool Blockchain::prevalidate_protocol_transaction(const block& b, uint64_t heigh CHECK_AND_ASSERT_MES(b.protocol_tx.vin[0].type() == typeid(txin_gen), false, "coinbase protocol transaction in the block has the wrong type"); CHECK_AND_ASSERT_MES(b.protocol_tx.version > 1, false, "Invalid coinbase protocol transaction version"); - if (hf_version >= HF_VERSION_CARROT) { - CHECK_AND_ASSERT_MES(b.protocol_tx.version == TRANSACTION_VERSION_CARROT || 2, false, "protocol transaction has wrong version"); - CHECK_AND_ASSERT_MES(b.protocol_tx.type == cryptonote::transaction_type::PROTOCOL, false, "protocol transaction has wrong type"); - } - if (hf_version >= HF_VERSION_ENFORCE_CARROT) { CHECK_AND_ASSERT_MES(b.protocol_tx.version == TRANSACTION_VERSION_CARROT, false, "protocol transaction has wrong version"); CHECK_AND_ASSERT_MES(b.protocol_tx.type == cryptonote::transaction_type::PROTOCOL, false, "protocol transaction has wrong type"); + } else if (hf_version >= HF_VERSION_CARROT) { + CHECK_AND_ASSERT_MES(b.protocol_tx.version == 2 || b.protocol_tx.version == TRANSACTION_VERSION_CARROT, false, "protocol transaction has wrong version"); + CHECK_AND_ASSERT_MES(b.protocol_tx.type == cryptonote::transaction_type::PROTOCOL, false, "protocol transaction has wrong type"); } + // for v2 txes (ringct), we only accept empty rct signatures for protocol transactions, if (hf_version >= HF_VERSION_REJECT_SIGS_IN_COINBASE && b.protocol_tx.version >= 2) {