From 550ef9a1c433dc83b0e83b33341a5409c035916c Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Fri, 28 May 2021 13:53:25 -0400 Subject: [PATCH] allows script addresses (beginning with r) to be used --- lbry/wallet/ledger.py | 5 ++++- tests/unit/wallet/test_ledger.py | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index fb1dd78b4..fc8decf57 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -185,7 +185,10 @@ class Ledger(metaclass=LedgerRegistry): @classmethod def is_valid_address(cls, address): decoded = Base58.decode_check(address) - return decoded[0] == cls.pubkey_address_prefix[0] + return ( + decoded[0] == cls.pubkey_address_prefix[0] or + decoded[0] == cls.script_address_prefix[0] + ) @classmethod def public_key_to_address(cls, public_key): diff --git a/tests/unit/wallet/test_ledger.py b/tests/unit/wallet/test_ledger.py index 276c5fa15..67f78f0aa 100644 --- a/tests/unit/wallet/test_ledger.py +++ b/tests/unit/wallet/test_ledger.py @@ -1,4 +1,5 @@ import os +from unittest import TestCase from binascii import hexlify from lbry.testcase import AsyncioTestCase @@ -85,6 +86,12 @@ class LedgerTestCase(AsyncioTestCase): self.ledger.headers._size = self.ledger.headers.io.seek(0, os.SEEK_END) // self.ledger.headers.header_size +class TestUtils(TestCase): + + def test_valid_address(self): + self.assertTrue(Ledger.is_valid_address("rCz6yb1p33oYHToGZDzTjX7nFKaU3kNgBd")) + + class TestSynchronization(LedgerTestCase): async def test_update_history(self):