From 796d52ac09189d92272f0b13506c8678d47c9da2 Mon Sep 17 00:00:00 2001 From: BTChip Date: Fri, 19 Sep 2014 15:51:10 +0200 Subject: [PATCH 1/2] Delegate firmware update and better error message when connection to the dongle fails --- plugins/btchipwallet.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/btchipwallet.py b/plugins/btchipwallet.py index 84d9feedf..dcc35d62a 100644 --- a/plugins/btchipwallet.py +++ b/plugins/btchipwallet.py @@ -27,6 +27,7 @@ try: from btchip.btchipUtils import compress_public_key,format_transaction, get_regular_input_script from btchip.bitcoinTransaction import bitcoinTransaction from btchip.btchipPersoWizard import StartBTChipPersoDialog + from btchip.btchipFirmwareWizard import updateFirmware from btchip.btchipException import BTChipException BTCHIP = True BTCHIP_DEBUG = False @@ -142,12 +143,16 @@ class BTChipWallet(NewWallet): d.setWaitImpl(DongleWaitQT(d)) self.client = btchip(d) firmware = self.client.getFirmwareVersion()['version'].split(".") - if int(firmware[0]) <> 1 or int(firmware[1]) <> 4: - aborted = True - raise Exception("Unsupported firmware version") - if int(firmware[2]) < 9: - aborted = True - raise Exception("Please update your firmware - 1.4.9 or higher is necessary") + if int(firmware[0]) <> 1 or int(firmware[1]) <> 4 or int(firmware[2]) < 9: + d.close() + try: + updateFirmware() + except Exception, e: + aborted = True + raise e + d = getDongle(BTCHIP_DEBUG) + d.setWaitImpl(DongleWaitQT(d)) + self.client = btchip(d) try: self.client.getOperationMode() except BTChipException, e: @@ -193,7 +198,7 @@ class BTChipWallet(NewWallet): pass self.client = None if not aborted: - raise Exception("Could not connect to your BTChip dongle. Please verify access permissions or PIN") + raise Exception("Could not connect to your BTChip dongle. Please verify access permissions, PIN, or unplug the dongle and plug it again") else: raise e self.client.bad = False From 2c096f966946dd60baaca1af56623c488015eb89 Mon Sep 17 00:00:00 2001 From: BTChip Date: Fri, 19 Sep 2014 16:02:09 +0200 Subject: [PATCH 2/2] Add firmware check --- plugins/btchipwallet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/btchipwallet.py b/plugins/btchipwallet.py index dcc35d62a..977f2af1b 100644 --- a/plugins/btchipwallet.py +++ b/plugins/btchipwallet.py @@ -27,7 +27,7 @@ try: from btchip.btchipUtils import compress_public_key,format_transaction, get_regular_input_script from btchip.bitcoinTransaction import bitcoinTransaction from btchip.btchipPersoWizard import StartBTChipPersoDialog - from btchip.btchipFirmwareWizard import updateFirmware + from btchip.btchipFirmwareWizard import checkFirmware, updateFirmware from btchip.btchipException import BTChipException BTCHIP = True BTCHIP_DEBUG = False @@ -143,7 +143,7 @@ class BTChipWallet(NewWallet): d.setWaitImpl(DongleWaitQT(d)) self.client = btchip(d) firmware = self.client.getFirmwareVersion()['version'].split(".") - if int(firmware[0]) <> 1 or int(firmware[1]) <> 4 or int(firmware[2]) < 9: + if (not checkFirmware(firmware)) or (int(firmware[0]) <> 1) or (int(firmware[1]) <> 4) or (int(firmware[2]) < 9): d.close() try: updateFirmware()