I tried to generate wallets by using pywallet and bip32utils (Python). But I noted that the addresses/keys of the 2 wallets, namely wallet_pywallet and wallet_bip39 don't match with each other.

I noted that the addresses/keys of wallet_bip39 match with Exodus, but wallet_pywallet doesn't. We have been using pywallet for such a long time so I believe wallet_pywallet should be correct as well. Why is there such a discrepancy?

Below is the code, while the code for wallet_bip39 is obtained from this post.

from pywallet import wallet
import binascii
import mnemonic
import bip32utils

def bip39(mnemonic_words):
    mobj = mnemonic.Mnemonic("english")
    seed = mobj.to_seed(mnemonic_words)

    bip32_root_key_obj = bip32utils.BIP32Key.fromEntropy(seed)
    bip32_child_key_obj = bip32_root_key_obj.ChildKey(
        44 + bip32utils.BIP32_HARDEN
        0 + bip32utils.BIP32_HARDEN
        0 + bip32utils.BIP32_HARDEN

    return {
        'mnemonic_words': mnemonic_words,
        'addr': bip32_child_key_obj.Address(),
        'publickey': binascii.hexlify(bip32_child_key_obj.PublicKey()).decode(),
        'privatekey': bip32_child_key_obj.WalletImportFormat(),
        'coin': 'BTC'

mnemonic_words = wallet.generate_mnemonic()
wallet_pywallet = wallet.create_wallet(network="BTC", seed=mnemonic_words, children=0)
wallet_bip39 = bip39(mnemonic_words)

Derivation paths.

wallet_bip39 is using m/44'/0'/0' while (if I looked at the right pywallet code) pywallet is using m/0'

  • Thanks for your reply. I tried to change the bip39()'s code to bip32_child_key_obj = bip32_root_key_obj.ChildKey(0 + bip32utils.BIP32_HARDEN).ChildKey(0).ChildKey(0), but the keys/addresses of the two wallets still don't match with each other. – H42 Apr 11 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.