qt: fix address dialog
(was showing full history, not just for addr)
This commit is contained in:
@@ -430,7 +430,7 @@ class AddressSynchronizer(Logger):
|
|||||||
return f
|
return f
|
||||||
|
|
||||||
@with_local_height_cached
|
@with_local_height_cached
|
||||||
def get_history(self, domain=None) -> Sequence[HistoryItem]:
|
def get_history(self, *, domain=None) -> Sequence[HistoryItem]:
|
||||||
# get domain
|
# get domain
|
||||||
if domain is None:
|
if domain is None:
|
||||||
domain = self.get_addresses()
|
domain = self.get_addresses()
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ class AddressHistoryModel(HistoryModel):
|
|||||||
def get_domain(self):
|
def get_domain(self):
|
||||||
return [self.address]
|
return [self.address]
|
||||||
|
|
||||||
|
def should_include_lightning_payments(self) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class AddressDialog(WindowModalDialog):
|
class AddressDialog(WindowModalDialog):
|
||||||
|
|
||||||
|
|||||||
@@ -252,9 +252,13 @@ class HistoryModel(QAbstractItemModel, Logger):
|
|||||||
self.parent.utxo_list.update()
|
self.parent.utxo_list.update()
|
||||||
|
|
||||||
def get_domain(self):
|
def get_domain(self):
|
||||||
'''Overridden in address_dialog.py'''
|
"""Overridden in address_dialog.py"""
|
||||||
return self.parent.wallet.get_addresses()
|
return self.parent.wallet.get_addresses()
|
||||||
|
|
||||||
|
def should_include_lightning_payments(self) -> bool:
|
||||||
|
"""Overridden in address_dialog.py"""
|
||||||
|
return True
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
def refresh(self, reason: str):
|
def refresh(self, reason: str):
|
||||||
self.logger.info(f"refreshing... reason: {reason}")
|
self.logger.info(f"refreshing... reason: {reason}")
|
||||||
@@ -268,7 +272,9 @@ class HistoryModel(QAbstractItemModel, Logger):
|
|||||||
if fx: fx.history_used_spot = False
|
if fx: fx.history_used_spot = False
|
||||||
wallet = self.parent.wallet
|
wallet = self.parent.wallet
|
||||||
self.set_visibility_of_columns()
|
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()):
|
if transactions == list(self.transactions.values()):
|
||||||
return
|
return
|
||||||
old_length = len(self.transactions)
|
old_length = len(self.transactions)
|
||||||
@@ -690,6 +696,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
|
|||||||
self.parent.show_message(_("Your wallet history has been successfully exported."))
|
self.parent.show_message(_("Your wallet history has been successfully exported."))
|
||||||
|
|
||||||
def do_export_history(self, file_name, is_csv):
|
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(),
|
hist = self.wallet.get_full_history(domain=self.hm.get_domain(),
|
||||||
from_timestamp=None,
|
from_timestamp=None,
|
||||||
to_timestamp=None,
|
to_timestamp=None,
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ class Abstract_Wallet(AddressSynchronizer):
|
|||||||
def balance_at_timestamp(self, domain, target_timestamp):
|
def balance_at_timestamp(self, domain, target_timestamp):
|
||||||
# we assume that get_history returns items ordered by block height
|
# we assume that get_history returns items ordered by block height
|
||||||
# we also assume that block timestamps are monotonic (which is false...!)
|
# we also assume that block timestamps are monotonic (which is false...!)
|
||||||
h = self.get_history(domain)
|
h = self.get_history(domain=domain)
|
||||||
balance = 0
|
balance = 0
|
||||||
for hist_item in h:
|
for hist_item in h:
|
||||||
balance = hist_item.balance
|
balance = hist_item.balance
|
||||||
@@ -496,8 +496,8 @@ class Abstract_Wallet(AddressSynchronizer):
|
|||||||
# return last balance
|
# return last balance
|
||||||
return balance
|
return balance
|
||||||
|
|
||||||
def get_onchain_history(self):
|
def get_onchain_history(self, *, domain=None):
|
||||||
for hist_item in self.get_history():
|
for hist_item in self.get_history(domain=domain):
|
||||||
yield {
|
yield {
|
||||||
'txid': hist_item.txid,
|
'txid': hist_item.txid,
|
||||||
'fee_sat': hist_item.fee,
|
'fee_sat': hist_item.fee,
|
||||||
@@ -584,15 +584,17 @@ class Abstract_Wallet(AddressSynchronizer):
|
|||||||
if self.lnworker:
|
if self.lnworker:
|
||||||
return self.lnworker.get_request(key)
|
return self.lnworker.get_request(key)
|
||||||
|
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
def get_full_history(self, fx=None):
|
def get_full_history(self, fx=None, *, onchain_domain=None, include_lightning=True):
|
||||||
transactions = OrderedDictWithIndex()
|
transactions = OrderedDictWithIndex()
|
||||||
onchain_history = self.get_onchain_history()
|
onchain_history = self.get_onchain_history(domain=onchain_domain)
|
||||||
for tx_item in onchain_history:
|
for tx_item in onchain_history:
|
||||||
txid = tx_item['txid']
|
txid = tx_item['txid']
|
||||||
transactions[txid] = tx_item
|
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):
|
for i, tx_item in enumerate(lightning_history):
|
||||||
txid = tx_item.get('txid')
|
txid = tx_item.get('txid')
|
||||||
|
|||||||
Reference in New Issue
Block a user