Skip to content

Commit 8140a87

Browse files
committed
Reject unneeded pegin witness by policy
1 parent 97356e8 commit 8140a87

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/validation.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,18 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
668668
CCoinsViewMemPool viewMemPool(pcoinsTip.get(), pool);
669669
view.SetBackend(viewMemPool);
670670

671+
// Quickly check for peg-in witness data on non-peg-in inputs
672+
for (size_t input_index = 0; input_index < tx.vin.size(); ++input_index) {
673+
if (!tx.vin[input_index].m_is_pegin) {
674+
// Check that the corresponding pegin witness is empty
675+
// Note that the witness vector must be size 0 or len(vin)
676+
if (!tx.witness.vtxinwit.empty() &&
677+
!tx.witness.vtxinwit[input_index].m_pegin_witness.IsNull()) {
678+
return state.Invalid(false, REJECT_PEGIN, "extra-pegin-witness");
679+
}
680+
}
681+
}
682+
671683
// do all inputs exist?
672684
for (const CTxIn& txin : tx.vin) {
673685
// ELEMENTS:

0 commit comments

Comments
 (0)