Skip to content

Commit c64128d

Browse files
committed
Merge #14248: [0.17] Fix crash bug with duplicate inputs within a transaction
0d49c82 [qa] backport: Test for duplicate inputs within a transaction (Suhas Daftuar) 833180f Fix crash bug with duplicate inputs within a transaction (Suhas Daftuar) Pull request description: This is a backport of #14247. Tree-SHA512: 4d3b6244d501a48f56a728c571dac9a346019a671434edac943f4f535ef8f94ec6bfd569a0585ad5e23a6e488ecd7e0079510cbb10a2a22f576eb36d73accb0c
2 parents 465a583 + 0d49c82 commit c64128d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3130,7 +3130,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
31303130

31313131
// Check transactions
31323132
for (const auto& tx : block.vtx)
3133-
if (!CheckTransaction(*tx, state, false))
3133+
if (!CheckTransaction(*tx, state, true))
31343134
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(),
31353135
strprintf("Transaction check failed (tx hash %s) %s", tx->GetHash().ToString(), state.GetDebugMessage()));
31363136

test/functional/p2p_invalid_block.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ def run_test(self):
8181

8282
node.p2p.send_blocks_and_test([block2], node, False, False, 16, b'bad-txns-duplicate')
8383

84+
# Check transactions for duplicate inputs
85+
self.log.info("Test duplicate input block.")
86+
87+
block2_orig.vtx[2].vin.append(block2_orig.vtx[2].vin[0])
88+
block2_orig.vtx[2].rehash()
89+
block2_orig.hashMerkleRoot = block2_orig.calc_merkle_root()
90+
block2_orig.rehash()
91+
block2_orig.solve()
92+
node.p2p.send_blocks_and_test([block2_orig], node, success=False, request_block=False, reject_reason=b'bad-txns-inputs-duplicate')
93+
8494
self.log.info("Test very broken block.")
8595

8696
block3 = create_block(tip, create_coinbase(height), block_time)

0 commit comments

Comments
 (0)