Skip to content

Add WordCount for mnemonic generation - #98

Open
coreyphillips wants to merge 1 commit into
rust-bitcoin:masterfrom
coreyphillips:feat/wordcount-enum
Open

Add WordCount for mnemonic generation#98
coreyphillips wants to merge 1 commit into
rust-bitcoin:masterfrom
coreyphillips:feat/wordcount-enum

Conversation

@coreyphillips

@coreyphillips coreyphillips commented Nov 11, 2025

Copy link
Copy Markdown

Adds a public WordCount enum and updates generate, generate_in, and generate_in_with to accept it instead of usize. The enum restricts generation to the five BIP39 word counts.

This is a breaking API change. Callers must replace integer word counts with the corresponding WordCount variant.

Closes #97.

AI tooling was used to help revise this change.

@caarloshenriq caarloshenriq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

I tested the changes locally:

  • Ran the full test suite (cargo test) and all tests passed.
  • Performed manual tests by generating mnemonics with different WordCount variants (12, 18, and 24 words) using generate, generate_in, and generate_in_with.
  • All generated mnemonics had the correct word count and the generation flow behaved as expected.

Everything worked as intended.

@tnull tnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this! While it's a nice API improvement, it's probably not super critical so I think we want to hold off on merging this until we have another, more critical change that would require breaking API anyways.

In the meantime, here are a few comments. Please also always disclose in the PR description and commit message if you utilized AI tooling. To this end, rewriting the PR description and commit messages to replace AI slop with concise descriptions would be appreciated. Thanks!

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs
@coreyphillips coreyphillips changed the title feat: replace usize with WordCount enum for mnemonic generation Add WordCount for mnemonic generation Aug 7, 2026
Restrict mnemonic generation to the five BIP39 word counts by accepting WordCount in generate, generate_in, and generate_in_with.

Update documentation, tests, and benchmarks for the new API.

AI tooling was used to help revise this change.
@coreyphillips

Copy link
Copy Markdown
Author

Thanks. I addressed the inline comments, updated the benchmark call site, and rewrote the PR description and commit message with an AI tooling disclosure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce enum WordCount

3 participants