Skip to content

Commit

Permalink
Merge bitcoin#14248: [0.17] Fix crash bug with duplicate inputs withi…
Browse files Browse the repository at this point in the history
…n 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 bitcoin#14247.

Tree-SHA512: 4d3b6244d501a48f56a728c571dac9a346019a671434edac943f4f535ef8f94ec6bfd569a0585ad5e23a6e488ecd7e0079510cbb10a2a22f576eb36d73accb0c
  • Loading branch information
laanwj committed Sep 17, 2018
2 parents 465a583 + 0d49c82 commit c64128d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3130,7 +3130,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P

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

Expand Down
10 changes: 10 additions & 0 deletions test/functional/p2p_invalid_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ def run_test(self):

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

# Check transactions for duplicate inputs
self.log.info("Test duplicate input block.")

block2_orig.vtx[2].vin.append(block2_orig.vtx[2].vin[0])
block2_orig.vtx[2].rehash()
block2_orig.hashMerkleRoot = block2_orig.calc_merkle_root()
block2_orig.rehash()
block2_orig.solve()
node.p2p.send_blocks_and_test([block2_orig], node, success=False, request_block=False, reject_reason=b'bad-txns-inputs-duplicate')

self.log.info("Test very broken block.")

block3 = create_block(tip, create_coinbase(height), block_time)
Expand Down

0 comments on commit c64128d

Please sign in to comment.