Skip to content

Commit 7884956

Browse files
committed
Merge #9511: Don't overwrite validation state with corruption check
116419e Don't overwrite validation state with corruption check (Alex Morcos)
2 parents eafba4e + 116419e commit 7884956

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/validation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -921,12 +921,13 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
921921
// SCRIPT_VERIFY_CLEANSTACK requires SCRIPT_VERIFY_WITNESS, so we
922922
// need to turn both off, and compare against just turning off CLEANSTACK
923923
// to see if the failure is specifically due to witness validation.
924-
if (!tx.HasWitness() && CheckInputs(tx, state, view, true, scriptVerifyFlags & ~(SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_CLEANSTACK), true, txdata) &&
925-
!CheckInputs(tx, state, view, true, scriptVerifyFlags & ~SCRIPT_VERIFY_CLEANSTACK, true, txdata)) {
924+
CValidationState stateDummy; // Want reported failures to be from first CheckInputs
925+
if (!tx.HasWitness() && CheckInputs(tx, stateDummy, view, true, scriptVerifyFlags & ~(SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_CLEANSTACK), true, txdata) &&
926+
!CheckInputs(tx, stateDummy, view, true, scriptVerifyFlags & ~SCRIPT_VERIFY_CLEANSTACK, true, txdata)) {
926927
// Only the witness is missing, so the transaction itself may be fine.
927928
state.SetCorruptionPossible();
928929
}
929-
return false;
930+
return false; // state filled in by CheckInputs
930931
}
931932

932933
// Check again against just the consensus-critical mandatory script

0 commit comments

Comments
 (0)