electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 8b2eb83238905fdbc781f042b8912ba9d7f45f37
parent 55b5335ebb2cdfac488203b5048e17a615d08a30
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri, 16 Oct 2020 21:10:32 +0200

wallet: use get_txin_value in get_wallet_delta

Diffstat:
Melectrum/address_synchronizer.py | 19++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py @@ -144,11 +144,16 @@ class AddressSynchronizer(Logger): return tx.outputs()[prevout_n].address return None - def get_txin_value(self, txin: TxInput) -> Optional[int]: + def get_txin_value(self, txin: TxInput, *, address: str = None) -> Optional[int]: if txin.value_sats() is not None: return txin.value_sats() prevout_hash = txin.prevout.txid.hex() prevout_n = txin.prevout.out_idx + if address: + d = self.db.get_txo_addr(prevout_hash, address) + for n, v, cb in d: + if n == txin.prevout.out_idx: + return v tx = self.db.get_transaction(prevout_hash) if tx: return tx.outputs()[prevout_n].value @@ -670,7 +675,7 @@ class AddressSynchronizer(Logger): def get_wallet_delta(self, tx: Transaction): """ effect of tx on wallet """ is_relevant = False # "related to wallet?" - is_mine = False + is_mine = False # "is any input mine?" is_pruned = False is_partial = False v_in = v_out = v_out_mine = 0 @@ -679,15 +684,7 @@ class AddressSynchronizer(Logger): if self.is_mine(addr): is_mine = True is_relevant = True - d = self.db.get_txo_addr(txin.prevout.txid.hex(), addr) - for n, v, cb in d: - if n == txin.prevout.out_idx: - value = v - break - else: - value = None - if value is None: - value = txin.value_sats() + value = self.get_txin_value(txin, address=addr) if value is None: is_pruned = True else: