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

Merge rust-bitcoin/rust-bitcoin#7022: taproot-primitives: Add consensus validation tests for LeafVersion

Public commit record

What the developer wrote

Authored by Andrew Poelstra

91/100 · Strong
Merge rust-bitcoin/rust-bitcoin#7022: taproot-primitives: Add consensus validation tests for LeafVersion

a4eca1edbff5aabff13284a442fb5e81330e631a taproot-primitives: Add consensus validation tests for LeafVersion (Jaydbrown)

Pull request description:

This PR adds specific unit tests for `taproot_primitives` covering valid and invalid leaf versions:

- `leaf_version_future_valid`: Locks the rule that even, non-tapscript bytes (`0x00`, `0x02`, `0xc2`, `0xc4`, `0xfe`) round-trip through `from_consensus` and `to_consensus`. (The BIP tests in `bitcoin/tests/taproot.rs` only unwrap versions that already appear in vectors).
- `leaf_version_invalid_rejected`: Makes sure `0x50` (annex prefix) returns an error as it is not a valid leaf. Verifies odd bytes (`0x01`, `0x03`, `0x51`, `0xc1`, `0xc3`, `0xff`) are invalid bytes and fail as per BIP-341/BIP-342. This test verifies invalid leaf versions are rejected.
- `serde_leaf_version`: Exercises deserialization round-trip for `0xc2` and rejection of invalid values (`80`, `193`, and `256`) using `IntoDeserializer` behind the existing `serde` feature, requiring no extra dependencies or lockfile changes.


ACKs for top commit:
apoelstra:
ACK a4eca1edbff5aabff13284a442fb5e81330e631a; successfully ran local tests


Tree-SHA512: 0e1911df5b5ab15e6b52d409277fd1d18e681200832281f58c67eff39870a92e1dfe37ade6a5bf9ca45f1427d7385e89f3c4984a42aed07a4e0e7e5c927eafb8
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit only adds new unit tests for an existing Bitcoin Taproot leaf-version validation function. It does not change any production code, fix a bug, or alter behavior. There is no security issue in the commit itself.

Recommended action

No action needed; this is a test-only addition. Review the existing LeafVersion::from_consensus implementation separately if desired, but this commit does not introduce or fix a vulnerability.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 15/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 10/10
Evidence quality 5/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.