diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index 18b0d46f9..73d065914 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -723,8 +723,10 @@ class Ledger(metaclass=LedgerRegistry): self.hash160_to_address(txi.txo_ref.txo.pubkey_hash) ) for txo in tx.outputs: - if txo.has_address: + if txo.is_pubkey_hash: addresses.add(self.hash160_to_address(txo.pubkey_hash)) + elif txo.is_script_hash: + addresses.add(self.hash160_to_script_address(txo.script_hash)) start = int(time.perf_counter()) while timeout and (int(time.perf_counter()) - start) <= timeout: if await self._wait_round(tx, height, addresses): diff --git a/lbry/wallet/transaction.py b/lbry/wallet/transaction.py index 6b0fef370..4624a1420 100644 --- a/lbry/wallet/transaction.py +++ b/lbry/wallet/transaction.py @@ -272,22 +272,30 @@ class Output(InputOutput): def id(self): return self.ref.id + @property + def is_pubkey_hash(self): + return 'pubkey_hash' in self.script.values + @property def pubkey_hash(self): return self.script.values['pubkey_hash'] + @property + def is_script_hash(self): + return 'script_hash' in self.script.values + @property def script_hash(self): return self.script.values['script_hash'] @property def has_address(self): - return 'pubkey_hash' in self.script.values + return self.is_pubkey_hash or self.is_script_hash def get_address(self, ledger): - if self.script.is_pay_pubkey_hash: + if self.is_pubkey_hash: return ledger.hash160_to_address(self.pubkey_hash) - elif self.script.is_pay_script_hash: + elif self.is_script_hash: return ledger.hash160_to_script_address(self.script_hash) def get_estimator(self, ledger): diff --git a/tests/integration/blockchain/test_wallet_commands.py b/tests/integration/blockchain/test_wallet_commands.py index f2b59ebd6..1cce4c6b5 100644 --- a/tests/integration/blockchain/test_wallet_commands.py +++ b/tests/integration/blockchain/test_wallet_commands.py @@ -61,7 +61,8 @@ class WalletCommands(CommandTestCase): self.assertEqual(await self.blockchain.get_balance(), '95.99973580') await self.assertBalance(self.account, '10.0') p2sh_address1 = await self.blockchain.get_new_address(self.blockchain.P2SH_SEGWIT_ADDRESS) - await self.account_send('2.0', p2sh_address1) + tx = await self.account_send('2.0', p2sh_address1) + self.assertEqual(tx['outputs'][0]['address'], p2sh_address1) self.assertEqual(await self.blockchain.get_balance(), '98.99973580') # +1 lbc for confirm block await self.assertBalance(self.account, '7.999877') await self.wallet_send('3.0', p2sh_address1) diff --git a/tests/integration/other/test_exchange_rate_manager.py b/tests/integration/other/test_exchange_rate_manager.py index 6f584bfc7..651b0088f 100644 --- a/tests/integration/other/test_exchange_rate_manager.py +++ b/tests/integration/other/test_exchange_rate_manager.py @@ -24,7 +24,7 @@ class TestExchangeRateManager(AsyncioTestCase): self.assertLessEqual(len(failures), 1, f"feed failures: {failures}. Please check exchange rate feeds!") lbc = manager.convert_currency('USD', 'LBC', Decimal('1.0')) self.assertGreaterEqual(lbc, 2.0) - self.assertLessEqual(lbc, 10.0) + self.assertLessEqual(lbc, 15.0) lbc = manager.convert_currency('BTC', 'LBC', Decimal('0.01')) self.assertGreaterEqual(lbc, 1_000) self.assertLessEqual(lbc, 4_000)