]> Untitled Git - bdk-cli/commitdiff
Merge bitcoindevkit/bdk-cli#366: fix(key): reject word counts other than 12 and 24... master github/master
authormerge-script <m@vaan.io>
Fri, 6 Nov 2026 11:15:42 +0000 (15:15 +0400)
committermerge-script <m@vaan.io>
Fri, 6 Nov 2026 11:15:42 +0000 (15:15 +0400)
3dec0e02967832ed0728c98f138f52b02599088f fix(key): reject word counts other than 12 and 24 in key generate (Olorunshogo Moses BAMTEFA)

Pull request description:

  # PR description

  ### Description

  `key generate --entropy` only matched `12`; every other value was silently coerced to a 24-word mnemonic, so `15`, `0` or `999` all produced 24 words with no error.

  `--entropy` now parses into a `MnemonicWordCount` `ValueEnum` limited to `12` and `24`, so any other value is rejected at parse time and `--help` lists the options. The flag name, `-e`, `WORD_COUNT` env var and default of `12` are unchanged.

  Fixes #362

  | `--entropy` | Before | After |
  |---|---|---|
  | `12` / default | 12 words | 12 words |
  | `24` | 24 words | 24 words |
  | `15` / `18` / `21` | 24 words | error listing valid values |
  | `0` / `13` / `999` | 24 words | error listing valid values |

  ### Notes to reviewers

  - `WordCount` derives no traits (no `Clone`), so clap can't parse into it directly. `MnemonicWordCount` mirrors it with a `From` impl, following the `CompileScriptType` pattern used by `compile --type`.
  - Behavior change: values other than 12 and 24 that previously produced 24 words now error. Noted in the CHANGELOG.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### Bugfixes:

  * [x] I've added tests to reproduce the issue which are now passing
  * [x] I'm linking the issue being fixed by this PR

ACKs for top commit:
  vadim-anfv:
    tACK 3dec0e02967832ed0728c98f138f52b02599088f
  tvpeter:
    ACK 3dec0e02967832ed0728c98f138f52b02599088f

Tree-SHA512: 399f224dbc486012595efddd864cab03629b412bf6734471547eca3e9ef046d200d4979708c32acb17e5e9ef03c235909247af150f419b500a64e00234049b18


Trivial merge