Invalid Addresses?
Closed this issue · 1 comments
MarcoDotIO commented
Hello there,
I am having some issues with creating valid Bitcoin addresses with the given SDK. Here is my test code:
from bitcoinlib.wallets import *
w1 = wallet_create_or_open(
name="test2",
network='testnet'
)
print("Wallet address: ", w1.get_key().address)
And any addresses from the get_key() function are not valid (e.g., they aren't prefixed with bc1 for mainnet, tb1 for testnet). Was something changed in a newer version?
Here's an example of the above output: mfvFzusKPZzGBAhS69AWvziRPjamtRhYpZ
MarcoDotIO commented
Update:
Seems like the documentation is out of date. Here's the way to derive valid bitcoin addresses:
from bitcoinlib.wallets import *
w1 = wallet_create_or_open(name="test2002", network='testnet')
pubkey = w1.get_key().key()
addr = Address("{pubkey}", encoding='bech32', script_type="p2wpkh", network="testnet")
print("Wallet address: ", addr.address)
Closing, but considering adding some additional documentation to clear things up.