From 9b4962f0dee7f5994aa810089c9eeaaae668454f Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Fri, 13 Mar 2026 16:53:13 -0400 Subject: [PATCH 1/4] qa: add newline at EOF when generating BIP 54 test vectors --- src/test/bip54_tests.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/bip54_tests.cpp b/src/test/bip54_tests.cpp index 2cc103444ca0..b2d0f7635220 100644 --- a/src/test/bip54_tests.cpp +++ b/src/test/bip54_tests.cpp @@ -53,7 +53,8 @@ static void WriteJSONTestVectors(const std::vector& test_vectors, std::string for (const auto& test_vector: test_vectors) { json_vectors.push_back(test_vector.GetJson()); } - const auto json_str{json_vectors.write(4)}; + auto json_str{json_vectors.write(4)}; + json_str += '\n'; FILE* file = fsbridge::fopen(filename, "w"); fputs(json_str.c_str(), file); fclose(file); From f329627943a6dbc4e031f66a42de02bd142dc1da Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Fri, 13 Mar 2026 16:53:55 -0400 Subject: [PATCH 2/4] qa: correct typos in BIP 54 test vectors --- src/test/bip54_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/bip54_tests.cpp b/src/test/bip54_tests.cpp index b2d0f7635220..d62c839bf65e 100644 --- a/src/test/bip54_tests.cpp +++ b/src/test/bip54_tests.cpp @@ -861,7 +861,7 @@ BOOST_AUTO_TEST_CASE(bip54_legacy_sigops) tx_copy2.vin[idx].scriptSig << OP_0 << sig << ToByteVector(redeem_script); BOOST_REQUIRE(VerifyTxin(spk, tx_copy2, idx)); - CheckExceedsBIP54Limits(CTransaction(tx_copy2), coins, test_vectors, "Mixed input types reaching exactly 2500 BIP54-sigops + a P2SH input with 1-of-1 CHECMULTISIG"); + CheckExceedsBIP54Limits(CTransaction(tx_copy2), coins, test_vectors, "Mixed input types reaching exactly 2500 BIP54-sigops + a P2SH input with 1-of-1 CHECKMULTISIG"); } // Adding an input spending an invalid Script but containing a CHECKSIG will @@ -1250,7 +1250,7 @@ BOOST_AUTO_TEST_CASE(bip54_legacy_sigops) tx2.vin.emplace_back(tx_create.GetHash(), 0); // CheckSigopsBIP54 will return false because there is 126 CMS that account for 20 each. - CheckExceedsBIP54Limits(CTransaction(tx2), coins, test_vectors, "Invalid bare script with 126 CHECMULTISIGs each accounted for 20 BIP54-sigops"); + CheckExceedsBIP54Limits(CTransaction(tx2), coins, test_vectors, "Invalid bare script with 126 CHECKMULTISIGs each accounted for 20 BIP54-sigops"); } // Note this is also a limitation for legitimate Scripts, for instance if the arguments to From 27957d2442a1e8ed07a8de4a8bb3dc9576709706 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Fri, 13 Mar 2026 17:15:11 -0400 Subject: [PATCH 3/4] qa: add a Taproot-annex case to BIP 54 txsize test vectors It was requested by ariard during review. --- src/test/bip54_tests.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/bip54_tests.cpp b/src/test/bip54_tests.cpp index d62c839bf65e..bea3bb402afc 100644 --- a/src/test/bip54_tests.cpp +++ b/src/test/bip54_tests.cpp @@ -1561,6 +1561,18 @@ BOOST_AUTO_TEST_CASE(bip54_txsize) RecordTestCase(test_vectors, CTransaction{tx_copy}, /*valid=*/false, "A 64-byte Segwit transaction (1 p2tr input, 1 p2a output)."); } + // A semi-realistic 64-byte transaction: 1 Taproot input with an annex, 1 OP_RETURN output. + { + CMutableTransaction tx_copy{tx}; + tx_copy.vout.back().scriptPubKey << OP_RETURN << "ab01"_hex_v; + auto sig{"5a78b5a14a2527feb02c08b8124e74c3b9bcc1bd3dba1fbfa87f1c930f28a46fea2bf375105dfd835e212c9127aad4976c46ef86be02edbb681e6f38f9a9e06f01"_hex_v_u8}; + tx_copy.vin.back().scriptWitness.stack.emplace_back(std::move(sig)); + auto annex{"4242ffab2121"_hex_v_u8}; + tx_copy.vin.back().scriptWitness.stack.emplace_back(std::move(annex)); + Assert(GetSerializeSize(TX_NO_WITNESS(tx_copy)) == INVALID_TX_NONWITNESS_SIZE); + RecordTestCase(test_vectors, CTransaction{tx_copy}, /*valid=*/false, "A 64-byte Segwit transaction (1 p2tr input with annex, 1 OP_RETURN output)."); + } + // Historical 64-byte transactions. Taken from Chris Stewart's BIP53. constexpr std::string_view historical_txs_hex[]{ "0200000001deb98691723fa71260ffca6ea0a7bc0a63b0a8a366e1b585caad47fb269a2ce401000000030251b201000000010000000000000000016a00000000", From fc24db402ccf590581c1b26aa4013da3af016910 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Mon, 16 Mar 2026 10:12:52 -0400 Subject: [PATCH 4/4] qa: add newline at EOF in BIP 54 json test vectors --- src/test/data/bip54_coinbases.json | 3 ++- src/test/data/bip54_timestamps.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/data/bip54_coinbases.json b/src/test/data/bip54_coinbases.json index 5d4845e6a035..6510a5ae22b1 100644 --- a/src/test/data/bip54_coinbases.json +++ b/src/test/data/bip54_coinbases.json @@ -76,4 +76,5 @@ "valid": false, "comment": "Block at height 4 with coinbase's nLockTime set to block's nTime minus 1 and maximum non-final nSequence." } -] \ No newline at end of file +] + diff --git a/src/test/data/bip54_timestamps.json b/src/test/data/bip54_timestamps.json index aaf9bee5fc78..41e67d01f714 100644 --- a/src/test/data/bip54_timestamps.json +++ b/src/test/data/bip54_timestamps.json @@ -4130,4 +4130,5 @@ ] } ] -} \ No newline at end of file +} +