Skip to content

Conversation

@coreyphillips
Copy link

@coreyphillips coreyphillips commented Nov 11, 2025

This PR:

  • Adds WordCount enum to restrict word counts to valid BIP39 values (12, 15, 18, 21 & 24)
  • Updates generate(), generate_in(), and generate_in_with() to accept WordCount instead of usize
  • Updates usage in comments and tests accordingly
  • Closes Introduce enum WordCount #97
  • ⚠️ This is a breaking change
    • generate() now requires use of the WordCount enum for the word_count parameter.
    • Migration:
      // Before
      let m = Mnemonic::generate(24)?;
      
      // After
      let m = Mnemonic::generate(WordCount::Words24)?;

- Add WordCount enum to restrict word counts to valid BIP39 values (12, 15, 18, 21 & 24)
- Update generate(), generate_in(), and generate_in_with() to accept WordCount instead of usize
- Update usage in comments and tests accordingly
Copy link
Contributor

@caarloshenriq caarloshenriq left a comment

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.

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

2 participants