key generate subcommand silently coerces any word count other than 12 to 24 words
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず、issueで説明されている KeySubCommand::Generate と word_count 引数パーサーを見つけます。コマンドが解析済みの値を bdk_wallet::keys::bip39::WordCount にどのように対応付けるかを確認し、関連するCLIテストを実行するか、15語の例と無効な値の例を試します。完了条件は、サポートされている5つの長さがすべて受け入れられ、サポートされていない値は有効な選択肢を列挙するメッセージとともに拒否されることです。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
key generate accepts any integer for --word-count but only distinguishes 12 from everything else. The match arm is:
let mnemonic_type = match self.word_count {
12 => WordCount::Words12,
_ => WordCount::Words24,
};
So --word-count 15 produces a 24-word mnemonic, --word-count 0 produces a 24-word mnemonic, and --word-count 999 produces a 24-word mnemonic. No error, no warning, no indication that the requested value was ignored. BIP39 defines five valid lengths: 12, 15, 18, 21, 24 and bdk_wallet::keys::bip39 WordCount already support all five, so the restriction is purely in the CLI's argument handling.
To Reproduce
- Request a 15-word mnemonic:
bdk-cli key generate --word-count 15 - Count the words in the output: it is 24, not 15.
- Confirm nonsense values are also accepted without error:
This also produces 24 words.bdk-cli key generate --word-count 0
Expected behavior
--word-count 15 should produce a 15-word mnemonic, since the library supports it. Invalid values such as 0, 13, or 999 should be rejected at parse time with a message listing the valid options, not silently coerced. PossibleValuesParser or a custom value_parser handles both:
#[arg(
long = "word-count",
short = 'w',
default_value = "WordCount::Words12",
value_parser = word_count_parser
)]
pub word_count: WordCount,
in the word_count_parser:
let word_count = match word_count {
"12" => WordCount::Words12,
"15" => WordCount::Words15,
"18" => WordCount::Words18,
"21" => WordCount::Words21,
"24" => WordCount::Words24,
_ => return(Error::Generic("...")),
};
The change is confined to KeySubCommand::Generate; no library or API changes are needed.
Build environment
· BDK-CLI tag/commit: main
· OS+version: macOS 12.7.6 (Monterey)
· Rust/Cargo version: rustc --version output
· Rust/Cargo target: x86_64-apple-darwin
Additional context
The silent coercion means a user's request is never honoured unless it happens to be exactly 12, and the failure mode is invisible. The command just succeeds and returns a valid mnemonic of the wrong length. Since usize parsing already rejects negative values, the only way to reach the match arm with an unintended value is a typo or an unsupported length, and both currently produce 24 words with no diagnostic. Validating at the clap boundary fixes both the missing lengths and the silent acceptance in a single change.
- 主要言語
- Rust
- スター
- 143
- フォーク
- 103
- 平均マージ
- 2日 9時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bitcoindevkit/bdk-cli のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
bitcoindevkit/bdk-cli#360 ·
メンテナーはふだん 1 日以内に返信
-
Expose remaining SignOptions fields in the wallet sign command対応中かも @emma31-dev が 2 日前に担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bitcoindevkit/bdk-cli#358 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
wallet sign command returns generic error for decoding failures対応中かも @emma31-dev が 2 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bitcoindevkit/bdk-cli#357 ·
メンテナーはふだん 1 日以内に返信
-
Remove "wallet" field from `WalletConfigInner`対応中かも @Jennycj が 11 日前に担当しました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bitcoindevkit/bdk-cli#332 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
bitcoindevkit/bdk-cli#359 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
bitcoindevkit/bdk-cli の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
foxglove/mcap#1907 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted r-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
servo/rust-smallvec#792 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信