`compile` doesn't validate keys and returns unusable descriptors
Maintainer antworten meist innerhalb von 2 Tagen
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 52/100
Rechercherichtung
Start from the compile subcommand, where the policy string is parsed as Concrete<String>, and reproduce with bdk-cli compile "pk(ABC)". The fix changes the parse type to Concrete<DescriptorPublicKey> and adds an --allow-placeholders flag that keeps the old behaviour. Done when placeholder keys and hashes are rejected by default, real keys and xpubs still compile, and existing tests and docs that use placeholders are updated.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
compile doesn't check that keys in the policy are actual keys. It succeeds and returns a descriptor that fails only later, when someone tries to use it:
$ bdk-cli compile "pk(ABC)"
{
"descriptor": "wsh(pk(ABC))#8gmtcnaw"
}
$ bitcoin-cli deriveaddresses "wsh(pk(ABC))#8gmtcnaw"
error code: -5
error message:
pk(): key 'ABC' is not valid
The policy is parsed as Concrete<String>, and a String key accepts anything.
Came up before in #225 and in the #317 review.
Proposed fix
Parse as Concrete<DescriptorPublicKey> by default. Keys are validated at parse time, so placeholders are rejected while real keys and xpubs keep working. Hashes are typed too, so sha256(H) is rejected the same way.
Keep the current behavior behind a flag, e.g. --allow-placeholders, since pk(A) style policies are handy to see what a policy compiles to, and in tests where only the policy shape matters, not the keys. This breaks existing calls with placeholders, docs and tests would need the flag or real keys.
# placeholder key is rejected
$ bdk-cli compile "pk(ABC)"
Error: Generic error: Invalid policy: unexpected «Key too short (<66 char), doesn't match any format»
# placeholder hash is rejected
$ bdk-cli compile "and(pk(02e5b88fdb71c696e1a473f309a47535b7190e21a22bd25e7fc8bd055db3bba12f),sha256(H))"
Error: Generic error: Invalid policy: unexpected «failed to parse hex»
# real keys and xpubs compile
$ bdk-cli compile "or(pk(02e5b88fdb71c696e1a473f309a47535b7190e21a22bd25e7fc8bd055db3bba12f),pk(xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/0/*))"
{
"descriptor": "wsh(or_b(pk(02e5b88fdb71c696e1a473f309a47535b7190e21a22bd25e7fc8bd055db3bba12f),s:pk(xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/0/*)))#t459ja6u"
}
# placeholders still work with the flag
$ bdk-cli compile "pk(ABC)" --allow-placeholders
{
"descriptor": "wsh(pk(ABC))#8gmtcnaw"
}
See
- DescriptorPublicKey in rust-miniscript
- Vorherrschende Sprache
- Rust
- Sterne
- 142
- Forks
- 103
- Ø Merge
- 5 T. 21 Std.
- Gemergte PRs (30 T.)
- 7
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus bitcoindevkit/bdk-cli
-
Remove "wallet" field from `WalletConfigInner`Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenenhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
bitcoindevkit/bdk-cli#332 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
enhancement
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 38/100
bitcoindevkit/bdk-cli#349 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 50/100
bitcoindevkit/bdk-cli#340 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Enforce Core-compatible OP_RETURN / datacarrier and standard tx-size limits in create_txEvtl. vergeben @tvpeter hat das vor 18 Tagen übernommen. Offenenhancement
bitcoindevkit/bdk-cli#339 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
bitcoindevkit/bdk-cli#338 ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in bitcoindevkit/bdk-cli
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
bytecodealliance/rustix#1703 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
bug discussion
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
medialab/xan#1201 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
farion1231/cc-switch#8298 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
ajeetdsouza/zoxide#1323 ·
Maintainer antworten meist innerhalb von 1 Tag