My sortedmulti_a taproot descriptor is being rejected by bitcoin-cli, why?
Question
I am attempting the following on regtest:
request: ["id": "51C82AC3-C966-4B37-BF01-426AB6A822D4", "jsonrpc": "1.0", "method": "getdescriptorinfo", "params": ["descriptor": "tr(sortedmulti_a(2,[38358b48/48h/1h/0h/3h]tpubDEJEvCnT3zY8LiJLXijiWFMT47h5Qz5xgbTx3ZrzyEtv9SSbFUKHQHk7mYPA1XezsRQwxm3DX12B8Sy47dnUhYLnF6HnU7nCkdgvxxBxkV7/0/*,[5f8ca6c0/48h/1h/0h/3h]tpubDEY9RgKWR6YkqvniTF29GSgocQiPmHQrmYxhFQ8PwApidoyJSffSSHUMekMggsPMVNGpiqx1A2KMf9hetZ5G5nrW9DbspqqMdg8bTaEGGBA/0/*))"]]
json: {
error = {
code = "-5";
message = "tr(): Multiple ']' characters found for a single pubkey";
};
id = "51C82AC3-C966-4B37-BF01-426AB6A822D4";
result = "<null>";
}
In bitcoin/docs/Descriptors.md I don't see anything mentioning why my descriptor would be invalid, could you please let me know what I am doing wrong?
tr(sortedmulti_a(2,[38358b48/48h/1h/0h/3h]tpubDEJEvCnT3zY8LiJLXijiWFMT47h5Qz5xgbTx3ZrzyEtv9SSbFUKHQHk7mYPA1XezsRQwxm3DX12B8Sy47dnUhYLnF6HnU7nCkdgvxxBxkV7/0/*,[5f8ca6c0/48h/1h/0h/3h]tpubDEY9RgKWR6YkqvniTF29GSgocQiPmHQrmYxhFQ8PwApidoyJSffSSHUMekMggsPMVNGpiqx1A2KMf9hetZ5G5nrW9DbspqqMdg8bTaEGGBA/0/*))
Answer 1
The error message is confusing, but the problem is that the tr() fragment takes as input a KEY expression, while you're giving it a SCRIPT expression.
The syntax for tr is either tr(KEY) or tr(KEY,TREE). The KEY here is the key to use as internal public key, while the TREE is a tree of script leaves.
The sortedmulti_a(...) fragment is a script expression. If you want to use a script, it needs to appear in the script tree. If so, you still need a separate key expression to use as the internal public key.
For reference, the descriptor is not being rejected by bitcoin-cli, as that is just a tool that hands its arguments to the node it is connecting to (typically bitcoind). It is the node which is rejecting it.