InvalidWordException

Exception thrown when a word is not found in the specified word list.

BIP-39 defines standardized word lists for multiple languages. Each list contains exactly 2048 unique words. This exception is thrown when a mnemonic contains a word that does not exist in the expected word list.

Common causes:

  • Misspelled word in the mnemonic

  • Using a mnemonic from one language with a different language's word list

  • Word truncated or corrupted

  • Non-BIP-39 word list used during mnemonic generation

Recovery actions:

  • Check spelling of the reported word

  • Try a different language word list if the mnemonic was generated elsewhere

  • Verify the complete word was entered (some words are similar prefixes)

Example:

try {
val m = Mnemonic.from(
mnemonic = "abandonn abandon abandon abandon abandon abandon " +
"abandon abandon abandon abandon abandon about",
language = MnemonicLanguage.ENGLISH
)
} catch (e: InvalidWordException) {
println("Unknown word: '${e.word}'")
println("Language: ${e.language.name}")
println("Please check spelling or try a different language")
}

See also:

Constructors

Link copied to clipboard
constructor(word: String, language: MnemonicLanguage)

Properties

Link copied to clipboard
expect open val cause: Throwable?
Link copied to clipboard

The language of the word list that was searched

Link copied to clipboard
expect open val message: String?
Link copied to clipboard

The word that was not found in the word list

Functions

Link copied to clipboard
open override fun toString(): String