key generate subcommand silently coerces any word count other than 12 to 24 words
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 84/100
Rechercherichtung
Beginne damit, KeySubCommand::Generate und den im Issue beschriebenen Argumentparser für word_count zu finden. Prüfe, wie der Befehl geparste Werte auf bdk_wallet::keys::bip39::WordCount abbildet, und führe dann die relevanten CLI-Tests aus oder probiere die Beispiele mit 15 Wörtern und einem ungültigen Wert aus. Fertig ist die Arbeit, wenn alle fünf unterstützten Längen berücksichtigt und nicht unterstützte Werte mit einer Meldung abgelehnt werden, die die gültigen Optionen auflistet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Rust
- Sterne
- 143
- Forks
- 103
- Ø Merge
- 2 T. 9 Std.
- Gemergte PRs (30 T.)
- 5
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
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
bitcoindevkit/bdk-cli#360 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Expose remaining SignOptions fields in the wallet sign commandEvtl. vergeben @emma31-dev hat das vor 1 Tag übernommen. Offenenhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
bitcoindevkit/bdk-cli#358 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
wallet sign command returns generic error for decoding failuresEvtl. vergeben @emma31-dev hat das vor 2 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
bitcoindevkit/bdk-cli#357 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Remove "wallet" field from `WalletConfigInner`Evtl. vergeben @Jennycj hat das vor 10 Tagen übernommen. Offenenhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
bitcoindevkit/bdk-cli#332 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
bitcoindevkit/bdk-cli#359 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in bitcoindevkit/bdk-cli
Ähnliche Issues
-
state:triage-needed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug P2
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 75/100
pedrovgs/UseCaseCoverage#23 ·
-
area: library data-loss tier: p0 type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
llm translation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag