3

Is there any Python package which will allow me to verify if the checksum of a bip39 mnemonic is valid? For instance, I have a 24-word bip39 mnemonic, and I might have made a mistake for one of the words. I want to see which words will result in a valid checksum.

I've seen Javascript versions, but nothing in Python

Michael Folkson
  • 14,337
  • 3
  • 11
  • 45
Sameer Lal
  • 43
  • 4
  • If this is being done with a significant amount of funds at stake (e.g. your life savings) be careful with what server you enter your mnemonic into. Ideally it should be a "airgapped computer that has no WiFi, Bluetooth, Ethernet or other networking capability" – Michael Folkson May 31 '23 at 09:44

1 Answers1

2

Clone/download this code from Trezor (don't forget the word list).

Then check your word-list like this:

from mnemonic import Mnemonic

code = "word1 word2 [...] word23 word24"
mnemo = Mnemonic("english")
isValid = mnemo.check(code) # returns a boolean
print('Checksum is valid: ' + str(isValid))
Jonathan Cross
  • 1,410
  • 10
  • 30
Pedro
  • 733
  • 4
  • 19