Hello guys,
I am using Bitcoin python package for testing purposes (
https://pypi.org/project/bitcoin/)
The function I am calling is:
pubkey_to_address(pubkey)
Its returning a P2PKH address
I want to generate a P2SH address from the pubkey instead.
Function code:
def pubkey_to_address(pubkey, magicbyte=0):
if isinstance(pubkey, (list, tuple)):
pubkey = encode_pubkey(pubkey, 'bin')
if len(pubkey) in [66, 130]:
return bin_to_b58check(
bin_hash160(binascii.unhexlify(pubkey)), magicbyte)
return bin_to_b58check(bin_hash160(pubkey), magicbyte)
Have read that I need to change magicbyte to 5 instead of 0 but that is not doing everything else correct 100%, so need a hand with us. If anyone can help edit the code it would be helpful, its this line that needs editing I would think:
return bin_to_b58check(bin_hash160(binascii.unhexlify(pubkey)), magicbyte)