From b9b08b768f1792fc0328eade5f9c63f9c0f4f6b0 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Wed, 3 Jun 2020 15:33:45 +0200 Subject: [PATCH] plugins/bitbox02: fix min version check Inform the user that they need to upgrade if their firmware version is out of date. The previous `check_device_firmware_version()` was dead code, and the bb02 function called inside also does not exist. --- electrum/plugins/bitbox02/bitbox02.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py index ce7c40119..fa6a57a12 100644 --- a/electrum/plugins/bitbox02/bitbox02.py +++ b/electrum/plugins/bitbox02/bitbox02.py @@ -33,6 +33,7 @@ try: HARDENED, u2fhid, bitbox_api_protocol, + FirmwareVersionOutdatedException, ) requirements_ok = True except ImportError: @@ -161,11 +162,17 @@ class BitBox02Client(HardwareClientBase): hid_device = hid.device() hid_device.open_path(self.bitbox_hid_info["path"]) - self.bitbox02_device = bitbox02.BitBox02( + + bitbox02_device = bitbox02.BitBox02( transport=u2fhid.U2FHid(hid_device), device_info=self.bitbox_hid_info, noise_config=NoiseConfig(), ) + try: + bitbox02_device.check_min_version() + except FirmwareVersionOutdatedException: + raise + self.bitbox02_device = bitbox02_device self.fail_if_not_initialized() @@ -176,13 +183,6 @@ class BitBox02Client(HardwareClientBase): "Please initialize the BitBox02 using the BitBox app first before using the BitBox02 in electrum" ) - def check_device_firmware_version(self) -> bool: - if self.bitbox02_device is None: - raise Exception( - "Need to setup communication first before attempting any BitBox02 calls" - ) - return self.bitbox02_device.check_firmware_version() - def coin_network_from_electrum_network(self) -> int: if constants.net.TESTNET: return bitbox02.btc.TBTC