AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 27 Bitcoin

DecomposePeginWitness: fix deserialization flags for MerkleBlock proof

Public commit record

What the developer wrote

Authored by Byron Hambly

95/100 · Strong
DecomposePeginWitness: fix deserialization flags for MerkleBlock proof

In CreatePeginWitnessInner, the MerkleBlock is always serialized without
witness: PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS

In DecomposePeginWitness before this change, the MerkleBlock was
deserialized with witness: PROTOCOL_VERSION

This was only noticed as an issue in the pegin subsidy implementation,
in a failure in the feature_dynafed functional test. In the
test_transition_mempool_eject test case, the Merkle block proof is coming
from the same chain where we are creating a pegin.

See the comment: "hack: since we're not validating peg-ins in parent chain,
just make both the funding and claim tx on same chain (printing money)"

I haven't investigated enough to explain why this causes a
deserialization failure in this specific case, but presumably this change
is correct since we're always serializing without witness. Before this
DecomposePeginWitness was only used in src/psbt.cpp
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a mismatch in how a Merkle block proof is unpacked inside a 'pegin' (a transaction that moves coins from a parent blockchain into this Elements sidechain). The proof was being read as if it might contain witness data, but it is always written without witness data. This mismatch could cause the proof to fail to decode in some situations, which could break peg-in validation or processing.

Recommended action

Apply the one-line patch to ensure MerkleBlock proofs are deserialized with SERIALIZE_TRANSACTION_NO_WITNESS, matching the serialization flags used in CreatePeginWitnessInner. Run the feature_dynafed functional tests to confirm the fix.

Security signals we found

01

Serialization/deserialization flag mismatch

02

Witness-data format mismatch in MerkleBlock proof

03

Peg-in witness decomposition failure

04

Functional test failure observed in feature_dynafed

Risk score

Why this scored 27/100

Our methodology →
Potential impact 6/30
Exploitability 3/25
Stealth signal 4/15
Affected reach 5/15
Confidence 6/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.