tqt: fix address dialog - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 6a32187f01713b35dd2d20638773e3611f07d285 DIR parent a1d7d39f687c2dd6e7a1c812a589bab708b326cc HTML Author: SomberNight <somber.night@protonmail.com> Date: Sat, 21 Sep 2019 18:48:44 +0200 qt: fix address dialog (was showing full history, not just for addr) Diffstat: M electrum/address_synchronizer.py | 2 +- M electrum/gui/qt/address_dialog.py | 3 +++ M electrum/gui/qt/history_list.py | 11 +++++++++-- M electrum/wallet.py | 16 +++++++++------- 4 files changed, 22 insertions(+), 10 deletions(-) --- DIR diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py t@@ -430,7 +430,7 @@ class AddressSynchronizer(Logger): return f @with_local_height_cached - def get_history(self, domain=None) -> Sequence[HistoryItem]: + def get_history(self, *, domain=None) -> Sequence[HistoryItem]: # get domain if domain is None: domain = self.get_addresses() DIR diff --git a/electrum/gui/qt/address_dialog.py b/electrum/gui/qt/address_dialog.py t@@ -45,6 +45,9 @@ class AddressHistoryModel(HistoryModel): def get_domain(self): return [self.address] + def should_include_lightning_payments(self) -> bool: + return False + class AddressDialog(WindowModalDialog): DIR diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py t@@ -252,9 +252,13 @@ class HistoryModel(QAbstractItemModel, Logger): self.parent.utxo_list.update() def get_domain(self): - '''Overridden in address_dialog.py''' + """Overridden in address_dialog.py""" return self.parent.wallet.get_addresses() + def should_include_lightning_payments(self) -> bool: + """Overridden in address_dialog.py""" + return True + @profiler def refresh(self, reason: str): self.logger.info(f"refreshing... reason: {reason}") t@@ -268,7 +272,9 @@ class HistoryModel(QAbstractItemModel, Logger): if fx: fx.history_used_spot = False wallet = self.parent.wallet self.set_visibility_of_columns() - transactions = wallet.get_full_history(self.parent.fx) + transactions = wallet.get_full_history(self.parent.fx, + onchain_domain=self.get_domain(), + include_lightning=self.should_include_lightning_payments()) if transactions == list(self.transactions.values()): return old_length = len(self.transactions) t@@ -690,6 +696,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): self.parent.show_message(_("Your wallet history has been successfully exported.")) def do_export_history(self, file_name, is_csv): + # FIXME this is currently broken. hist = self.wallet.get_full_history(domain=self.hm.get_domain(), from_timestamp=None, to_timestamp=None, DIR diff --git a/electrum/wallet.py b/electrum/wallet.py t@@ -487,7 +487,7 @@ class Abstract_Wallet(AddressSynchronizer): def balance_at_timestamp(self, domain, target_timestamp): # we assume that get_history returns items ordered by block height # we also assume that block timestamps are monotonic (which is false...!) - h = self.get_history(domain) + h = self.get_history(domain=domain) balance = 0 for hist_item in h: balance = hist_item.balance t@@ -496,8 +496,8 @@ class Abstract_Wallet(AddressSynchronizer): # return last balance return balance - def get_onchain_history(self): - for hist_item in self.get_history(): + def get_onchain_history(self, *, domain=None): + for hist_item in self.get_history(domain=domain): yield { 'txid': hist_item.txid, 'fee_sat': hist_item.fee, t@@ -584,15 +584,17 @@ class Abstract_Wallet(AddressSynchronizer): if self.lnworker: return self.lnworker.get_request(key) - @profiler - def get_full_history(self, fx=None): + def get_full_history(self, fx=None, *, onchain_domain=None, include_lightning=True): transactions = OrderedDictWithIndex() - onchain_history = self.get_onchain_history() + onchain_history = self.get_onchain_history(domain=onchain_domain) for tx_item in onchain_history: txid = tx_item['txid'] transactions[txid] = tx_item - lightning_history = self.lnworker.get_history() if self.lnworker else [] + if self.lnworker and include_lightning: + lightning_history = self.lnworker.get_history() + else: + lightning_history = [] for i, tx_item in enumerate(lightning_history): txid = tx_item.get('txid')