#!/usr/bin/env python3 """ Derive eCash (XEC) addresses from a BIP39 mnemonic. Uses the same derivation path as Cashtab / Electrum ABC: m/44'/899'/0'/0/<index> Install dependency: pip install bip_utils --break-system-packages SECURITY NOTE: Run OFFLINE on a machine you trust disconnected from the network if possible. Typing a seed phrase online can be risky. Use this only with test mnemonics until you've verified it locally, and verify a real derivation against a second independent wallet before trusting funds to it. """ from bip_utils import Bip39SeedGenerator, Bip44, Bip44Coins, Bip44Changes def derive_ecash_addresses(mnemonic: str, account: int = 0, count: int = 5): """ mnemonic: 12 or 24 word BIP39 phrase account: BIP44 account index (usually 0) count: how many receiving addresses to derive """ seed_bytes = Bip39SeedGenerator(mnemonic).Generate() bip44_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.ECASH) acc_ctx = bip44_ctx.Purpose().Coin().Account(account) change_ctx = acc_ctx.Change(Bip44Changes.CHAIN_EXT) # external/receiving chain results = [] for i in range(count): addr_ctx = change_ctx.AddressIndex(i) results.append({ "index": i, "path": f"m/44'/899'/{account}'/0/{i}", "address": addr_ctx.PublicKey().ToAddress(), "wif_private_key": addr_ctx.PrivateKey().ToWif(), }) return results if __name__ == "__main__": # Replace with your own mnemonic. This is the well-known public # BIP39 test vector -- do NOT use it for real funds. test_mnemonic = ( "abandon abandon abandon abandon abandon abandon " "abandon abandon abandon abandon abandon about" ) for entry in derive_ecash_addresses(test_mnemonic, count=3): print(f"[{entry['index']}] {entry['path']}") print(f" address: {entry['address']}") print(f" wif: {entry['wif_private_key']}")
Is there a way to convert 12 word mnemonic into public address starting with "ecash:<public>" address? There seem to be some python libraries but I couldn't get them to work for eCash.
1 reply
Sadly, they all look similar but do not match the address within the wallet.