diff --git a/src/test/util/mining.cpp b/src/test/util/mining.cpp index da15e6789a2..05f1be77ee2 100644 --- a/src/test/util/mining.cpp +++ b/src/test/util/mining.cpp @@ -49,6 +49,7 @@ std::vector> CreateBlockChain(size_t total_height, const coinbase_tx.vout.resize(1); coinbase_tx.vout[0].scriptPubKey = P2WSH_OP_TRUE; coinbase_tx.vout[0].nValue = GetBlockSubsidy(height + 1, params.GetConsensus()); + // Always include OP_0 as a dummy extraNonce. coinbase_tx.vin[0].scriptSig = CScript() << (height + 1) << OP_0; block.vtx = {MakeTransactionRef(std::move(coinbase_tx))}; diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index 2303fd4cc76..dfa66bb8899 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -82,7 +82,7 @@ std::shared_ptr MinerTestingSetup::Block(const uint256& prev_hash) txCoinbase.vout[1].nValue = txCoinbase.vout[0].nValue; txCoinbase.vout[0].nValue = 0; txCoinbase.vin[0].scriptWitness.SetNull(); - // Always pad with OP_0 at the end to avoid bad-cb-length error + // Always pad with OP_0 as dummy extraNonce (also avoids bad-cb-length error for block <=16) const int prev_height{WITH_LOCK(::cs_main, return m_node.chainman->m_blockman.LookupBlockIndex(prev_hash)->nHeight)}; txCoinbase.vin[0].scriptSig = CScript{} << prev_height + 1 << OP_0; txCoinbase.nLockTime = static_cast(prev_height); diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index 8ad8ea8a521..e1453e3a99b 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -164,7 +164,7 @@ def add_witness_commitment(block, nonce=0): def script_BIP34_coinbase_height(height): if height <= 16: res = CScriptOp.encode_op_n(height) - # Append dummy to increase scriptSig size to 2 (see bad-cb-length consensus rule) + # Append dummy extraNonce to increase scriptSig size to 2 (see bad-cb-length consensus rule) return CScript([res, OP_0]) return CScript([CScriptNum(height)])