Mnemonic (Class)¶
A BIP-39 mnemonic seed phrase.
Mnemonic phrases (also called seed phrases or recovery phrases) are human-readable representations of cryptographic seeds used for HD wallet generation.
__new__
¶
Create a mnemonic from an existing phrase.
| PARAMETER | DESCRIPTION |
|---|---|
phrase
|
The mnemonic phrase string.
TYPE:
|
language
|
Optional language for the phrase (default: English). |
| RETURNS | DESCRIPTION |
|---|---|
Mnemonic
|
A new Mnemonic instance.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If the phrase is invalid. |
random
staticmethod
¶
random(word_count: Optional[int] = None) -> Mnemonic
Generate a random mnemonic phrase.
| PARAMETER | DESCRIPTION |
|---|---|
word_count
|
Number of words (12, 15, 18, 21, or 24). Default: 24.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Mnemonic
|
A new random mnemonic.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If the word count is invalid. |
to_seed
¶
Convert the mnemonic to a seed for key derivation.
| PARAMETER | DESCRIPTION |
|---|---|
password
|
Optional passphrase for additional security.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The seed as a hex string.
TYPE:
|
Note
The same mnemonic with different passwords produces completely different seeds (and thus different wallets).