I want to get all the addresses associated with my extended public key. I found how to do this on bitcoinlib's docs:
Initialize an Address object. Specify a public key, redeemscript or a hash.
>>> addr = Address('03715219f51a2681b7642d1e0e35f61e5288ff59b87d275be9eaf1a5f481dcdeb6', encoding='bech32', script_type='p2wsh') >>> addr.address 'bc1qaehsuffn0stxmugx3z69z9hm6gnjd9qzeqlfv92cpf5adw63x4tsfl7vwl'
However I'm having issues getting Address()
function to work, since my code:
from bitcoin import * # using import * because not sure what else to import?
master = Address("my extended pub key", encoding='bech32', script_type='p2wpkh')
print(master.address)
Produces this error:
NameError: name 'Address' is not defined
from bitcoin import *
Using import *
is not a good practice. Not only does this import stuff that you don't need and you don't know what exactly it imports, it also does not import what you do need in this case.
According to the documentation you have linked, you need to use this import statement:
from bitcoinlib.keys import Address