I am developing some code to derive addresses from different master public keys extracted from a series of wallets for some experiments I want to conduct. My code is currently able to work with most wallets I’ve tried to use, but Electrum seems to fail, as the xpub that can be extracted from Electrum app is not from the regular derivation path m/84/0/0 but from m/0h, causing this lines of code:
xpub_str="zpub6restofthekey..."
bip_obj = Bip84.FromExtendedKey(xpub_str, Bip84Coins.BITCOIN)
addr = bip_obj.Change(Bip44Changes.CHAIN_EXT).AddressIndex(index).PublicKey().ToAddress()
To throw the following exception: "error": "Depth of the public-only Bip object (<bip_utils.bip.bip32.bip32_key_data.Bip32Depth object at 0x000001D6E7D885D0>) is below account level or beyond address index level".
At first I thought the issue might be using zpub instead of xpub, but other wallets such as Trezor Suite or Green also use zpub and I’ve been able to successfully generate addresses with the code I showed above.
If anyone knows how I can workaround this issue, or some alternative way of computing addresses from the Electrum xpub, I’d be very grateful.












