From f70a996619e6b0cc956cb0b794b22df4cc43e6ec Mon Sep 17 00:00:00 2001 From: ThomasV Date: Tue, 9 Jun 2015 09:58:40 +0200 Subject: [PATCH] fix trezor initialiation hook (pass window in load_wallet) --- gui/qt/__init__.py | 5 ----- gui/qt/main_window.py | 5 ++--- lib/commands.py | 3 ++- lib/plugins.py | 2 +- plugins/btchipwallet.py | 2 +- plugins/cosigner_pool.py | 2 +- plugins/exchange_rate.py | 2 +- plugins/labels.py | 2 +- plugins/trezor.py | 17 ++++++++--------- plugins/trustedcoin.py | 2 +- 10 files changed, 18 insertions(+), 24 deletions(-) diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py index e0e33e075..16a432c64 100644 --- a/gui/qt/__init__.py +++ b/gui/qt/__init__.py @@ -73,9 +73,6 @@ class ElectrumGui: if app is None: self.app = QApplication(sys.argv) self.app.installEventFilter(self.efilter) - # let plugins know that we are using the qt gui - always_hook('init_qt_app', self.app) - def build_tray_menu(self): m = QMenu() @@ -105,8 +102,6 @@ class ElectrumGui: def close(self): self.current_window.close() - - def go_full(self): self.config.set_key('lite_mode', False, True) self.lite_window.hide() diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index ca35e22b8..636d83341 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -236,8 +236,7 @@ class ElectrumWindow(QMainWindow): self.clear_receive_tab() self.update_receive_tab() self.show() - run_hook('init_qt', self.gui_object) - run_hook('load_wallet', wallet) + run_hook('load_wallet', wallet, self) def import_old_contacts(self): # backward compatibility: import contacts @@ -2622,7 +2621,7 @@ class ElectrumWindow(QMainWindow): plugins[name] = p = module.Plugin(self.config, name) p.enable() p.wallet = self.wallet - p.load_wallet(self.wallet) + p.load_wallet(self.wallet, self) p.init_qt(self.gui_object) r = p.is_enabled() cb.setChecked(r) diff --git a/lib/commands.py b/lib/commands.py index e30fe4576..04930e3ae 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -525,7 +525,7 @@ class Commands: PR_PAID: 'Paid', PR_EXPIRED: 'Expired', } - out['amount'] = format_satoshis(out.get('amount')) + out['amount'] = format_satoshis(out.get('amount')) + ' BTC' out['status'] = pr_str[out.get('status', PR_UNKNOWN)] return out @@ -626,6 +626,7 @@ config_variables = { 'requests_dir': 'directory where a bip70 file will be written.', 'ssl_privkey': 'Path to your SSL private key, needed to sign the request.', 'ssl_chain': 'Chain of SSL certificates, needed for signed requests. Put your certificate at the top and the root CA at the end', + 'url_rewrite': 'Parameters passed to str.replace(), in order to create the r= part of bitcoin: URIs. Example: \"(\'file:///var/www/\',\'https://electrum.org/\')\"', }, 'listrequests':{ 'url_rewrite': 'Parameters passed to str.replace(), in order to create the r= part of bitcoin: URIs. Example: \"(\'file:///var/www/\',\'https://electrum.org/\')\"', diff --git a/lib/plugins.py b/lib/plugins.py index 4289dd936..d224a0849 100644 --- a/lib/plugins.py +++ b/lib/plugins.py @@ -169,7 +169,7 @@ class BasePlugin: def init_qt(self, gui): pass @hook - def load_wallet(self, wallet): pass + def load_wallet(self, wallet, window): pass @hook def close_wallet(self): pass diff --git a/plugins/btchipwallet.py b/plugins/btchipwallet.py index 0318c91bd..e51c9e407 100644 --- a/plugins/btchipwallet.py +++ b/plugins/btchipwallet.py @@ -73,7 +73,7 @@ class Plugin(BasePlugin): return True @hook - def load_wallet(self, wallet): + def load_wallet(self, wallet, window): if self.btchip_is_connected(): if not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your BTChip device"), _('OK')) diff --git a/plugins/cosigner_pool.py b/plugins/cosigner_pool.py index 984648bef..330af8be5 100644 --- a/plugins/cosigner_pool.py +++ b/plugins/cosigner_pool.py @@ -95,7 +95,7 @@ class Plugin(BasePlugin): return self.wallet.wallet_type in ['2of2', '2of3'] @hook - def load_wallet(self, wallet): + def load_wallet(self, wallet, window): self.wallet = wallet if not self.is_available(): return diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py index acb7c2500..508ac9f13 100644 --- a/plugins/exchange_rate.py +++ b/plugins/exchange_rate.py @@ -259,7 +259,7 @@ class Plugin(BasePlugin): return quote_text @hook - def load_wallet(self, wallet): + def load_wallet(self, wallet, window): tx_list = {} for item in self.wallet.get_history(self.wallet.storage.get("current_account", None)): tx_hash, conf, value, timestamp, balance = item diff --git a/plugins/labels.py b/plugins/labels.py index 7173ea21a..2a860fb9f 100644 --- a/plugins/labels.py +++ b/plugins/labels.py @@ -51,7 +51,7 @@ class Plugin(BasePlugin): self.window.connect(self.window, SIGNAL('labels:pulled'), self.on_pulled) @hook - def load_wallet(self, wallet): + def load_wallet(self, wallet, window): self.wallet = wallet self.wallet_nonce = self.wallet.storage.get("wallet_nonce") diff --git a/plugins/trezor.py b/plugins/trezor.py index 4cc37d72d..0d300b970 100644 --- a/plugins/trezor.py +++ b/plugins/trezor.py @@ -46,6 +46,7 @@ class Plugin(BasePlugin): self._is_available = self._init() self._requires_settings = True self.wallet = None + self.handler = None def constructor(self, s): return TrezorWallet(s) @@ -82,9 +83,6 @@ class Plugin(BasePlugin): return False return True - @hook - def add_plugin(self, wallet): - wallet.plugin = self @hook def close_wallet(self): @@ -94,17 +92,19 @@ class Plugin(BasePlugin): self.wallet.client.transport.close() self.wallet = None - @hook - def init_qt_app(self, app): - self.handler = TrezorQtHandler(app) - @hook def init_cmdline(self): self.handler = TrezorCmdLineHandler() @hook - def load_wallet(self, wallet): + def load_wallet(self, wallet, window): self.wallet = wallet + self.window = window + self.wallet.plugin = self + + if self.handler is None: + self.handler = TrezorQtHandler(self.window.app) + 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')) @@ -186,7 +186,6 @@ class TrezorWallet(BIP32_HD_Wallet): self.mpk = None self.device_checked = False self.force_watching_only = False - always_hook('add_plugin', self) def get_action(self): if not self.accounts: diff --git a/plugins/trustedcoin.py b/plugins/trustedcoin.py index 54d3b1122..95f12a197 100644 --- a/plugins/trustedcoin.py +++ b/plugins/trustedcoin.py @@ -322,7 +322,7 @@ class Plugin(BasePlugin): self.is_billing = False @hook - def load_wallet(self, wallet): + def load_wallet(self, wallet, window): self.trustedcoin_button = StatusBarButton( QIcon(":icons/trustedcoin.png"), _("Network"), self.settings_dialog) self.window.statusBar().addPermanentWidget(self.trustedcoin_button) self.xpub = self.wallet.master_public_keys.get('x1/')