Closed discoltk closed 7 years ago
@discoltk if you take a look into the code, you need to pass the 'magic byte' for testnet to that function to return testnet address from script
def script_to_address(script, vbyte=0):
if re.match('^[0-9a-fA-F]*$', script):
script = binascii.unhexlify(script)
if script[:3] == b'\x76\xa9\x14' and script[-2:] == b'\x88\xac' and len(script) == 25:
return bin_to_b58check(script[3:-2], vbyte) # pubkey hash addresses
else:
if vbyte in [111, 196]:
# Testnet
scripthash_byte = 196
...
@reiven Ah, yea now it makes sense. Saw the magic byte stuff but it didn't click (despite being obvious) that it was an argument I had to pass myself. Thanks!
ok great, you can now close this issue.
Maybe related to compressed vs uncompressed addresses, but this function returns mainnet looking addresses for my testnet transactions.