How to generate mycelium addresses from the 12 words in python
I am trying to re-generate the receiving addresses (and change addresses, for that matter) my mycelium wallet has generated.
So far I've used trezor's implementation of BIP39 to generate the entropy from the 12 words, and a BIP32 implementation I have used previously (successfully, to generate the same addresses as bitcoin core, which uses a different subkeys scheme), to produce the keys from the entropy.
Here's the code:
from bip32utils import BIP32Key
from bip32utils import BIP32_HARDEN
import bip39
wallet_generator = bip39.Mnemonic('english')
entropy = wallet_generator.to_entropy('12 words here')
key = BIP32Key.fromEntropy(entropy)
account_number = 0
i = 0
print key.ChildKey(44 + BIP32_HARDEN) \
.ChildKey(0 + BIP32_HARDEN) \
.ChildKey(account_number + BIP32_HARDEN) \
.ChildKey(0) \
.ChildKey(i) \
.Address()
I am trying to follow BIP44's scheme as described here.
I am getting a key, but not the one that appear in my first mycelium transaction. I've tries to search the first 100 i with account_number 0 and 1, to no avail. Using bip32gen from the command line does not produce the correct key either:
echo YOUR_ENTROPY_IN_HEX_HERE | \
bip32gen -v \
-i entropy -f - -x \
-o addr -F - -X \
m/44h/0h/0h/0/0
With entropy converted to hex with print ''.join('{:02X}'.format(x) for x in entropy)
I'm not sure if my use of bip39 or bip32utils (or both) is wrong. What am I missing?
http://ift.tt/2Ax1yIy
Comments
Post a Comment