Browse Source

plugins: call load_wallet in install wizard

283
ThomasV 10 years ago
parent
commit
060e3aa23e
  1. 2
      gui/qt/__init__.py
  2. 8
      gui/qt/installwizard.py
  3. 2
      gui/qt/main_window.py
  4. 2
      lib/plugins.py
  5. 3
      plugins/trezor.py

2
gui/qt/__init__.py

@ -153,7 +153,7 @@ class ElectrumGui:
QMessageBox.information(None, _('Warning'), _('The file was removed'), _('OK')) QMessageBox.information(None, _('Warning'), _('The file was removed'), _('OK'))
return return
return return
wizard = installwizard.InstallWizard(self.config, self.network, storage) wizard = installwizard.InstallWizard(self.config, self.network, storage, self.app)
wizard.show() wizard.show()
if action == 'new': if action == 'new':
action, wallet_type = wizard.restore_or_create() action, wallet_type = wizard.restore_or_create()

8
gui/qt/installwizard.py

@ -15,7 +15,7 @@ from amountedit import AmountEdit
import sys import sys
import threading import threading
from electrum.plugins import always_hook from electrum.plugins import always_hook, run_hook
from electrum.mnemonic import prepare_seed from electrum.mnemonic import prepare_seed
MSG_ENTER_ANYTHING = _("Please enter a wallet seed, a master public key, a list of Bitcoin addresses, or a list of private keys") MSG_ENTER_ANYTHING = _("Please enter a wallet seed, a master public key, a list of Bitcoin addresses, or a list of private keys")
@ -28,8 +28,9 @@ MSG_VERIFY_SEED = _("Your seed is important!") + "\n" + _("To make sure th
class InstallWizard(QDialog): class InstallWizard(QDialog):
def __init__(self, config, network, storage): def __init__(self, config, network, storage, app):
QDialog.__init__(self) QDialog.__init__(self)
self.app = app
self.config = config self.config = config
self.network = network self.network = network
self.storage = storage self.storage = storage
@ -345,6 +346,9 @@ class InstallWizard(QDialog):
# fixme: password is only needed for multiple accounts # fixme: password is only needed for multiple accounts
password = None password = None
# load wallet in plugins
run_hook('load_wallet', wallet, self)
while action is not None: while action is not None:
util.print_error("installwizard:", wallet, action) util.print_error("installwizard:", wallet, action)

2
gui/qt/main_window.py

@ -2635,7 +2635,7 @@ class ElectrumWindow(QMainWindow):
try: try:
cb = QCheckBox(descr['fullname']) cb = QCheckBox(descr['fullname'])
cb.setEnabled(is_available(name, self.wallet)) cb.setEnabled(is_available(name, self.wallet))
cb.setChecked(p is not None) cb.setChecked(p is not None and p.is_enabled())
grid.addWidget(cb, i, 0) grid.addWidget(cb, i, 0)
if p and p.requires_settings(): if p and p.requires_settings():
w = p.settings_widget(self) w = p.settings_widget(self)

2
lib/plugins.py

@ -63,9 +63,11 @@ def init_plugins(config, is_local, gui_name):
def constructor(name, storage): def constructor(name, storage):
if plugins.get(name) is None: if plugins.get(name) is None:
try: try:
print_error(_("Loading plugin by constructor:"), name)
p = loader(name) p = loader(name)
plugins[name] = p.Plugin(config, name) plugins[name] = p.Plugin(config, name)
except: except:
print_msg(_("Error: cannot initialize plugin"), name)
return return
return plugins[name].constructor(storage) return plugins[name].constructor(storage)

3
plugins/trezor.py

@ -98,6 +98,7 @@ class Plugin(BasePlugin):
@hook @hook
def load_wallet(self, wallet, window): def load_wallet(self, wallet, window):
self.print_error("load_wallet")
self.wallet = wallet self.wallet = wallet
self.window = window self.window = window
self.wallet.plugin = self self.wallet.plugin = self
@ -106,7 +107,7 @@ class Plugin(BasePlugin):
self.handler = TrezorQtHandler(self.window.app) self.handler = TrezorQtHandler(self.window.app)
if self.trezor_is_connected(): if self.trezor_is_connected():
if not self.wallet.check_proper_device(): if self.wallet.addresses() and not self.wallet.check_proper_device():
QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK'))
self.wallet.force_watching_only = True self.wallet.force_watching_only = True
else: else:

Loading…
Cancel
Save