Browse Source

qt gui: more resilient startup

Example log:
app tries to auto-open to wallet "test_segwit_2", which has too new db version,
then user manually tries to open wallet "test_segwit_3" instead,
which opens okay but - immediately after - the process shuts down (due to line 383 -> line 458).
```
$ ./run_electrum -v --testnet -o
  0.59 | I | simple_config.SimpleConfig | electrum directory /home/user/.electrum/testnet
  0.59 | I | logging | Electrum version: 4.3.4 - https://electrum.org - https://github.com/spesmilo/electrum
  0.59 | I | logging | Python version: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]. On platform: Linux-5.15.0-58-generic-x86_64-with-glibc2.35
  0.59 | I | logging | Logging to file: /home/user/.electrum/testnet/logs/electrum_log_20230202T151759Z_220451.log
  0.59 | I | logging | Log filters: verbosity '*', verbosity_shortcuts ''
  0.59 | I | p/plugin.Plugins | registering hardware bitbox02: ('hardware', 'bitbox02', 'BitBox02')
  0.59 | I | p/plugin.Plugins | registering hardware coldcard: ('hardware', 'coldcard', 'Coldcard Wallet')
  0.59 | I | p/plugin.Plugins | registering hardware digitalbitbox: ('hardware', 'digitalbitbox', 'Digital Bitbox wallet')
  0.60 | I | p/plugin.Plugins | registering hardware jade: ('hardware', 'jade', 'Jade wallet')
  0.60 | I | p/plugin.Plugins | registering hardware keepkey: ('hardware', 'keepkey', 'KeepKey wallet')
  0.60 | I | p/plugin.Plugins | registering hardware ledger: ('hardware', 'ledger', 'Ledger wallet')
  1.74 | I | p/plugin.Plugins | loaded payserver
  1.74 | I | p/plugin.Plugins | registering hardware safe_t: ('hardware', 'safe_t', 'Safe-T mini wallet')
  1.74 | I | p/plugin.Plugins | registering hardware trezor: ('hardware', 'trezor', 'Trezor wallet')
  1.74 | I | p/plugin.Plugins | registering wallet type ('2fa', 'trustedcoin')
  1.74 | D | util.profiler | Plugins.__init__ 1.1522 sec
  1.74 | I | exchange_rate.FxThread | using exchange CoinGecko
  1.75 | D | util.profiler | Daemon.__init__ 0.0033 sec
  1.75 | I | daemon.Daemon | starting taskgroup.
  1.75 | I | daemon.Daemon | launching GUI: qt
  1.75 | I | gui.qt.ElectrumGui | Qt GUI starting up... Qt=5.15.3, PyQt=5.15.6
  1.75 | I | daemon.CommandsServer | now running and listening. socktype=unix, addr=/home/user/.electrum/testnet/daemon_rpc_socket
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
  2.04 | D | util.profiler | ElectrumGui.__init__ 0.2865 sec
  2.04 | I | storage.WalletStorage | wallet path /home/user/.electrum/testnet/wallets/test_segwit_2
  2.13 | I | storage.WalletStorage | wallet path /home/user/.electrum/testnet/wallets/test_segwit_2
  5.24 | E | gui.qt.ElectrumGui |
Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/gui/qt/__init__.py", line 354, in start_new_window
    wallet = self._start_wizard_to_select_or_create_wallet(path)
  File "/home/user/wspace/electrum/electrum/gui/qt/__init__.py", line 401, in _start_wizard_to_select_or_create_wallet
    db = WalletDB(storage.read(), manual_upgrades=False)
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 72, in __init__
    self.load_data(raw)
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 102, in load_data
    if not self.requires_upgrade():
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 153, in requires_upgrade
    return self.get_seed_version() < FINAL_SEED_VERSION
  File "/home/user/wspace/electrum/electrum/json_db.py", line 44, in wrapper
    return func(self, *args, **kwargs)
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1035, in get_seed_version
    raise WalletFileException('This version of Electrum is too old to open this wallet.\n'
electrum.util.WalletFileException: This version of Electrum is too old to open this wallet.
(highest supported storage version: 50, version of this file: 51)
  5.35 | I | storage.WalletStorage | wallet path /home/user/.electrum/testnet/wallets/wallet_20
  7.90 | I | storage.WalletStorage | wallet path /home/user/.electrum/testnet/wallets/test_segwit_3
  8.48 | D | util.profiler | WalletDB._load_transactions 0.0517 sec
  8.48 | D | util.profiler | AddressSynchronizer.load_local_history 0.0005 sec
  8.48 | D | util.profiler | AddressSynchronizer.check_history 0.0005 sec
  8.70 | D | util.profiler | AddressList.update 0.0000 sec
  9.00 | D | util.profiler | Deterministic_Wallet.try_detecting_internal_addresses_corruption 0.0223 sec
  9.01 | D | util.profiler | ElectrumWindow.load_wallet 0.0808 sec
  9.01 | I | daemon.Daemon | stop() entered. initiating shutdown
  9.01 | I | gui.qt.ElectrumGui | closing GUI
  9.01 | I | daemon.Daemon | stopping all wallets
  9.04 | I | storage.WalletStorage | saved /home/user/.electrum/testnet/wallets/test_segwit_3
  9.04 | D | util.profiler | WalletDB._write 0.0265 sec
  9.04 | I | daemon.Daemon | stopping network and taskgroup
  9.04 | I | daemon.Daemon | taskgroup stopped.
  9.04 | I | daemon.Daemon | removing lockfile
  9.04 | I | daemon.Daemon | stopped
  9.08 | I | p/plugin.Plugins | stopped
QThread: Destroyed while thread is still running
Aborted (core dumped)
```
master
SomberNight 3 years ago
parent
commit
dbd2e56e85
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 9
      electrum/gui/qt/__init__.py

9
electrum/gui/qt/__init__.py

@ -330,8 +330,11 @@ class ElectrumGui(BaseElectrumGui, Logger):
app_is_starting: bool = False,
force_wizard: bool = False,
) -> Optional[ElectrumWindow]:
'''Raises the window for the wallet if it is open. Otherwise
opens the wallet and creates a new window for it'''
"""Raises the window for the wallet if it is open.
Otherwise, opens the wallet and creates a new window for it.
Warning: the returned window might be for a completely different wallet
than the provided path, as we allow user interaction to change the path.
"""
wallet = None
# Try to open with daemon first. If this succeeds, there won't be a wizard at all
# (the wallet main window will appear directly).
@ -379,7 +382,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
path = self.config.get_fallback_wallet_path()
else:
path = os.path.join(wallet_dir, filename)
self.start_new_window(path, uri=None, force_wizard=True)
return self.start_new_window(path, uri=None, force_wizard=True)
return
window.bring_to_top()
window.setWindowState(window.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)

Loading…
Cancel
Save