From ac2d4eb0efe856def0ee2327c5a1c6986bbaa762 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Sun, 4 Feb 2018 21:59:58 +0100 Subject: [PATCH] fix #3508 --- lib/base_wizard.py | 9 +++++++++ lib/plugins.py | 13 +++++++++---- plugins/ledger/ledger.py | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/base_wizard.py b/lib/base_wizard.py index b73e1953..ab18b761 100644 --- a/lib/base_wizard.py +++ b/lib/base_wizard.py @@ -234,6 +234,15 @@ class BaseWizard(object): self.plugin = self.plugins.get_plugin(name) try: self.plugin.setup_device(device_info, self, purpose) + except OSError as e: + self.show_error(_('We encountered an error while connecting to your device:') + + '\n' + str(e) + '\n' + + _('To try to fix this, we will now re-pair with your device.') + '\n' + + _('Please try again.')) + devmgr = self.plugins.device_manager + devmgr.unpair_id(device_info.device.id_) + self.choose_hw_device(purpose) + return except BaseException as e: self.show_error(str(e)) self.choose_hw_device(purpose) diff --git a/lib/plugins.py b/lib/plugins.py index e37fe08a..e94013a2 100644 --- a/lib/plugins.py +++ b/lib/plugins.py @@ -362,15 +362,20 @@ class DeviceMgr(ThreadJob, PrintError): if not xpub in self.xpub_ids: return _id = self.xpub_ids.pop(xpub) - client = self.client_lookup(_id) - self.clients.pop(client, None) - if client: - client.close() + self._close_client(_id) def unpair_id(self, id_): xpub = self.xpub_by_id(id_) if xpub: self.unpair_xpub(xpub) + else: + self._close_client(id_) + + def _close_client(self, id_): + client = self.client_lookup(id_) + self.clients.pop(client, None) + if client: + client.close() def pair_xpub(self, xpub, id_): with self.lock: diff --git a/plugins/ledger/ledger.py b/plugins/ledger/ledger.py index 4e181c4f..cf56ee97 100644 --- a/plugins/ledger/ledger.py +++ b/plugins/ledger/ledger.py @@ -172,6 +172,10 @@ class Ledger_Client(): raise Exception("Dongle is temporarily locked - please unplug it and replug it again") if ((e.sw & 0xFFF0) == 0x63c0): raise Exception("Invalid PIN - please unplug the dongle and plug it again before retrying") + if e.sw == 0x6f00 and e.message == 'Invalid channel': + # based on docs 0x6f00 might be a more general error, hence we also compare message to be sure + raise Exception("Invalid channel.\n" + "Please make sure that 'Browser support' is disabled on your device.") raise e def checkDevice(self):