key generate subcommand silently coerces any word count other than 12 to 24 words
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 84/100
Línea de trabajo
Empieza por localizar KeySubCommand::Generate y el analizador de argumentos word_count descrito en el issue. Comprueba cómo el comando asigna los valores analizados a bdk_wallet::keys::bip39::WordCount y, después, ejecuta las pruebas pertinentes de CLI o prueba los ejemplos de 15 palabras y de valor no válido. El trabajo estará terminado cuando se admitan las cinco longitudes compatibles y se rechacen los valores no admitidos con un mensaje que enumere las opciones válidas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 143
- Forks
- 103
- Merge medio
- 2 d 8 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bitcoindevkit/bdk-cli
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
bitcoindevkit/bdk-cli#360 ·
Los mantenedores suelen responder en 1 día
-
Expose remaining SignOptions fields in the wallet sign commandPosiblemente ocupada @emma31-dev la tomó hace 3 días. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
bitcoindevkit/bdk-cli#358 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
wallet sign command returns generic error for decoding failuresPosiblemente ocupada @emma31-dev la tomó hace 3 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bitcoindevkit/bdk-cli#357 ·
Los mantenedores suelen responder en 1 día
-
Remove "wallet" field from `WalletConfigInner`Posiblemente ocupada @Jennycj la tomó hace 12 días. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bitcoindevkit/bdk-cli#332 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
bitcoindevkit/bdk-cli#359 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de bitcoindevkit/bdk-cli
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
farion1231/cc-switch#8829 ·
Los mantenedores suelen responder en 1 día
-
bug ci good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
longbridge/gpui-kit#3677 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
ilya-zlobintsev/LACT#1235 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Shared Sink flush/close can complete without submitting buffered tasksPosiblemente ocupada @RivTian la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
apalis-dev/apalis#797 ·
Los mantenedores suelen responder en 7 días