Skip to content

BIP394: rawtr() Output Script Descriptors - #2251

Merged
murchandamus merged 1 commit into
bitcoin:masterfrom
jeanpablojp:rawtr-descriptor
Nov 6, 2026
Merged

murchandamus merged 1 commit into
bitcoin:masterfrom
jeanpablojp:rawtr-descriptor

Conversation

@jeanpablojp

@jeanpablojp jeanpablojp commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

This is a BIP draft for the rawtr() script expression, following the style of BIPs 381-387. Bitcoin Core has implemented it since 24.0 and it has never had a BIP; sipa noted that on #2050 in March.

While writing this I did some digging and found rawtr in more places than I expected. BIP 390 allows musig() inside it, and two of the BIP 390 test vectors are rawtr() descriptors, so a published BIP already points at an expression no BIP defines. Outside Core it's a gap people route around: rust-miniscript prints rawtr_not_supported_yet where a descriptor should be, and bdk-ffi's tests cite rawtr as BIP-386.

Mail list discussion: https://groups.google.com/g/bitcoindev/c/CCZN_qQ5C1s

@achow101

Copy link
Copy Markdown
Member

Concept ACK

@danielabrozzoni danielabrozzoni left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a very good read, thanks for submitting! It's coincise and easy to understand.
Looks good to me! Though I think someone who knows more about descriptors than I do should also take a look :)

EDIT: I just realized, you should change BIP380's Appendix B to point to this page.

Comment thread bip-rawtr.mediawiki Resolved
@jeanpablojp

Copy link
Copy Markdown
Contributor Author

@danielabrozzoni about the Appendix B, BIP 3 says only the editor assigns the number, and until then the BIP is referred to by name. I can add the row now pointing to bip-rawtr.mediawiki, or wait for the editor to assign the number in this PR and register it with the number. Which do you prefer?

@murchandamus murchandamus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your submission, this looks great already. I noticed that there was no Rationale section, yet. Please include one if you get any questions or comments about design decisions or related work, or you feel that content in that regard is missing.

Perhaps @achow101 could take a more thorough look at this, too.

Let’s call this BIP394. Please update the file name of your document, the corresponding preamble headers and add the README entry you were asking about with that number.

Comment thread bip-rawtr.mediawiki Resolved
@murchandamus murchandamus changed the title BIP Draft: rawtr() Output Script Descriptors BIP394: rawtr() Output Script Descriptors Sep 9, 2026
@jeanpablojp
jeanpablojp force-pushed the rawtr-descriptor branch 2 times, most recently from 01d7de1 to bf51f95 Compare September 14, 2026 13:36
@jeanpablojp

Copy link
Copy Markdown
Contributor Author

Thanks for the number, @murchandamus.

Renamed to bip-0394.mediawiki, Rationale added, preamble updated, the Type: Specification suggestion taken, and the README row added.

I also added the rawtr(KEY) row to BIP 380's Appendix B, which is what @danielabrozzoni asked for and what BIP 392 and BIP 393 did in their own PRs.

@fametrano fametrano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recomputed every vector in the Test Vectors section with btclib's descriptor parser, and the single-key ranged ones a second time with plain BIP32 derivation and no descriptor code; all match. One normative sentence has no vector behind it: "compressed public keys would be implicitly converted to x-only public keys". The WIF vector covers it only indirectly, and nothing shows that the 02 and 03 forms of the same x give the same script. Core also rejects a 32-byte key whose x is not on the curve, which "must only create x-only public keys" does not make obvious. The two suggestions below, checked the same way, close both gaps in the format the section already uses.

Comment thread bip-0394.mediawiki Resolved
Comment thread bip-0394.mediawiki Resolved

@fametrano fametrano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

At a37df7c, I ran every test vector through Bitcoin Core 31.1 and 32.1, and through the descriptor parser of btclib-wallet, which I maintain, on its pure-Python arithmetic. Every run reproduces the scripts of all 9 valid descriptors, both multipath branches included, and rejects all 9 invalid ones. The compressed-key and off-curve vectors added since my last review close the two gaps it pointed out. Scripts and output: https://gist.github.com/fametrano/8ecee0a1ee1e15de1443fd6d6d0db9de/68601ac59d1db6579e13387f680c2f0e740313a6

@murchandamus murchandamus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK a37df7c

I would have liked more review, but this looks good to me. Intend to merge next week, unless further development indicate that we should delay.

@achow101 achow101 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

Comment thread bip-0394.mediawiki Outdated
</pre>

Key expressions within a <tt>rawtr()</tt> expression must only create x-only public keys, as in <tt>tr()</tt> expressions.
Uncompressed public keys are not allowed, but compressed public keys would be implicitly converted to x-only public keys.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The end of this sentence reads weirdly to me, I think it's missing a verb.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t see where a verb is missing, but the two statements do seem a bit disjoint. It might be a bit clearer as:

Suggested change
Uncompressed public keys are not allowed, but compressed public keys would be implicitly converted to x-only public keys.
Uncompressed public keys are not allowed. Compressed public keys are allowed, but will be implicitly converted to x-only public keys.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took murch's suggestion, thanks. Reads clearer to me too.

@murchandamus murchandamus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK bc8b68c

@murchandamus
murchandamus merged commit 55916fd into bitcoin:master Nov 6, 2026
4 checks passed
jonatack added a commit to jonatack/bips that referenced this pull request Nov 23, 2026
rawtr() has been deployed in Bitcoin Core since v24.0 (#23480), is
referenced by BIP 390's test vectors, and has an independent verified
implementation in btclib-wallet (tested across all 18 vectors in bitcoin#2251).
fanquake added a commit to bitcoin/bitcoin that referenced this pull request Nov 27, 2026
5301fdb doc: add 389 (multipath) and 394 (rawtr) to bips.md (jeanpablo)

Pull request description:

  BIP 394 (`rawtr()`) was merged in bitcoin/bips#2251. `rawtr()` has been implemented since v24.0 (#23480), and BIP 389 (multipath) since v29.0 (#22838).

  In `descriptors.md`, `rawtr()` was the only `SCRIPT` expression without a BIP reference, so its line now references 394. BIP 389 was already referenced there.

ACKs for top commit:
  jonatack:
    ACK 5301fdb

Tree-SHA512: 02bc87ff879b74813056d63543ae36648986aab36c45ace779bea20460d564dc4b2985c35220366c0efb5b30b26dea119d7bf130bf071abdc1f88488ec3f98b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants