<p>If you want a Merkle tree with script paths <code>S1</code> and <code>S2</code> on the second level of the Merkle tree and script path <code>S3</code> on the first level of the Merkle tree the descriptor notation is:</p>
<p><code>tr(KEY,{{S1,S2},S3})</code></p>
<p>where <code>KEY</code> can be any key expression including public key, x-only public key, WIF private key, xpub, xprv or xpub/xprv with derivation path.</p>
<p>Pull request <a href="https://github.com/bitcoin/bitcoin/pull/22051" rel="nofollow noreferrer">#22051</a> added support for <code>tr(KEY,{{S1,{{S2,S3},...}},...})</code> descriptors and the notation was confirmed in pull request <a href="https://github.com/bitcoin/bitcoin/pull/21365#issuecomment-793300643" rel="nofollow noreferrer">#21365</a>.</p>

CC BY-SA 4.0
2022-09-14T08:12:57.103Z
Thanks, how didn't I think of it *facepalm*  

Maybe we should update the descriptor documentation with an example
Sosthène
CC BY-SA 4.0
2022-09-13T15:37:40.100Z
2022-09-14T14:21:16.473Z
2022-09-14T14:21:16.473Z
Michael Folkson
<p>I read in the Bitcoin Core doc an example of a taproot output descriptor with 2 script paths :</p>
<pre><code>tr(c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5,{pk(fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556),pk(e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13)})
</code></pre>
<p>I tried to pass a descriptor with a third script path, but I'm met with an error <code>tr(): expected ')' after script expression</code></p>
<p>That makes sense since I read in the same doc that the syntax for taproot descriptor is <code>tr(KEY,TREE)</code>, and that <code>TREE</code> is defined as:</p>
<pre><code>* any SCRIPT expression
* An open brace {, a TREE expression, a comma ,, a TREE expression, and a closing brace }
</code></pre>
<p>This is consistent with what I saw in the rust-bitcoin library, where a <code>TAPTREE</code> is either a leaf, or 2 trees.</p>
<p>My question is what if I wanted to commit a third script, a very simple one like the 2 in the example?</p>
<p>I think I could compute the root of my tree myself and use the <code>rawtr()</code> descriptor with the output pubkey, but what if I want to prove there's no hidden commitment?</p>
<p>I guess I could give all the scripts and that one could figure it out by recreating the scriptpubkey and check it's the same, but that's cumbersome.</p>

<taproot><output-script-descriptors>
How to represent a taproot output with more than 2 scriptleaves as a descriptor?
Sosthène
# How to represent a taproot output with more than 2 scriptleaves as a descriptor?

(Asked by: username_0 on 2022-09-13)

I read in the Bitcoin Core doc an example of a taproot output descriptor with 2 script paths :

```
tr(c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5,{pk(fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556),pk(e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13)})

```

I tried to pass a descriptor with a third script path, but I'm met with an error `tr(): expected ')' after script expression`

That makes sense since I read in the same doc that the syntax for taproot descriptor is `tr(KEY,TREE)`, and that `TREE` is defined as:

```
* any SCRIPT expression
* An open brace {, a TREE expression, a comma ,, a TREE expression, and a closing brace }

```

This is consistent with what I saw in the rust-bitcoin library, where a `TAPTREE` is either a leaf, or 2 trees.

My question is what if I wanted to commit a third script, a very simple one like the 2 in the example?

I think I could compute the root of my tree myself and use the `rawtr()` descriptor with the output pubkey, but what if I want to prove there's no hidden commitment?

I guess I could give all the scripts and that one could figure it out by recreating the scriptpubkey and check it's the same, but that's cumbersome.

**Tags:** taproot, output-script-descriptors


---

## 1 answers

### Answer by username_1 on 2022-09-13. Score: 4 | Accepted answer

If you want a Merkle tree with script paths `S1` and `S2` on the second level of the Merkle tree and script path `S3` on the first level of the Merkle tree the descriptor notation is:

`tr(KEY,{{S1,S2},S3})`

where `KEY` can be any key expression including public key, x-only public key, WIF private key, xpub, xprv or xpub/xprv with derivation path.

Pull request [#22051](https://github.com/bitcoin/bitcoin/pull/22051) added support for `tr(KEY,{{S1,{{S2,S3},...}},...})` descriptors and the notation was confirmed in pull request [#21365](https://github.com/bitcoin/bitcoin/pull/21365#issuecomment-793300643).

> **Comments:**
> **username_0**: Thanks, how didn't I think of it *facepalm*    Maybe we should update the descriptor documentation with an example  

---

