InvalidChecksumException

class InvalidChecksumException(message: String = "Mnemonic checksum validation failed") : Sep05Exception

Exception thrown when mnemonic checksum validation fails.

BIP-39 mnemonics include a checksum derived from the SHA-256 hash of the entropy. The checksum is appended to the entropy before encoding to words. When decoding, the checksum is recalculated and compared. A mismatch indicates the mnemonic was corrupted or contains a typo.

Checksum sizes by mnemonic length:

  • 12 words: 4-bit checksum

  • 15 words: 5-bit checksum

  • 18 words: 6-bit checksum

  • 21 words: 7-bit checksum

  • 24 words: 8-bit checksum

Recovery actions:

  • Double-check spelling of each word

  • Verify word order is correct

  • Ensure using the correct word list language

Example:

try {
// Mnemonic with incorrect last word (checksum word)
val m = Mnemonic.from(
"abandon abandon abandon abandon abandon abandon " +
"abandon abandon abandon abandon abandon wrong"
)
} catch (e: InvalidChecksumException) {
println("Checksum failed: ${e.message}")
println("Please verify your mnemonic phrase for typos")
}

See also:

Parameters

message

Description of the checksum failure (defaults to standard message)

Constructors

Link copied to clipboard
constructor(message: String = "Mnemonic checksum validation failed")

Properties

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

Functions

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