From e1d0247ce406d457f8b64724cfd5fbb37a9b716b Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 12 Dec 2023 14:17:38 +0000 Subject: [PATCH] wallet: clarify difference between wallet.is_mine and adb.is_mine related https://github.com/spesmilo/electrum/pull/8699 --- electrum/address_synchronizer.py | 10 ++++++++-- electrum/wallet.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py index 74c7ee2e0..bf78878d5 100644 --- a/electrum/address_synchronizer.py +++ b/electrum/address_synchronizer.py @@ -110,8 +110,14 @@ class AddressSynchronizer(Logger, EventListener): self.remove_local_transactions_we_dont_have() def is_mine(self, address: Optional[str]) -> bool: - """Returns whether an address is in our set - Note: This class has a larget set of addresses than the wallet + """Returns whether an address is in our set. + + Differences between adb.is_mine and wallet.is_mine: + - adb.is_mine: addrs that we are watching (e.g. via Synchronizer) + - lnwatcher adds its own lightning-related addresses that are not part of the wallet + - wallet.is_mine: addrs that are part of the wallet balance or the wallet might sign for + - an offline wallet might learn from a PSBT about addrs beyond its gap limit + Neither set is guaranteed to be a subset of the other. """ if not address: return False return self.db.is_addr_in_history(address) diff --git a/electrum/wallet.py b/electrum/wallet.py index ba7d4fae5..fa8286772 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -3089,7 +3089,7 @@ class Abstract_Wallet(ABC, Logger, EventListener): for txin_idx, txin in enumerate(tx.inputs()): if txin.sighash and txin.sighash != Sighash.ALL: # non-standard addr = self.adb.get_txin_address(txin) - if self.adb.is_mine(addr): + if self.is_mine(addr): sh_out = txin.sighash & (Sighash.ANYONECANPAY ^ 0xff) sh_in = txin.sighash & Sighash.ANYONECANPAY confirm |= hintmap[sh_out][0] | hintmap[sh_in][0]