From 8140a87decdd88cd6febd4384a6afa6decad9dac Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Fri, 22 Mar 2019 17:17:11 -0400 Subject: [PATCH] Reject unneeded pegin witness by policy --- src/validation.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/validation.cpp b/src/validation.cpp index 4412bdfc18..d164752bd5 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -668,6 +668,18 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool CCoinsViewMemPool viewMemPool(pcoinsTip.get(), pool); view.SetBackend(viewMemPool); + // Quickly check for peg-in witness data on non-peg-in inputs + for (size_t input_index = 0; input_index < tx.vin.size(); ++input_index) { + if (!tx.vin[input_index].m_is_pegin) { + // Check that the corresponding pegin witness is empty + // Note that the witness vector must be size 0 or len(vin) + if (!tx.witness.vtxinwit.empty() && + !tx.witness.vtxinwit[input_index].m_pegin_witness.IsNull()) { + return state.Invalid(false, REJECT_PEGIN, "extra-pegin-witness"); + } + } + } + // do all inputs exist? for (const CTxIn& txin : tx.vin) { // ELEMENTS: