Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BIP39 and BIP44 Wallet Import (using Master Private Key) #1

Open
mflaxman opened this issue Jul 31, 2015 · 0 comments
Open
Assignees

Comments

@mflaxman
Copy link

Update: here's code to meet the 39 and 44 spec, but since they use hardened derivation for the change and receiving trees it breaks the general structure of the wallet and requires a much bigger re-write :(

# This matches https://www.reddit.com/r/Bitcoin/comments/2srxr2/what_is_the_difference_between_bip_32_and_bip_44/

from mnemonic import Mnemonic

m = Mnemonic('english')

hexlify(m.to_seed(mnemonic='cheese upset pudding inmate flavor crush hard same element index laugh supreme'))
b'8b3137dc79f912e4c5cddbe4bbe313abd0a0a8cf2441dcf4d664655087e8c202431e8e7b2503e63426703b3c773a12473a94c39058e7fb0784ab570b80ed0a23'

from bitmerchant.wallet import Wallet
from binascii import unhexlify

wallet = Wallet.from_master_secret(unhexlify(b'8b3137dc79f912e4c5cddbe4bbe313abd0a0a8cf2441dcf4d664655087e8c202431e8e7b2503e63426703b3c773a12473a94c39058e7fb0784ab570b80ed0a23'))

wallet.serialize_b58()
xprv9s21ZrQH143K3Wjn9PzvdHooVbaSauXnawrxMhi7BdR1PrC41x51WTBWybzSjUaiPVH6BusrpupCkouMgAkBGtNJhb3bqpmRuKG5vrH96GL

wallet.get_child_for_path("m/44'/0'/0'/0/0").to_address()  # '1LPdUu1qKXFTowobD9uB62QesdodtV2ugx'

change_wallet = wallet.get_child_for_path('''m/44'/0'/0'/0/0''')

change_wallet.to_address()  # '1LPdUu1qKXFTowobD9uB62QesdodtV2ugx'

change_wallet.export_to_wif()  # 'KziXBfNy2eZEKHdZeBZQ3ZyW3joXcv2k66yHuKPaDgNwEX76wMPU'
@mflaxman mflaxman self-assigned this Jul 31, 2015
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

No branches or pull requests

1 participant