michailbrynard / ethereum-bip44-python

Python code to generate Ethereum addresses from a hierarchical deterministic wallet according to the BIP44 standard.
Other
104 stars 45 forks source link

Invalid mnemonics #9

Closed mattbeckman closed 3 years ago

mattbeckman commented 3 years ago

I'm finding a number of generated mnemonics are invalid according to Ian Coleman's bip39 app.

Can you tell me if this is an issue with my code below?

mnemonic = i1 +' '+ i2 +' '+ i3 +' '+ i4 +' '+ i5 +' '+ i6 +' '+ i7 +' '+ i8 +' '+ i9 +' '+ i10 +' '+ i11 +' '+ i12

master_key = HDPrivateKey.master_key_from_mnemonic(mnemonic)

root_keys = HDKey.from_path(master_key,"m/44'/60'/0'")

acct_priv_key = root_keys[-1]

keys = HDKey.from_path(acct_priv_key,'{change}/{index}'.format(change=0, index=0))

private_key = keys[-1]

address = private_key.public_key.address()

print(address, ' ', mnemonic)

Here is an example of a set of mnemonics that were generated, but are marked as invalid: spike kidney come bird nominee puppy wool subject short add mystery hawk (these are not from a live wallet but generated from a set of words). Thanks.

mattbeckman commented 3 years ago

All good. I forgot I could use Mnemonic to check if the word set/checksum was valid.

In case someone else needs this:

mnemo = Mnemonic("english")
mnemonic = "wordA wordB ..."
if mnemo.check(mnemonic):
    # valid mnemonic