electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit dda4a0fcb3671a260cd5bee61ef83b747e179678
parent 9d40fb2ea8b347e08b4b64897537e2197d4325e3
Author: ThomasV <thomasv@gitorious>
Date:   Mon, 26 Jan 2015 20:42:32 +0100

call load_wallet and close_wallet for each plugin

Diffstat:
Mgui/qt/main_window.py | 9++++++++-
Mlib/plugins.py | 25+++++++++++++++----------
Mplugins/trezor.py | 2+-
3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -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: diff --git a/lib/plugins.py b/lib/plugins.py @@ -45,16 +45,17 @@ 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 - try: - r = f(*args) - except Exception: - print_error("Plugin error") - traceback.print_exc(file=sys.stdout) - r = False - if r: - results.append(r) + if p.is_enabled(): + try: + r = f(*args) + except Exception: + print_error("Plugin error") + traceback.print_exc(file=sys.stdout) + 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 diff --git a/plugins/trezor.py b/plugins/trezor.py @@ -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