Last active
February 19, 2020 20:22
-
-
Save igorgue/7a029f67bcbcdeabfb880145698b6057 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment