From d1dee205473140aca34180e5de8b9bbe17c2207d Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Mon, 17 Sep 2018 16:13:37 -0400 Subject: [PATCH 1/2] Fix crash bug with duplicate inputs within a transaction Introduced by #9049 --- src/validation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index 7795905c4..145862db7 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3032,7 +3032,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())); From 9bd08fd465c35f08f3aab3c713ce1d70ddc1c492 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Mon, 17 Sep 2018 16:15:02 -0400 Subject: [PATCH 2/2] [qa] backport: Test for duplicate inputs within a transaction --- test/functional/p2p_invalid_block.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/functional/p2p_invalid_block.py b/test/functional/p2p_invalid_block.py index edcade63c..7744526d9 100755 --- a/test/functional/p2p_invalid_block.py +++ b/test/functional/p2p_invalid_block.py @@ -95,7 +95,18 @@ class InvalidBlockRequestTest(ComparisonTestFramework): assert(block2_orig.vtx != block2.vtx) self.tip = block2.sha256 - yield TestInstance([[block2, RejectResult(16, b'bad-txns-duplicate')], [block2_orig, True]]) + yield TestInstance([[block2, RejectResult(16, b'bad-txns-duplicate')]]) + + # Check transactions for duplicate inputs + self.log.info("Test duplicate input block.") + + block2_dup = copy.deepcopy(block2_orig) + block2_dup.vtx[2].vin.append(block2_dup.vtx[2].vin[0]) + block2_dup.vtx[2].rehash() + block2_dup.hashMerkleRoot = block2_dup.calc_merkle_root() + block2_dup.rehash() + block2_dup.solve() + yield TestInstance([[block2_dup, RejectResult(16, b'bad-txns-inputs-duplicate')], [block2_orig, True]]) height += 1 '''