MCPcopy Create free account
hub / github.com/ElementsProject/elements / decode

Function decode

test/functional/test_framework/liquid_addr.py:86–101  ·  view source on GitHub ↗

Decode a segwit confidential address. Its payload is longer than the payload for unconfidential address by 33 bytes (the length of blinding pubkey)

(hrp, addr)

Source from the content-addressed store, hash-verified

84
85
86def decode(hrp, addr):
87 """Decode a segwit confidential address.
88 Its payload is longer than the payload for unconfidential address
89 by 33 bytes (the length of blinding pubkey)"""
90
91 hrpgot, data = blech32_decode(addr)
92 if hrpgot != hrp:
93 return (None, None)
94 decoded = convertbits(data[1:], 5, 8, False)
95 if decoded is None or len(decoded) < 2 or len(decoded) > 40+33:
96 return (None, None)
97 if data[0] > 16:
98 return (None, None)
99 if data[0] == 0 and len(decoded) != 20+33 and len(decoded) != 32+33:
100 return (None, None)
101 return (data[0], decoded)
102
103
104def encode(hrp, witver, witprog):

Callers 2

run_testMethod · 0.90
encodeFunction · 0.70

Calls 2

blech32_decodeFunction · 0.85
convertbitsFunction · 0.70

Tested by

no test coverage detected