bip39_mnemonic_utils

Module for BIP39 mnemonic utility classes.

class Bip39WordsListGetter

Bases: MnemonicWordsListGetterBase

BIP39 words list getter class. It allows to get words list by language so that they are loaded from file only once per language.

GetByLanguage(lang: MnemonicLanguages) MnemonicWordsList

Get words list by language. Words list of a specific language are loaded from file only the first time they are requested.

Parameters:

lang (MnemonicLanguages) – Language

Returns:

MnemonicWordsList object

Return type:

MnemonicWordsList object

Raises:
  • TypeError – If the language is not a Bip39Languages enum

  • ValueError – If loaded words list is not valid

m_words_lists: Dict[MnemonicLanguages, MnemonicWordsList]
class Bip39WordsListFinder

Bases: MnemonicWordsListFinderBase

BIP39 words list finder class. It automatically finds the correct words list from a mnemonic.

classmethod FindLanguage(mnemonic: Mnemonic) Tuple[MnemonicWordsList, MnemonicLanguages]

Automatically find the language of the specified mnemonic and get the correct MnemonicWordsList class for it.

Parameters:

mnemonic (Mnemonic object) – Mnemonic object

Returns:

MnemonicWordsList object (index 0), mnemonic language (index 1)

Return type:

tuple[MnemonicWordsList, MnemonicLanguages]

Raises:

ValueError – If the mnemonic language cannot be found