allows script addresses (beginning with r) to be used

This commit is contained in:
Lex Berezhny 2021-05-28 13:53:25 -04:00
parent 935adfb51a
commit 550ef9a1c4
2 changed files with 11 additions and 1 deletions

View file

@ -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):

View file

@ -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):