Browse Source

bitcoin.address_to_scripthash: add net param (#7143)

closes #7141
patch-4
krzysobo 4 years ago
committed by GitHub
parent
commit
7ea7e7cec9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      electrum/bitcoin.py

5
electrum/bitcoin.py

@ -506,10 +506,11 @@ def address_to_hash(addr: str, *, net=None) -> Tuple[OnchainOutputType, bytes]:
raise BitcoinException(f"unknown address type: {addrtype}")
def address_to_scripthash(addr: str) -> str:
script = address_to_script(addr)
def address_to_scripthash(addr: str, *, net=None) -> str:
script = address_to_script(addr, net=net)
return script_to_scripthash(script)
def script_to_scripthash(script: str) -> str:
h = sha256(bfh(script))[0:32]
return bh2u(bytes(reversed(h)))

Loading…
Cancel
Save