call load_wallet and close_wallet for each plugin
This commit is contained in:
parent
9d40fb2ea8
commit
dda4a0fcb3
|
@ -203,6 +203,7 @@ class ElectrumWindow(QMainWindow):
|
|||
|
||||
def close_wallet(self):
|
||||
self.wallet.stop_threads()
|
||||
self.hide()
|
||||
run_hook('close_wallet')
|
||||
|
||||
def load_wallet(self, wallet):
|
||||
|
@ -210,13 +211,17 @@ class ElectrumWindow(QMainWindow):
|
|||
self.wallet = wallet
|
||||
self.update_wallet_format()
|
||||
# address used to create a dummy transaction and estimate transaction fee
|
||||
self.dummy_address = self.wallet.addresses(False)[0]
|
||||
a = self.wallet.addresses(False)
|
||||
self.dummy_address = a[0] if a else None
|
||||
|
||||
self.invoices = self.wallet.storage.get('invoices', {})
|
||||
self.accounts_expanded = self.wallet.storage.get('accounts_expanded',{})
|
||||
self.current_account = self.wallet.storage.get("current_account", None)
|
||||
title = 'Electrum ' + self.wallet.electrum_version + ' - ' + os.path.basename(self.wallet.storage.path)
|
||||
if self.wallet.is_watching_only(): title += ' [%s]' % (_('watching only'))
|
||||
self.setWindowTitle( title )
|
||||
self.update_history_tab()
|
||||
self.show()
|
||||
self.update_wallet()
|
||||
# Once GUI has been initialized check if we want to announce something since the callback has been called before the GUI was initialized
|
||||
self.notify_transactions()
|
||||
|
@ -308,6 +313,8 @@ class ElectrumWindow(QMainWindow):
|
|||
QMessageBox.critical(None, "Error", _("File exists"))
|
||||
return
|
||||
|
||||
if self.wallet:
|
||||
self.close_wallet()
|
||||
wizard = installwizard.InstallWizard(self.config, self.network, storage)
|
||||
wallet = wizard.run('new')
|
||||
if wallet:
|
||||
|
|
|
@ -45,8 +45,7 @@ def run_hook(name, *args):
|
|||
for p, f in f_list:
|
||||
if name == 'load_wallet':
|
||||
p.wallet = args[0]
|
||||
if not p.is_enabled():
|
||||
continue
|
||||
if p.is_enabled():
|
||||
try:
|
||||
r = f(*args)
|
||||
except Exception:
|
||||
|
@ -55,6 +54,8 @@ def run_hook(name, *args):
|
|||
r = False
|
||||
if r:
|
||||
results.append(r)
|
||||
if name == 'close_wallet':
|
||||
p.wallet = None
|
||||
|
||||
if results:
|
||||
assert len(results) == 1, results
|
||||
|
@ -92,8 +93,12 @@ class BasePlugin:
|
|||
|
||||
def init_qt(self, gui): pass
|
||||
|
||||
@hook
|
||||
def load_wallet(self, wallet): pass
|
||||
|
||||
@hook
|
||||
def close_wallet(self): pass
|
||||
|
||||
#def init(self): pass
|
||||
|
||||
def close(self): pass
|
||||
|
|
|
@ -93,7 +93,7 @@ class Plugin(BasePlugin):
|
|||
@hook
|
||||
def close_wallet(self):
|
||||
print_error("trezor: clear session")
|
||||
if self.wallet.client:
|
||||
if self.wallet and self.wallet.client:
|
||||
self.wallet.client.clear_session()
|
||||
|
||||
@hook
|
||||
|
|
Loading…
Reference in New Issue