From 95a68b3a8a146de1b26d937cc27a2033b2552b1c Mon Sep 17 00:00:00 2001 From: zura Date: Wed, 16 Jun 2021 12:20:49 +0400 Subject: [PATCH 1/3] fixed incorrectly decoding cashaddr format addresses --- cashaddress/convert.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cashaddress/convert.py b/cashaddress/convert.py index 12bb758..ff8b1dd 100644 --- a/cashaddress/convert.py +++ b/cashaddress/convert.py @@ -106,11 +106,11 @@ def _cash_string(address_string): decoded = b32decode(base32string) if not verify_checksum(prefix, decoded): raise InvalidAddress('Bad cash address checksum') - converted = convertbits(decoded, 5, 8) + converted = convertbits(decoded[:-9], 5, 8) version = Address._address_type('cash', converted[0])[0] if prefix == Address.TESTNET_PREFIX: version += '-TESTNET' - payload = converted[1:-6] + payload = converted[1:] return Address(version, payload, prefix) From 4cc017c3b7e316afbebd38b39a8ca0782127df2b Mon Sep 17 00:00:00 2001 From: zura Date: Wed, 16 Jun 2021 15:53:47 +0400 Subject: [PATCH 2/3] fixed convertBits appending extra zero causing incorrect result --- cashaddress/convert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cashaddress/convert.py b/cashaddress/convert.py index ff8b1dd..2c2277a 100644 --- a/cashaddress/convert.py +++ b/cashaddress/convert.py @@ -106,7 +106,7 @@ def _cash_string(address_string): decoded = b32decode(base32string) if not verify_checksum(prefix, decoded): raise InvalidAddress('Bad cash address checksum') - converted = convertbits(decoded[:-9], 5, 8) + converted = convertbits(decoded[:-9], 5, 8, False) version = Address._address_type('cash', converted[0])[0] if prefix == Address.TESTNET_PREFIX: version += '-TESTNET' From a82f22ad68c4f95218bcc3ae94136c22968dcc0c Mon Sep 17 00:00:00 2001 From: zura Date: Wed, 16 Jun 2021 16:54:03 +0400 Subject: [PATCH 3/3] fixed typo --- cashaddress/convert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cashaddress/convert.py b/cashaddress/convert.py index 2c2277a..b2235b5 100644 --- a/cashaddress/convert.py +++ b/cashaddress/convert.py @@ -106,7 +106,7 @@ def _cash_string(address_string): decoded = b32decode(base32string) if not verify_checksum(prefix, decoded): raise InvalidAddress('Bad cash address checksum') - converted = convertbits(decoded[:-9], 5, 8, False) + converted = convertbits(decoded[:-8], 5, 8, False) version = Address._address_type('cash', converted[0])[0] if prefix == Address.TESTNET_PREFIX: version += '-TESTNET'