Browse Source

fix plugins initialization

283
ThomasV 10 years ago
parent
commit
78ce20b0b8
  1. 3
      lib/plugins.py
  2. 23
      plugins/trezor.py
  3. 8
      plugins/trustedcoin.py

3
lib/plugins.py

@ -46,6 +46,9 @@ def run_hook(name, *args):
for p, f in f_list:
if name == 'load_wallet':
p.wallet = args[0]
if name == 'init_qt':
gui = args[0]
p.window = gui.main_window
if name in SPECIAL_HOOKS or p.is_enabled():
try:
r = f(*args)

23
plugins/trezor.py

@ -55,11 +55,13 @@ class Plugin(BasePlugin):
return TREZOR
def is_available(self):
if self.wallet is None:
return self._is_available
if self.wallet.storage.get('wallet_type') == 'trezor':
return True
return False
if not self._is_available:
return False
if not self.wallet:
return False
if self.wallet.storage.get('wallet_type') != 'trezor':
return False
return True
def requires_settings(self):
return self._requires_settings
@ -70,11 +72,9 @@ class Plugin(BasePlugin):
def is_enabled(self):
if not self.is_available():
return False
if not self.wallet or self.wallet.storage.get('wallet_type') == 'trezor':
return True
return self.wallet.storage.get('use_' + self.name) is True
if self.wallet.has_seed():
return False
return True
def enable(self):
return BasePlugin.enable(self)
@ -98,9 +98,6 @@ class Plugin(BasePlugin):
@hook
def load_wallet(self, wallet):
self.wallet = wallet
if self.wallet.has_seed():
return
if self.trezor_is_connected():
if not self.wallet.check_proper_device():
QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK'))

8
plugins/trustedcoin.py

@ -223,8 +223,8 @@ class Plugin(BasePlugin):
+ _("For more information, visit") + " <a href=\"https://api.trustedcoin.com/#/electrum-help\">https://api.trustedcoin.com/#/electrum-help</a>"
def is_available(self):
if self.wallet is None:
return True
if not self.wallet:
return False
if self.wallet.storage.get('wallet_type') == '2fa':
return True
return False
@ -238,10 +238,6 @@ class Plugin(BasePlugin):
def is_enabled(self):
if not self.is_available():
return False
if not self.wallet:
return True
if self.wallet.storage.get('wallet_type') != '2fa':
return False
if self.wallet.master_private_keys.get('x2/'):
return False
return True

Loading…
Cancel
Save