`compile` doesn't validate keys and returns unusable descriptors
メンテナーはふだん 2 日以内に返信
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Rust
- スター
- 143
- フォーク
- 98
- 平均マージ
- 5日 21時間
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bitcoindevkit/bdk-cli のほかの issue
-
Remove "wallet" field from `WalletConfigInner`対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bitcoindevkit/bdk-cli#332 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
bitcoindevkit/bdk-cli#349 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
bitcoindevkit/bdk-cli#340 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Enforce Core-compatible OP_RETURN / datacarrier and standard tx-size limits in create_tx対応中かも @tvpeter が 17 日前に担当しました。 オープンenhancement
bitcoindevkit/bdk-cli#339 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
bitcoindevkit/bdk-cli#338 ·
メンテナーはふだん 2 日以内に返信
bitcoindevkit/bdk-cli の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
project-robius/robrix#1154 ·
メンテナーはふだん 1 日以内に返信
-
Add Mimirオープン
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
slavakurilyak/awesome-ai-agents#759 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
compiler-explorer/compiler-explorer#9272 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 63/100
pop-os/cosmic-files#2117 ·
メンテナーはふだん 2 日以内に返信