Skip to content

Commit 7bf98b6

Browse files
committed
mempool: add validation for witness standard check
Add missing witness standard validation in mempool See https://github.com/bitcoin/bitcoin/blob/89c7b6b97ab409d06b435d8b4f36e5e4be36908d/src/validation.cpp#L887
1 parent 53984d0 commit 7bf98b6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

mempool/mempool.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,22 @@ func (mp *TxPool) validateStandardness(tx *btcutil.Tx, nextBlockHeight int32,
16391639
return txRuleError(rejectCode, str)
16401640
}
16411641

1642+
// Check the witness standard.
1643+
err = checkWitnessStandard(tx, utxoView)
1644+
if err != nil {
1645+
// Attempt to extract a reject code from the error so it can be
1646+
// retained. When not possible, fall back to a non-standard
1647+
// error.
1648+
rejectCode, found := extractRejectCode(err)
1649+
if !found {
1650+
rejectCode = wire.RejectNonstandard
1651+
}
1652+
str := fmt.Sprintf("transaction %v has a non-standard "+
1653+
"witness: %v", tx.Hash(), err)
1654+
1655+
return txRuleError(rejectCode, str)
1656+
}
1657+
16421658
return nil
16431659
}
16441660

0 commit comments

Comments
 (0)