Author

Topic: Python code to generate private key from BIP39 seed phrase and path (Read 148 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
bitcoinlib library should do the job. I've made sure there's option to enter your own BIP39 seed phrase and path. Here's example code (i checked the result with https://iancoleman.io/bip39/),

Code:
>>> from bitcoinlib.wallets import Wallet
>>> mnemonic = "jaguar laptop random problem corn nut fun happy maximum federal wrap address"
>>> w = Wallet.create('Wallet1', keys=mnemonic, network='bitcoin')
>>> k = w.key_for_path([0, 0])
>>> k.address
'17AmSBNzGunnuPzCiJoTV2mdqu4v9Jt7QY'
>>> k = w.key_for_path([0, 1])
>>> k.address
'1Q9UgCADh16mfVaA5xmKxiCLZuiCG1g3zr'
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
Need to quickly get some Python for deriving private keys at a path given a seed, as I'm trying to create payment addresses for users on my website. (The addresses will be used in my Flask server and stored in a database.)

The seed phrase itself is going to be stored in some libsodium-kind of container, so no need to worry about that.
Jump to: