fix plugins initialization
This commit is contained in:
parent
36a5e09532
commit
78ce20b0b8
|
@ -46,6 +46,9 @@ def run_hook(name, *args):
|
||||||
for p, f in f_list:
|
for p, f in f_list:
|
||||||
if name == 'load_wallet':
|
if name == 'load_wallet':
|
||||||
p.wallet = args[0]
|
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():
|
if name in SPECIAL_HOOKS or p.is_enabled():
|
||||||
try:
|
try:
|
||||||
r = f(*args)
|
r = f(*args)
|
||||||
|
|
|
@ -55,11 +55,13 @@ class Plugin(BasePlugin):
|
||||||
return TREZOR
|
return TREZOR
|
||||||
|
|
||||||
def is_available(self):
|
def is_available(self):
|
||||||
if self.wallet is None:
|
if not self._is_available:
|
||||||
return self._is_available
|
return False
|
||||||
if self.wallet.storage.get('wallet_type') == 'trezor':
|
if not self.wallet:
|
||||||
return True
|
return False
|
||||||
return False
|
if self.wallet.storage.get('wallet_type') != 'trezor':
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def requires_settings(self):
|
def requires_settings(self):
|
||||||
return self._requires_settings
|
return self._requires_settings
|
||||||
|
@ -70,11 +72,9 @@ class Plugin(BasePlugin):
|
||||||
def is_enabled(self):
|
def is_enabled(self):
|
||||||
if not self.is_available():
|
if not self.is_available():
|
||||||
return False
|
return False
|
||||||
|
if self.wallet.has_seed():
|
||||||
if not self.wallet or self.wallet.storage.get('wallet_type') == 'trezor':
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return self.wallet.storage.get('use_' + self.name) is True
|
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
return BasePlugin.enable(self)
|
return BasePlugin.enable(self)
|
||||||
|
@ -98,9 +98,6 @@ class Plugin(BasePlugin):
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def load_wallet(self, wallet):
|
def load_wallet(self, wallet):
|
||||||
self.wallet = wallet
|
|
||||||
if self.wallet.has_seed():
|
|
||||||
return
|
|
||||||
if self.trezor_is_connected():
|
if self.trezor_is_connected():
|
||||||
if not self.wallet.check_proper_device():
|
if 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'))
|
||||||
|
|
|
@ -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>"
|
+ _("For more information, visit") + " <a href=\"https://api.trustedcoin.com/#/electrum-help\">https://api.trustedcoin.com/#/electrum-help</a>"
|
||||||
|
|
||||||
def is_available(self):
|
def is_available(self):
|
||||||
if self.wallet is None:
|
if not self.wallet:
|
||||||
return True
|
return False
|
||||||
if self.wallet.storage.get('wallet_type') == '2fa':
|
if self.wallet.storage.get('wallet_type') == '2fa':
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -238,10 +238,6 @@ class Plugin(BasePlugin):
|
||||||
def is_enabled(self):
|
def is_enabled(self):
|
||||||
if not self.is_available():
|
if not self.is_available():
|
||||||
return False
|
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/'):
|
if self.wallet.master_private_keys.get('x2/'):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue