MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / decode

Function decode

test/functional/test_framework/segwit_addr.py:87–99  ·  view source on GitHub ↗

Decode a segwit address.

(hrp, addr)

Source from the content-addressed store, hash-verified

85
86
87def decode(hrp, addr):
88 """Decode a segwit address."""
89 hrpgot, data = bech32_decode(addr)
90 if hrpgot != hrp:
91 return (None, None)
92 decoded = convertbits(data[1:], 5, 8, False)
93 if decoded is None or len(decoded) < 2 or len(decoded) > 40:
94 return (None, None)
95 if data[0] > 16:
96 return (None, None)
97 if data[0] == 0 and len(decoded) != 20 and len(decoded) != 32:
98 return (None, None)
99 return (data[0], decoded)
100
101
102def encode(hrp, witver, witprog):

Callers 1

encodeFunction · 0.85

Calls 2

bech32_decodeFunction · 0.85
convertbitsFunction · 0.85

Tested by

no test coverage detected