diff --git a/electrum/daemon.py b/electrum/daemon.py index ad1c2a854..0db918c4b 100644 --- a/electrum/daemon.py +++ b/electrum/daemon.py @@ -319,12 +319,12 @@ class Daemon(DaemonThread): DaemonThread.stop(self) def init_gui(self, config, plugins): + threading.current_thread().setName('GUI') gui_name = config.get('gui', 'qt') if gui_name in ['lite', 'classic']: gui_name = 'qt' gui = __import__('electrum.gui.' + gui_name, fromlist=['electrum']) self.gui = gui.ElectrumGui(config, self, plugins) - threading.current_thread().setName('GUI') try: self.gui.main() except BaseException as e: diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py index 83f21cc25..885684ea1 100644 --- a/electrum/gui/qt/__init__.py +++ b/electrum/gui/qt/__init__.py @@ -97,6 +97,7 @@ class ElectrumGui(PrintError): QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts) if hasattr(QGuiApplication, 'setDesktopFileName'): QGuiApplication.setDesktopFileName('electrum.desktop') + self.gui_thread = threading.current_thread() self.config = config self.daemon = daemon self.plugins = plugins diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py index f22b7f6ae..aefd4e2cf 100644 --- a/electrum/gui/qt/history_list.py +++ b/electrum/gui/qt/history_list.py @@ -27,10 +27,12 @@ import webbrowser import datetime from datetime import date from typing import TYPE_CHECKING, Tuple, Dict +import threading from electrum.address_synchronizer import TX_HEIGHT_LOCAL from electrum.i18n import _ -from electrum.util import block_explorer_URL, profiler, print_error, TxMinedInfo +from electrum.util import (block_explorer_URL, profiler, print_error, TxMinedInfo, + PrintError) from .util import * @@ -67,7 +69,8 @@ class HistorySortModel(QSortFilterProxyModel): return False return item1.value() < item2.value() -class HistoryModel(QAbstractItemModel): +class HistoryModel(QAbstractItemModel, PrintError): + def __init__(self, parent): super().__init__(parent) self.parent = parent @@ -171,6 +174,8 @@ class HistoryModel(QAbstractItemModel): return self.parent.wallet.get_addresses() def refresh(self, reason: str): + self.print_error(f"refreshing... reason: {reason}") + assert self.parent.gui_thread == threading.current_thread(), 'must be called from GUI thread' selected = self.parent.history_list.selectionModel().currentIndex() selected_row = None if selected: @@ -288,7 +293,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): return True return False - def __init__(self, parent, model): + def __init__(self, parent, model: HistoryModel): super().__init__(parent, self.create_menu, 2) self.hm = model self.proxy = HistorySortModel(self) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 087e14e8a..f5a7b4207 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -114,6 +114,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.gui_object = gui_object self.config = config = gui_object.config # type: SimpleConfig + self.gui_thread = gui_object.gui_thread self.setup_exception_hook() diff --git a/electrum/wallet.py b/electrum/wallet.py index 64cbb80b9..0d58f44d3 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -45,7 +45,7 @@ from .util import (NotEnoughFunds, PrintError, UserCancelled, profiler, format_satoshis, format_fee_satoshis, NoDynamicFeeEstimates, WalletFileException, BitcoinException, InvalidPassword, format_time, timestamp_to_datetime, Satoshis, - Fiat, bfh, bh2u) + Fiat, bfh, bh2u, TxMinedInfo) from .bitcoin import (COIN, TYPE_ADDRESS, is_address, address_to_script, is_minikey, relayfee, dust_threshold) from .version import * @@ -523,11 +523,11 @@ class Abstract_Wallet(AddressSynchronizer): return ', '.join(labels) return '' - def get_tx_status(self, tx_hash, tx_mined_status): + def get_tx_status(self, tx_hash, tx_mined_info: TxMinedInfo): extra = [] - height = tx_mined_status.height - conf = tx_mined_status.conf - timestamp = tx_mined_status.timestamp + height = tx_mined_info.height + conf = tx_mined_info.conf + timestamp = tx_mined_info.timestamp if conf == 0: tx = self.transactions.get(tx_hash) if not tx: @@ -554,7 +554,7 @@ class Abstract_Wallet(AddressSynchronizer): elif height == TX_HEIGHT_UNCONFIRMED: status = 0 else: - status = 2 + status = 2 # not SPV verified else: status = 3 + min(conf, 6) time_str = format_time(timestamp) if timestamp else _("unknown")