BIP394: rawtr() Output Script Descriptors #2251

pull jeanpablojp wants to merge 1 commits into bitcoin:master from jeanpablojp:rawtr-descriptor changing 3 files +130 −0
  1. jeanpablojp commented at 11:10 AM on August 12, 2026: 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

  2. jonatack added the label New BIP on Aug 12, 2026
  3. achow101 commented at 10:55 PM on August 12, 2026: member

    Concept ACK

  4. danielabrozzoni commented at 7:00 PM on August 13, 2026: member

    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.

  5. in bip-rawtr.mediawiki:7 in 54fea1a294
       0 | @@ -0,0 +1,104 @@
       1 | +<pre>
       2 | +  BIP: ?
       3 | +  Layer: Applications
       4 | +  Title: rawtr() Output Script Descriptors
       5 | +  Authors: Jean Moreira <jeanpablo.jp@hotmail.com>
       6 | +  Status: Draft
       7 | +  Type: Specification
    


    danielabrozzoni commented at 5:43 PM on August 14, 2026:

    I think the type should be "Informational", similarly to other descriptor BIPs:

    BIP Description Type
    380 Output Script Descriptors (general) Informational
    381 pk(), pkh(), multi() etc. Informational
    382 wpkh(), wsh() Informational
    383 sh() Informational
    384 combo() Informational
    385 raw(), addr() Informational
    386 tr() Informational
    387 multi_a(), sortedmulti_a() Informational
    389 Multipath descriptors Informational
    390 musig() (used inside rawtr()) Informational

    jeanpablojp commented at 8:46 PM on August 14, 2026:

    You are right, I just pushed the change. Thanks.


    murchandamus commented at 6:19 PM on September 9, 2026:

    Actually, I think all of these should be Specification BIPs. The criteria for BIP types were amended by BIP3 compared to BIP2, but we haven’t updated all of the affected BIPs, yet.


    danielabrozzoni commented at 1:36 PM on September 17, 2026:

    @murchandamus understood, thanks for pointing this out! I implemented the change of type in #2292 :)

  6. jeanpablojp force-pushed on Aug 14, 2026
  7. jeanpablojp commented at 3:10 PM on August 15, 2026: contributor

    @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?

  8. in bip-rawtr.mediawiki:7 in 4af973fc90
       0 | @@ -0,0 +1,104 @@
       1 | +<pre>
       2 | +  BIP: ?
       3 | +  Layer: Applications
       4 | +  Title: rawtr() Output Script Descriptors
       5 | +  Authors: jeanpablojp <me@jeanpablo.jp>
       6 | +  Status: Draft
       7 | +  Type: Informational
    


    murchandamus commented at 6:25 PM on September 9, 2026:

    Sorry for the back-and-forth on this, but this should please be a Specification BIP.

      Type: Specification
    
  9. murchandamus commented at 7:53 PM on September 9, 2026: member

    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.

  10. murchandamus renamed this:
    BIP Draft: rawtr() Output Script Descriptors
    BIP394: rawtr() Output Script Descriptors
    on Sep 9, 2026
  11. jeanpablojp force-pushed on Sep 14, 2026
  12. jeanpablojp force-pushed on Sep 14, 2026
  13. jeanpablojp commented at 1:53 PM on September 14, 2026: contributor

    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.

  14. murchandamus requested review from achow101 on Sep 23, 2026
  15. fametrano commented at 8:18 PM on October 3, 2026: contributor

    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.

  16. in bip-0394.mediawiki:69 in bf51f956d9 outdated
      64 | +Valid descriptors followed by the scripts they produce. Descriptors involving derived child keys will have the 0th, 1st, and 2nd scripts listed. These vectors were generated with Bitcoin Core's descriptor implementation. Note that the first vector uses the same key as the first <tt>tr()</tt> vector of [[bip-0386.mediawiki|BIP 386]]: with <tt>rawtr()</tt> the key appears in the script unchanged, while <tt>tr()</tt> tweaks it. The third vector takes the output key that the BIP 386 vector produced and reproduces its script.
      65 | +
      66 | +* <tt>rawtr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)</tt>
      67 | +** <tt>5120a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd</tt>
      68 | +* <tt>rawtr(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1)</tt>
      69 | +** <tt>5120a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd</tt>
    


    fametrano commented at 8:18 PM on October 3, 2026:
    ** <tt>5120a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd</tt>
    * <tt>rawtr(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)</tt>
    ** <tt>5120a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd</tt>
    * <tt>rawtr(02a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)</tt>
    ** <tt>5120a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd</tt>
    

    jeanpablojp commented at 9:34 PM on October 27, 2026:

    Thanks. Applied, with the two compressed keys after the third vector so the note above the list still points at the right one.

  17. in bip-0394.mediawiki:101 in bf51f956d9 outdated
      96 | +* Script expression instead of a key expression: <tt>rawtr(pk(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</tt>
      97 | +* More than one key: <tt>rawtr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,77aab6e066f8a7419c5ab714c12c67d25007ed55a43cadcacb4d7a970a093f11)</tt>
      98 | +* Tree expression, which <tt>rawtr()</tt> does not take: <tt>rawtr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,pk(77aab6e066f8a7419c5ab714c12c67d25007ed55a43cadcacb4d7a970a093f11))</tt>
      99 | +* Uncompressed private key: <tt>rawtr(5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss)</tt>
     100 | +* Uncompressed public key: <tt>rawtr(04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235)</tt>
     101 | +* No key: <tt>rawtr()</tt>
    


    fametrano commented at 8:18 PM on October 3, 2026:
    * No key: <tt>rawtr()</tt>
    * X-only key with no point on the curve: <tt>rawtr(0000000000000000000000000000000000000000000000000000000000000005)</tt>
    

    jeanpablojp commented at 9:33 PM on October 27, 2026:

    Thanks, applied.

  18. jeanpablojp force-pushed on Oct 27, 2026
  19. fametrano commented at 6:22 PM on November 1, 2026: contributor

    Concept ACK

    At a37df7cc79bc1d404db40294bbfb6ff1e02402be, 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

  20. murchandamus commented at 6:31 PM on November 5, 2026: member

    ACK a37df7cc79bc1d404db40294bbfb6ff1e02402be

    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.

  21. in bip-0394.mediawiki:44 in a37df7cc79
      39 | +<pre>
      40 | +OP_1 <KEY>
      41 | +</pre>
      42 | +
      43 | +Key expressions within a <tt>rawtr()</tt> expression must only create x-only public keys, as in <tt>tr()</tt> expressions.
      44 | +Uncompressed public keys are not allowed, but compressed public keys would be implicitly converted to x-only public keys.
    


    achow101 commented at 8:38 PM on November 5, 2026:

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


    murchandamus commented at 10:40 PM on November 5, 2026:

    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:

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

    jeanpablojp commented at 1:27 PM on November 6, 2026:

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

  22. achow101 commented at 8:40 PM on November 5, 2026: member

    ACK

  23. BIP394: rawtr() Output Script Descriptors bc8b68c9cf
  24. jeanpablojp force-pushed on Nov 6, 2026
  25. murchandamus commented at 7:57 PM on November 6, 2026: member

    ACK bc8b68c9cf60896bb981aa2d7030a5f2f3d32db8

  26. murchandamus merged this on Nov 6, 2026
  27. murchandamus closed this on Nov 6, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-22 17:10 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me