Skip to content

Commit 32564b0

Browse files
committed
fix len check in blech32 decode() in test framework
1 parent cfc4cca commit 32564b0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/functional/test_framework/liquid_addr.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,19 @@ def convertbits(data, frombits, tobits, pad=True):
8484

8585

8686
def decode(hrp, addr):
87-
"""Decode a segwit address."""
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+
8891
hrpgot, data = blech32_decode(addr)
8992
if hrpgot != hrp:
9093
return (None, None)
9194
decoded = convertbits(data[1:], 5, 8, False)
92-
if decoded is None or len(decoded) < 2 or len(decoded) > 40:
95+
if decoded is None or len(decoded) < 2 or len(decoded) > 40+33:
9396
return (None, None)
9497
if data[0] > 16:
9598
return (None, None)
96-
if data[0] == 0 and len(decoded) != 20 and len(decoded) != 32:
99+
if data[0] == 0 and len(decoded) != 20+33 and len(decoded) != 32+33:
97100
return (None, None)
98101
return (data[0], decoded)
99102

0 commit comments

Comments
 (0)