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

witness: rewrite the docs on several Taproot-related methods and deprecate a method

Public commit record

What the developer wrote

Authored by Andrew Poelstra

85/100 · Strong
witness: rewrite the docs on several Taproot-related methods and deprecate a method

There are multiple issues with these docs:

* They repeatedly say "according to the rules of BIP XYZ". Duh. We should
document when we're *not* following the rules.
* In the Taproot methods, we then say that we're just looking for 0x50 bytes
but not really parsing stuff, which is untrue because we do parse the
witness stack...
* ...and we say that the user should call Script::is_p2tr to see if the
output is really Taproot, which is untrue according to BIP 341...
* ...and we don't even explain that the user needs to call is_p2tr on the
*output script* and not the script being returned from this function.

Furthermore, we have two methods `tapscript` and `taproot_leaf_script`.
We say that the latter "does not return the control block". Neither one
returns the control block. We don't say how these methods are different
(or, for that matter, where to get the control block).

Also inside `tapscript` we have some assinine comment from Kix about how
the method is "broken" because of some distinction between "leaf script"
and "tapscript" that exists only in his head. We don't expose this to
our users. We shouldn't expose it to ourselves either. Clarify what (I
think) he means and promote it to a deprecation notice.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This commit is a documentation and deprecation cleanup for Taproot-related witness methods in the rust-bitcoin library. It rewrites misleading doc comments, deprecates the `tapscript` method in favor of `taproot_leaf_script`, and clarifies that callers should validate the output script (not the returned script) when checking for Taproot or Segwit v0 spends. There is no code behavior change beyond adding a Rust deprecation attribute.

Recommended action

No urgent security action. Library users should migrate from `tapscript` to `taproot_leaf_script` to obtain the leaf version and avoid future compatibility issues. Reviewers may verify that the deprecation attribute compiles cleanly and that downstream code is updated before the method is removed in a future release.

Security signals we found

01

Deprecation of API that omits leaf version, which could lead to subtly broken assumptions if a new Tapscript version is deployed

02

Documentation correction clarifying that output-script validation (not returned-script validation) is required for type checking

03

No logic change; no memory safety, cryptographic, or consensus bug introduced or fixed

Risk score

Why this scored 19/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 1/15
Affected reach 3/15
Confidence 8/10
Evidence quality 4/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.