Skip to content

Keep mnemonic words out of exception messages - #161

Merged
ebellocchia merged 1 commit into
ebellocchia:masterfrom
fametrano:mnemonic-not-in-exception
Oct 20, 2026
Merged

ebellocchia merged 1 commit into
ebellocchia:masterfrom
fametrano:mnemonic-not-in-exception

Conversation

@fametrano

Copy link
Copy Markdown
Contributor

When the language is not given, a mnemonic with one misspelled word raises a ValueError that holds the whole mnemonic. I found five more messages with the same problem: the word lookup names the word it did not find, TonSeedGenerator prints the whole mnemonic, and the BIP39, Algorand and Monero checksum errors print checksum words or bits of the mnemonic.

This PR removes the mnemonic data from all six messages and keeps the exception types. The word lookup also chained the KeyError holding the word, so it now raises with no exception chained. The test_invalid_mnemonic tests of BIP39, Algorand, Monero, Polyseed, TON and Electrum v1/v2 now check the message and the chain. All seven fail on master. Closes #160.

A misspelled word made the language detection copy the whole mnemonic
into the ValueError message. The word lookup, the TON seed generator
and the BIP39, Algorand and Monero checksum errors also put words or
checksum bits of the mnemonic in their messages.

The word lookup also chained the KeyError holding the word to its
ValueError. It now raises without a caught exception.

Close ebellocchia#160
@ebellocchia
ebellocchia merged commit 6a1ddae into ebellocchia:master Oct 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A mnemonic with a misspelled word is copied whole into the exception message

2 participants