Browse Source

qt: fix address dialog

(was showing full history, not just for addr)
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 5 years ago
parent
commit
6a32187f01
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/address_synchronizer.py
  2. 3
      electrum/gui/qt/address_dialog.py
  3. 11
      electrum/gui/qt/history_list.py
  4. 16
      electrum/wallet.py

2
electrum/address_synchronizer.py

@ -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()

3
electrum/gui/qt/address_dialog.py

@ -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):

11
electrum/gui/qt/history_list.py

@ -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}")
@ -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)
@ -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,

16
electrum/wallet.py

@ -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
@ -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,
@ -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')

Loading…
Cancel
Save