• Welcome to forex.pm forex forum binary options trade. Please login or sign up.
 

Generate addresses from Trezor's xPub using Python

Started by Bitcoin, Apr 02, 2022, 04:44 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bitcoin

Generate addresses from Trezor's xPub using Python

I am trying to generate BIP32 HD addresses from my Trezors xPub key.
I keep getting errors with most of the libs our there. What am I missing?



pywallet:



from pywallet import wallet
xpub = 'ypub6Y9NsCaunfAtedv6VX7UTfuvQGLu1TgMtLtjnRydESqWwUSkJnAzATyCzscezpcfoXtgJhAfUTauEQWWt8xvbLxo7qXToCDkJi1Nb1b7wZB'
wallet.create_address(network="BTC", xpub=pub, child=0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/pywallet/wallet.py", line 48, in create_address
    wallet_obj = Wallet.deserialize(xpub, network=network.upper())
  File "/usr/local/lib/python3.5/dist-packages/pywallet/utils/bip32.py", line 557, in deserialize
    version)
pywallet.utils.keys.IncompatibleNetworkException: Incorrect network. Bitcoin Main Net expects a byte prefix of 76067358, but you supplied b'\x04\x9d|\xb2'


The pybitcointools do generate an address, but they do not match the one Trezor generates.



Essentially I need code which replicated Trezor address generation from xPub. Any ideas?


Source: Generate addresses from Trezor's xPub using Python