bitcoindevkit / bitcoindevkit/bdk-cli

`compile --type=sh` produces a descriptor Bitcoin Core rejects

Ouverte
#313 2 commentaires 0 réactions 1 personne assignée Réclamée par @vadim-anfv Voir sur GitHub
discussion
Langage dominant
Rust
Étoiles
141
Forks
99
Merge moyen
6 j 14 min
PR mergées (30 j)
1

Description

`bdk-cli compile` accepts `--type` values `sh`, `wsh`, `sh-wsh` and `tr`. Only `sh` produces a descriptor Bitcoin Core rejects:

```console
$ A=$(bdk-cli --network bitcoin key generate | jq -r .xprv)
$ B=$(bdk-cli --network bitcoin key generate | jq -r .xprv)

$ D=$(bdk-cli compile "or(pk($A),pk($B))" --type=sh | jq -r .descriptor)

$ bitcoin-cli getdescriptorinfo "$D"
error code: -5
error message:
Miniscript expressions can only be used in wsh or tr.
```

The same policy with `--type=wsh`, `--type=sh-wsh` and `--type=tr` is accepted.

BIP 379 scopes Miniscript to P2WSH and Tapscript, and excludes P2SH explicitly, [spec](https://github.com/bitcoin/bips/blob/ed4ffcb6a48d4dc4fdfc11cdba783c233db8c66e/bip-0379.md#specification):

> These specifications apply to P2WSH (BIP 141) and Tapscript (BIP 342) scripts [...] P2SH and bare scripts are excluded from this specification.

Core enforces that where it parses the Miniscript expression, [src](https://github.com/bitcoin/bitcoin/blob/9be056a8a72b624dae9623b2f7bded92c2a21c91/src/script/descriptor.cpp#L2600-L2604):

```cpp
if (node) {
if (ctx != ParseScriptContext::P2WSH && ctx != ParseScriptContext::P2TR) {
error = "Miniscript expressions can only be used in wsh or tr.";
return {};
}
```

bdk-cli can still build the descriptor because `rust-miniscript` keeps the pre-BIP contexts. BDK also handles it end to end: `wallet config --ext-descriptor "$D"` followed by `new_address` derives a P2SH address, and the script itself is consensus-valid. Other descriptor-based wallets may not support this type though - Core rejects it outright, in both `getdescriptorinfo` and `importdescriptors`.

@tvpeter how would you like this handled?

1. drop `sh` from the accepted `--type` values
2. keep it, but warn on output and document that it is outside BIP 379 specification

Happy to open the PR once you have picked one.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.