From 5fafd34de74623b7c083cd3217272fd2abcedb9a Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 9 May 2018 19:08:21 +0200 Subject: [PATCH] don't offer recovery type choice for trezor T --- plugins/trezor/clientbase.py | 4 ++++ plugins/trezor/qt.py | 8 +++++--- plugins/trezor/trezor.py | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/trezor/clientbase.py b/plugins/trezor/clientbase.py index a8a423228..5a3d43b93 100644 --- a/plugins/trezor/clientbase.py +++ b/plugins/trezor/clientbase.py @@ -233,6 +233,10 @@ class TrezorClientBase(GuiMixin, PrintError): def atleast_version(self, major, minor=0, patch=0): return self.firmware_version() >= (major, minor, patch) + def get_trezor_model(self): + """Returns '1' for Trezor One, 'T' for Trezor T.""" + return self.features.model + @staticmethod def wrapper(func): '''Wrap methods to clear any message box they opened.''' diff --git a/plugins/trezor/qt.py b/plugins/trezor/qt.py index 34a6e7f5e..e6ecd6dca 100644 --- a/plugins/trezor/qt.py +++ b/plugins/trezor/qt.py @@ -181,7 +181,7 @@ class QtPlugin(QtPluginBase): if device_id: SettingsDialog(window, self, keystore, device_id).exec_() - def request_trezor_init_settings(self, wizard, method, device): + def request_trezor_init_settings(self, wizard, method, model): vbox = QVBoxLayout() next_enabled = True label = QLabel(_("Enter a label to name your device:")) @@ -251,7 +251,7 @@ class QtPlugin(QtPluginBase): vbox.addWidget(cb_phrase) # ask for recovery type (random word order OR matrix) - if method == TIM_RECOVER: + if method == TIM_RECOVER and not model == 'T': gb_rectype = QGroupBox() hbox_rectype = QHBoxLayout() gb_rectype.setLayout(hbox_rectype) @@ -271,13 +271,15 @@ class QtPlugin(QtPluginBase): bg_rectype.addButton(rb2) bg_rectype.setId(rb2, RECOVERY_TYPE_MATRIX) hbox_rectype.addWidget(rb2) + else: + bg_rectype = None wizard.exec_layout(vbox, next_enabled=next_enabled) if method in [TIM_NEW, TIM_RECOVER]: item = bg_numwords.checkedId() pin = cb_pin.isChecked() - recovery_type = bg_rectype.checkedId() + recovery_type = bg_rectype.checkedId() if bg_rectype else None else: item = ' '.join(str(clean_text(text)).split()) pin = str(pin.text()) diff --git a/plugins/trezor/trezor.py b/plugins/trezor/trezor.py index e5a310ae1..2ce3721d0 100644 --- a/plugins/trezor/trezor.py +++ b/plugins/trezor/trezor.py @@ -196,9 +196,12 @@ class TrezorPlugin(HW_PluginBase): (TIM_MNEMONIC, _("Upload a BIP39 mnemonic to generate the seed")), (TIM_PRIVKEY, _("Upload a master private key")) ] + devmgr = self.device_manager() + client = devmgr.client_by_id(device_id) + model = client.get_trezor_model() def f(method): import threading - settings = self.request_trezor_init_settings(wizard, method, self.device) + settings = self.request_trezor_init_settings(wizard, method, model) t = threading.Thread(target=self._initialize_device_safe, args=(settings, method, device_id, wizard, handler)) t.setDaemon(True) t.start()