From 817f01593efe763b7860e7790ea72640b978988a Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 18 Sep 2019 10:46:54 -0300 Subject: [PATCH] call the correct method on is_valid_address --- lbry/tests/integration/test_account_commands.py | 16 ++++++++++++++++ torba/torba/client/baseledger.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lbry/tests/integration/test_account_commands.py b/lbry/tests/integration/test_account_commands.py index fa1270842..dc2d39b76 100644 --- a/lbry/tests/integration/test_account_commands.py +++ b/lbry/tests/integration/test_account_commands.py @@ -171,3 +171,19 @@ class AccountManagement(CommandTestCase): }) self.assertEqual(history[6]['value'], '0.0') self.assertEqual(history[7]['value'], '10.0') + + async def test_address_validation(self): + address = await self.daemon.jsonrpc_address_unused() + bad_address = address[0:20] + '9999999' + address[27:] + self.assertEqual(len(address), len(bad_address)) + self.assertNotEqual(bad_address, address) + with self.assertRaises(Exception) as send_error: + await self.daemon.jsonrpc_account_send('0.1', addresses=[bad_address]) + self.assertEqual(f"'{bad_address}' is not a valid address", send_error.exception.args[0]) + tx = await self.daemon.jsonrpc_account_send('0.1', addresses=[address]) + for output in tx.outputs: + if output.get_address(self.ledger) == bad_address: + self.fail("account") + elif output.get_address(self.ledger) == address: + return 'yay' + self.fail("account_send sent to bad address!") diff --git a/torba/torba/client/baseledger.py b/torba/torba/client/baseledger.py index 1db56885f..ae4882d52 100644 --- a/torba/torba/client/baseledger.py +++ b/torba/torba/client/baseledger.py @@ -161,7 +161,7 @@ class BaseLedger(metaclass=LedgerRegistry): @classmethod def is_valid_address(cls, address): - decoded = Base58.decode(address) + decoded = Base58.decode_check(address) return decoded[0] == cls.pubkey_address_prefix[0] @classmethod