From 747eb854267f83efdacaf7278f51a99c33036f75 Mon Sep 17 00:00:00 2001 From: Wizz Wallet <153743376+wizz-wallet-dev@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:43:30 +0800 Subject: [PATCH] Remove aliased address type functions to resolve the correct network (#216) --- electrumx/lib/script2addr.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/electrumx/lib/script2addr.py b/electrumx/lib/script2addr.py index 0c5b8d69..f13c6744 100644 --- a/electrumx/lib/script2addr.py +++ b/electrumx/lib/script2addr.py @@ -220,11 +220,11 @@ def hash_160(x: bytes) -> bytes: def hash160_to_p2pkh(h160: bytes) -> str: - return hash160_to_b58_address(h160, ADDRTYPE_P2PKH) + return hash160_to_b58_address(h160, get_addr_type_p2pkh()) def hash160_to_p2sh(h160: bytes) -> str: - return hash160_to_b58_address(h160, ADDRTYPE_P2SH) + return hash160_to_b58_address(h160, get_addr_type_p2sh()) def public_key_to_p2pkh(public_key: bytes) -> str: @@ -232,7 +232,7 @@ def public_key_to_p2pkh(public_key: bytes) -> str: def hash_to_segwit_addr(h: bytes, witver: int) -> str: - addr = segwit_addr.encode(SEGWIT_HRP, witver, h) + addr = segwit_addr.encode(get_segwit_hrp(), witver, h) assert addr is not None return addr @@ -273,11 +273,6 @@ def get_segwit_hrp(): return value -ADDRTYPE_P2PKH = get_addr_type_p2pkh() -ADDRTYPE_P2SH = get_addr_type_p2sh() -SEGWIT_HRP = get_segwit_hrp() - - def get_address_from_output_script(_bytes: bytes) -> Optional[str]: try: decoded = [x for x in script_GetOp(_bytes)]