Class Mnemonic
-
- All Implemented Interfaces:
public final class MnemonicProvides utility methods to generate random mnemonics and also generate seeds from mnemonics.
-
-
Method Summary
Modifier and Type Method Description final LanguagegetLanguage()The language of the mnemonic words, defaults to Language.ENGLISH. final Stringgenerate(Integer strength)Generates a random mnemonic. final Stringgenerate()Generates a random mnemonic. final ByteArraytoEntropy(List<String> words)Converts the mnemonic words to entropy. final StringtoMnemonic(ByteArray entropy)Converts the entropy to mnemonic words. final Booleancheck(String mnemonic)Checks if the mnemonic is valid. final StringexpandWord(String prefix)Expands the given word prefix to a complete word from the wordlist. final Stringexpand(String mnemonic)Expands the given mnemonic by expanding each word prefix to a complete word from the wordlist. final static LanguagedetectLanguage(String mnemonic)Detects the language of the mnemonic words. final static ByteArraytoSeed(String mnemonic, String passphrase)Converts the mnemonic words to a seed. final static ByteArraytoSeed(String mnemonic)Converts the mnemonic words to a seed. final static StringtoHdMasterKey(ByteArray seed, Boolean testnet)Converts the seed to a BIP32 HD master key. final static StringtoHdMasterKey(ByteArray seed)Converts the seed to a BIP32 HD master key. -
-
Method Detail
-
getLanguage
final Language getLanguage()
The language of the mnemonic words, defaults to Language.ENGLISH.
-
generate
@JvmOverloads() final String generate(Integer strength)
Generates a random mnemonic.
- Parameters:
strength- The strength of the mnemonic, defaults to 128 bits.- Returns:
The generated mnemonic.
-
generate
@JvmOverloads() final String generate()
Generates a random mnemonic.
- Returns:
The generated mnemonic.
-
toEntropy
final ByteArray toEntropy(List<String> words)
Converts the mnemonic words to entropy.
- Parameters:
words- The mnemonic words.- Returns:
The entropy.
-
toMnemonic
final String toMnemonic(ByteArray entropy)
Converts the entropy to mnemonic words.
- Parameters:
entropy- The entropy.- Returns:
The mnemonic words.
-
check
final Boolean check(String mnemonic)
Checks if the mnemonic is valid.
- Parameters:
mnemonic- The mnemonic words.- Returns:
True if the mnemonic is valid, false otherwise.
-
expandWord
final String expandWord(String prefix)
Expands the given word prefix to a complete word from the wordlist.
- Parameters:
prefix- The word prefix.- Returns:
The expanded word if a unique match is found, otherwise the original prefix.
-
expand
final String expand(String mnemonic)
Expands the given mnemonic by expanding each word prefix to a complete word from the wordlist.
- Parameters:
mnemonic- The mnemonic words.- Returns:
The expanded mnemonic.
-
detectLanguage
final static Language detectLanguage(String mnemonic)
Detects the language of the mnemonic words.
- Parameters:
mnemonic- The mnemonic words.- Returns:
The language code of the mnemonic words.
-
toSeed
@JvmOverloads() final static ByteArray toSeed(String mnemonic, String passphrase)
Converts the mnemonic words to a seed.
- Parameters:
mnemonic- The mnemonic words.passphrase- The passphrase to use for the seed, defaults to an empty string.- Returns:
The seed.
-
toSeed
@JvmOverloads() final static ByteArray toSeed(String mnemonic)
Converts the mnemonic words to a seed.
- Parameters:
mnemonic- The mnemonic words.- Returns:
The seed.
-
toHdMasterKey
@JvmOverloads() final static String toHdMasterKey(ByteArray seed, Boolean testnet)
Converts the seed to a BIP32 HD master key.
- Parameters:
seed- The seed.testnet- Whether to generate a testnet key, defaults to false.- Returns:
The HD master key.
-
toHdMasterKey
@JvmOverloads() final static String toHdMasterKey(ByteArray seed)
Converts the seed to a BIP32 HD master key.
- Parameters:
seed- The seed.- Returns:
The HD master key.
-
-
-
-