Skip to content

Commit bb66a11

Browse files
committed
Fix DoS vulnerability in mempool acceptance
Moves the IsStandard check to happen after the premature-witness check, so that adding a witness to a transaction can't prevent mempool acceptance. Note that this doesn't address the broader category of potential mempool DoS issues that affect transactions after segwit activation.
1 parent 91abb77 commit bb66a11

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,11 +1132,6 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
11321132
if (tx.IsCoinBase())
11331133
return state.DoS(100, false, REJECT_INVALID, "coinbase");
11341134

1135-
// Rather not work on nonstandard transactions (unless -testnet/-regtest)
1136-
string reason;
1137-
if (fRequireStandard && !IsStandardTx(tx, reason))
1138-
return state.DoS(0, false, REJECT_NONSTANDARD, reason);
1139-
11401135
// Don't relay version 2 transactions until CSV is active, and we can be
11411136
// sure that such transactions will be mined (unless we're on
11421137
// -testnet/-regtest).
@@ -1150,6 +1145,11 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
11501145
return state.DoS(0, false, REJECT_NONSTANDARD, "no-witness-yet", true);
11511146
}
11521147

1148+
// Rather not work on nonstandard transactions (unless -testnet/-regtest)
1149+
string reason;
1150+
if (fRequireStandard && !IsStandardTx(tx, reason))
1151+
return state.DoS(0, false, REJECT_NONSTANDARD, reason);
1152+
11531153
// Only accept nLockTime-using transactions that can be mined in the next
11541154
// block; we don't want our mempool filled up with transactions that can't
11551155
// be mined yet.

0 commit comments

Comments
 (0)