from bitcoinutils.setup import setup
from bitcoinutils.keys import PrivateKey
setup('testnet')
priv = PrivateKey() # generate a fresh key
addr = priv.get_public_key().get_segwit_address() # P2WPKH
print(addr.to_string()) # tb1q...
A low-level Bitcoin library that explains the thorny details as it goes — keys, all address types, transactions with every SIGHASH, timelocks and non-standard scripts. Used in MSc courses at the University of Nicosia and the Aristotle University of Thessaloniki.