From 53d6eeb3f3150425a3b3a40c341998a2bda39a41 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 8 Jun 2021 16:45:30 +0200 Subject: [PATCH] wallet: rm get_txout_address method --- electrum/address_synchronizer.py | 7 ++----- electrum/wallet.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py index 702ce6612..37fb3b71f 100644 --- a/electrum/address_synchronizer.py +++ b/electrum/address_synchronizer.py @@ -172,9 +172,6 @@ class AddressSynchronizer(Logger): return tx.outputs()[prevout_n].value return None - def get_txout_address(self, txo: TxOutput) -> Optional[str]: - return txo.address - def load_unverified_transactions(self): # review transactions that are in the history for addr in self.db.get_history(): @@ -271,7 +268,7 @@ class AddressSynchronizer(Logger): # it could happen that we think tx is unrelated but actually one of the inputs is is_mine. # this is the main motivation for allow_unrelated is_mine = any([self.is_mine(self.get_txin_address(txin)) for txin in tx.inputs()]) - is_for_me = any([self.is_mine(self.get_txout_address(txo)) for txo in tx.outputs()]) + is_for_me = any([self.is_mine(txo.address) for txo in tx.outputs()]) if not is_mine and not is_for_me: raise UnrelatedTransactionException() # Find all conflicting transactions. @@ -325,7 +322,7 @@ class AddressSynchronizer(Logger): ser = tx_hash + ':%d'%n scripthash = bitcoin.script_to_scripthash(txo.scriptpubkey.hex()) self.db.add_prevout_by_scripthash(scripthash, prevout=TxOutpoint.from_str(ser), value=v) - addr = self.get_txout_address(txo) + addr = txo.address if addr and self.is_mine(addr): self.db.add_txo_addr(tx_hash, addr, n, v, is_coinbase) self._get_addr_balance_cache.pop(addr, None) # invalidate cache diff --git a/electrum/wallet.py b/electrum/wallet.py index d29ef98bc..9f784ad8f 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -2232,7 +2232,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): def receive_tx_callback(self, tx_hash, tx, tx_height): super().receive_tx_callback(tx_hash, tx, tx_height) for txo in tx.outputs(): - addr = self.get_txout_address(txo) + addr = txo.address if addr in self.receive_requests: status = self.get_request_status(addr) util.trigger_callback('request_status', self, addr, status)