from electrum.bitcoin import pubkey_to_address from electrum.constants import BitcoinTestnet from electrum.keystore import BIP32Node # Mnemonic: combine defy review meadow hamster future sphere awake upper garbage aunt fish exact minute width # HD Path: m/49'/1'/0' xpub = 'upub5DiY8ttzMX33hN2pEFPvdhgucA32AQ58QnHw7Doy9jWDThfZK8RZL1rCkqUBgBLWyc8unNABCdqm6zPFXFiqNzBNQHqFMhXhenqHHAQxyNN' node = BIP32Node.from_xkey(xpub, net=BitcoinTestnet()) assert xpub == node.to_xkey(net=BitcoinTestnet()) first_addr_node = node.subkey_at_public_derivation("0/0") address = pubkey_to_address(txin_type='p2wpkh-p2sh', pubkey=first_addr_node.eckey.get_public_key_hex(), net=BitcoinTestnet()) assert address == '2NBo3VLe28bdX5frFojkJEC3yUT7bNri2VB'