mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 02:35:20 +00:00
qt history: minor clean-up and sanity checking
This commit is contained in:
parent
e023d8abdd
commit
48e119b59e
5 changed files with 17 additions and 10 deletions
|
@ -319,12 +319,12 @@ class Daemon(DaemonThread):
|
||||||
DaemonThread.stop(self)
|
DaemonThread.stop(self)
|
||||||
|
|
||||||
def init_gui(self, config, plugins):
|
def init_gui(self, config, plugins):
|
||||||
|
threading.current_thread().setName('GUI')
|
||||||
gui_name = config.get('gui', 'qt')
|
gui_name = config.get('gui', 'qt')
|
||||||
if gui_name in ['lite', 'classic']:
|
if gui_name in ['lite', 'classic']:
|
||||||
gui_name = 'qt'
|
gui_name = 'qt'
|
||||||
gui = __import__('electrum.gui.' + gui_name, fromlist=['electrum'])
|
gui = __import__('electrum.gui.' + gui_name, fromlist=['electrum'])
|
||||||
self.gui = gui.ElectrumGui(config, self, plugins)
|
self.gui = gui.ElectrumGui(config, self, plugins)
|
||||||
threading.current_thread().setName('GUI')
|
|
||||||
try:
|
try:
|
||||||
self.gui.main()
|
self.gui.main()
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
|
|
|
@ -97,6 +97,7 @@ class ElectrumGui(PrintError):
|
||||||
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts)
|
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts)
|
||||||
if hasattr(QGuiApplication, 'setDesktopFileName'):
|
if hasattr(QGuiApplication, 'setDesktopFileName'):
|
||||||
QGuiApplication.setDesktopFileName('electrum.desktop')
|
QGuiApplication.setDesktopFileName('electrum.desktop')
|
||||||
|
self.gui_thread = threading.current_thread()
|
||||||
self.config = config
|
self.config = config
|
||||||
self.daemon = daemon
|
self.daemon = daemon
|
||||||
self.plugins = plugins
|
self.plugins = plugins
|
||||||
|
|
|
@ -27,10 +27,12 @@ import webbrowser
|
||||||
import datetime
|
import datetime
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from typing import TYPE_CHECKING, Tuple, Dict
|
from typing import TYPE_CHECKING, Tuple, Dict
|
||||||
|
import threading
|
||||||
|
|
||||||
from electrum.address_synchronizer import TX_HEIGHT_LOCAL
|
from electrum.address_synchronizer import TX_HEIGHT_LOCAL
|
||||||
from electrum.i18n import _
|
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 *
|
from .util import *
|
||||||
|
|
||||||
|
@ -67,7 +69,8 @@ class HistorySortModel(QSortFilterProxyModel):
|
||||||
return False
|
return False
|
||||||
return item1.value() < item2.value()
|
return item1.value() < item2.value()
|
||||||
|
|
||||||
class HistoryModel(QAbstractItemModel):
|
class HistoryModel(QAbstractItemModel, PrintError):
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
@ -171,6 +174,8 @@ class HistoryModel(QAbstractItemModel):
|
||||||
return self.parent.wallet.get_addresses()
|
return self.parent.wallet.get_addresses()
|
||||||
|
|
||||||
def refresh(self, reason: str):
|
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 = self.parent.history_list.selectionModel().currentIndex()
|
||||||
selected_row = None
|
selected_row = None
|
||||||
if selected:
|
if selected:
|
||||||
|
@ -288,7 +293,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __init__(self, parent, model):
|
def __init__(self, parent, model: HistoryModel):
|
||||||
super().__init__(parent, self.create_menu, 2)
|
super().__init__(parent, self.create_menu, 2)
|
||||||
self.hm = model
|
self.hm = model
|
||||||
self.proxy = HistorySortModel(self)
|
self.proxy = HistorySortModel(self)
|
||||||
|
|
|
@ -114,6 +114,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
|
|
||||||
self.gui_object = gui_object
|
self.gui_object = gui_object
|
||||||
self.config = config = gui_object.config # type: SimpleConfig
|
self.config = config = gui_object.config # type: SimpleConfig
|
||||||
|
self.gui_thread = gui_object.gui_thread
|
||||||
|
|
||||||
self.setup_exception_hook()
|
self.setup_exception_hook()
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ from .util import (NotEnoughFunds, PrintError, UserCancelled, profiler,
|
||||||
format_satoshis, format_fee_satoshis, NoDynamicFeeEstimates,
|
format_satoshis, format_fee_satoshis, NoDynamicFeeEstimates,
|
||||||
WalletFileException, BitcoinException,
|
WalletFileException, BitcoinException,
|
||||||
InvalidPassword, format_time, timestamp_to_datetime, Satoshis,
|
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,
|
from .bitcoin import (COIN, TYPE_ADDRESS, is_address, address_to_script,
|
||||||
is_minikey, relayfee, dust_threshold)
|
is_minikey, relayfee, dust_threshold)
|
||||||
from .version import *
|
from .version import *
|
||||||
|
@ -523,11 +523,11 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||||
return ', '.join(labels)
|
return ', '.join(labels)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def get_tx_status(self, tx_hash, tx_mined_status):
|
def get_tx_status(self, tx_hash, tx_mined_info: TxMinedInfo):
|
||||||
extra = []
|
extra = []
|
||||||
height = tx_mined_status.height
|
height = tx_mined_info.height
|
||||||
conf = tx_mined_status.conf
|
conf = tx_mined_info.conf
|
||||||
timestamp = tx_mined_status.timestamp
|
timestamp = tx_mined_info.timestamp
|
||||||
if conf == 0:
|
if conf == 0:
|
||||||
tx = self.transactions.get(tx_hash)
|
tx = self.transactions.get(tx_hash)
|
||||||
if not tx:
|
if not tx:
|
||||||
|
@ -554,7 +554,7 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||||
elif height == TX_HEIGHT_UNCONFIRMED:
|
elif height == TX_HEIGHT_UNCONFIRMED:
|
||||||
status = 0
|
status = 0
|
||||||
else:
|
else:
|
||||||
status = 2
|
status = 2 # not SPV verified
|
||||||
else:
|
else:
|
||||||
status = 3 + min(conf, 6)
|
status = 3 + min(conf, 6)
|
||||||
time_str = format_time(timestamp) if timestamp else _("unknown")
|
time_str = format_time(timestamp) if timestamp else _("unknown")
|
||||||
|
|
Loading…
Add table
Reference in a new issue