def perform_hw1_preflight(self): try: ver = self.dongleObject.getFirmwareVersion() firmware = ver['version'].split(".") self.canAlternateCoinVersions = (ver['specialVersion'] >= 0x20 and map(int, firmware) >= [1, 0, 1]) if not checkFirmware(firmware): self.dongleObject.dongle.close() raise Exception("HW1 firmware version too old. Please update at https://www.ledgerwallet.com") try: self.dongleObject.getOperationMode() except BTChipException, e: if (e.sw == 0x6985): self.dongleObject.dongle.close() self.handler.get_setup( ) # Acquire the new client on the next run else: raise e if self.has_detached_pin_support(self.dongleObject) and not self.is_pin_validated(self.dongleObject) and (self.handler <> None): remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts() if remaining_attempts <> 1: msg = "Enter your Ledger PIN - remaining attempts : " + str(remaining_attempts) else: msg = "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception('Aborted by user - please unplug the dongle and plug it again before retrying') pin = pin.encode() self.dongleObject.verifyPin(pin) if self.canAlternateCoinVersions: self.dongleObject.setAlternateCoinVersions(48, 5)
def get_client(self, noPin=False): if not BTCHIP: self.give_error('please install github.com/btchip/btchip-python') aborted = False if not self.client or self.client.bad: try: d = getDongle(BTCHIP_DEBUG) d.setWaitImpl(DongleWaitQT(d)) self.client = btchip(d) ver = self.client.getFirmwareVersion() firmware = ver['version'].split(".") self.canAlternateCoinVersions = (ver['specialVersion'] >= 0x20 and map(int, firmware) >= [1, 0, 1]) if not checkFirmware(firmware): 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: if (e.sw == 0x6985): d.close() dialog = StartBTChipPersoDialog() dialog.exec_() # Then fetch the reference again as it was invalidated d = getDongle(BTCHIP_DEBUG) d.setWaitImpl(DongleWaitQT(d)) self.client = btchip(d) else: raise e if not noPin: # Immediately prompts for the PIN remaining_attempts = self.client.getVerifyPinRemainingAttempts() if remaining_attempts <> 1: msg = "Enter your BTChip PIN - remaining attempts : " + str(remaining_attempts) else: msg = "Enter your BTChip PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: aborted = True raise Exception('Aborted by user - please unplug the dongle and plug it again before retrying') pin = pin.encode() self.client.verifyPin(pin) if self.canAlternateCoinVersions: self.client.setAlternateCoinVersions(48, 5)
def get_client(self, noPin=False): if not BTCHIP: self.give_error("please install github.com/btchip/btchip-python") aborted = False if not self.client or self.client.bad: try: d = getDongle(BTCHIP_DEBUG) self.client = btchip(d) self.client.handler = self.plugin.handler firmware = self.client.getFirmwareVersion()["version"].split(".") if not checkFirmware(firmware): d.close() try: updateFirmware() except Exception, e: aborted = True raise e d = getDongle(BTCHIP_DEBUG) self.client = btchip(d) try: self.client.getOperationMode() except BTChipException, e: if e.sw == 0x6985: d.close() dialog = StartBTChipPersoDialog() dialog.exec_() # Then fetch the reference again as it was invalidated d = getDongle(BTCHIP_DEBUG) self.client = btchip(d) else: raise e if not noPin: # Immediately prompts for the PIN remaining_attempts = self.client.getVerifyPinRemainingAttempts() if remaining_attempts <> 1: msg = "Enter your BTChip PIN - remaining attempts : " + str(remaining_attempts) else: msg = "Enter your BTChip PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: aborted = True raise Exception("Aborted by user - please unplug the dongle and plug it again before retrying") pin = pin.encode() self.client.verifyPin(pin)
def perform_hw1_preflight(self): try: firmwareInfo = self.dongleObject.getFirmwareVersion() firmware = firmwareInfo['version'] self.multiOutputSupported = versiontuple(firmware) >= versiontuple(MULTI_OUTPUT_SUPPORT) self.canAlternateCoinVersions = (versiontuple(firmware) >= versiontuple(ALTERNATIVE_COIN_VERSION) and firmwareInfo['specialVersion'] >= 0x20) if not checkFirmware(firmwareInfo): self.dongleObject.dongle.close() raise Exception(MSG_NEEDS_FW_UPDATE_GENERIC) try: self.dongleObject.getOperationMode() except BTChipException as e: if (e.sw == 0x6985): self.dongleObject.dongle.close() self.handler.get_setup( ) # Acquire the new client on the next run else: raise e if self.has_detached_pin_support(self.dongleObject) and not self.is_pin_validated(self.dongleObject) and (self.handler is not None): remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts() if remaining_attempts != 1: msg = "Enter your Ledger PIN - remaining attempts : " + str(remaining_attempts) else: msg = "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception('Aborted by user - please unplug the dongle and plug it again before retrying') pin = pin.encode() self.dongleObject.verifyPin(pin) if self.canAlternateCoinVersions: self.dongleObject.setAlternateCoinVersions(constants.net.ADDRTYPE_P2PKH, constants.net.ADDRTYPE_P2SH) except BTChipException as e: if (e.sw == 0x6faa): 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 get_client(self, wallet, noPin=False): aborted = False client = self.client if not client or client.bad: try: d = getDongle(BTCHIP_DEBUG) client = btchip(d) firmware = client.getFirmwareVersion()['version'].split(".") if not checkFirmware(firmware): d.close() try: updateFirmware() except Exception, e: aborted = True raise e d = getDongle(BTCHIP_DEBUG) client = btchip(d) try: client.getOperationMode() except BTChipException, e: if (e.sw == 0x6985): d.close() dialog = StartBTChipPersoDialog() dialog.exec_() # Then fetch the reference again as it was invalidated d = getDongle(BTCHIP_DEBUG) client = btchip(d) else: raise e if not noPin: # Immediately prompts for the PIN remaining_attempts = client.getVerifyPinRemainingAttempts() if remaining_attempts <> 1: msg = "Enter your Ledger PIN - remaining attempts : " + str(remaining_attempts) else: msg = "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = wallet.password_dialog(msg) if not confirmed: aborted = True raise Exception('Aborted by user - please unplug the dongle and plug it again before retrying') pin = pin.encode() client.verifyPin(pin)
def perform_hw1_preflight(self): try: firmwareInfo = self.dongleObject.getFirmwareVersion() firmware = firmwareInfo['version'].split(".") self.multiOutputSupported = int(firmware[0]) >= 1 and int(firmware[1]) >= 1 and int(firmware[2]) >= 4 self.segwitSupported = (int(firmware[0]) >= 1 and int(firmware[1]) >= 1 and int(firmware[2]) >= 10) or (firmwareInfo['specialVersion'] == 0x20 and int(firmware[0]) == 1 and int(firmware[1]) == 0 and int(firmware[2]) >= 4) self.nativeSegwitSupported = int(firmware[0]) >= 1 and int(firmware[1]) >= 1 and int(firmware[2]) >= 10 if not checkFirmware(firmware): self.dongleObject.dongle.close() raise Exception(MSG_NEEDS_FW_UPDATE_GENERIC) try: self.dongleObject.getOperationMode() except BTChipException as e: if (e.sw == 0x6985): self.dongleObject.dongle.close() self.handler.get_setup( ) # Acquire the new client on the next run else: raise e if self.has_detached_pin_support(self.dongleObject) and not self.is_pin_validated(self.dongleObject) and (self.handler is not None): remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts() if remaining_attempts != 1: msg = "Enter your Ledger PIN - remaining attempts : " + str(remaining_attempts) else: msg = "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception('Aborted by user - please unplug the dongle and plug it again before retrying') pin = pin.encode() self.dongleObject.verifyPin(pin) except BTChipException as e: if (e.sw == 0x6faa): 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") raise e
def perform_hw1_preflight(self): try: firmware = self.dongleObject.getFirmwareVersion()['version'].split( ".") self.multiOutputSupported = int(firmware[0]) >= 1 and int( firmware[1]) >= 1 and int(firmware[2]) >= 4 if not checkFirmware(firmware): self.dongleObject.dongle.close() raise Exception( "HW1 firmware version too old. Please update at https://www.ledgerwallet.com" ) try: self.dongleObject.getOperationMode() except BTChipException, e: if (e.sw == 0x6985): self.dongleObject.dongle.close() self.handler.get_setup() # Acquire the new client on the next run else: raise e if self.has_detached_pin_support( self.dongleObject) and not self.is_pin_validated( self.dongleObject) and (self.handler <> None): remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts( ) if remaining_attempts <> 1: msg = "Enter your Ledger PIN - remaining attempts : " + str( remaining_attempts) else: msg = "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception( 'Aborted by user - please unplug the dongle and plug it again before retrying' ) pin = pin.encode() self.dongleObject.verifyPin(pin)
def perform_hw1_preflight(self): try: firmwareInfo = self.dongleObject.getFirmwareVersion() firmware = firmwareInfo['version'].split(".") self.multiOutputSupported = int(firmware[0]) >= 1 and int(firmware[1]) >= 1 and int(firmware[2]) >= 4 self.segwitSupported = (int(firmware[0]) >= 1 and int(firmware[1]) >= 1 and int(firmware[2]) >= 10) or (firmwareInfo['specialVersion'] == 0x20 and int(firmware[0]) == 1 and int(firmware[1]) == 0 and int(firmware[2]) >= 4) self.nativeSegwitSupported = int(firmware[0]) >= 1 and int(firmware[1]) >= 1 and int(firmware[2]) >= 10 if not checkFirmware(firmware): self.dongleObject.dongle.close() raise Exception("HW1 firmware version too old. Please update at https://www.ledgerwallet.com") try: self.dongleObject.getOperationMode() except BTChipException as e: if (e.sw == 0x6985): self.dongleObject.dongle.close() self.handler.get_setup( ) # Acquire the new client on the next run else: raise e if self.has_detached_pin_support(self.dongleObject) and not self.is_pin_validated(self.dongleObject) and (self.handler is not None): remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts() if remaining_attempts != 1: msg = "Enter your Ledger PIN - remaining attempts : " + str(remaining_attempts) else: msg = "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception('Aborted by user - please unplug the dongle and plug it again before retrying') pin = pin.encode() self.dongleObject.verifyPin(pin) except BTChipException as e: if (e.sw == 0x6faa): 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") raise e
def perform_hw1_preflight(self): try: firmwareInfo = self.dongleObject.getFirmwareVersion() firmware = firmwareInfo['version'] self.multiOutputSupported = versiontuple(firmware) >= versiontuple( MULTI_OUTPUT_SUPPORT) self.overwinterSupported = versiontuple(firmware) >= versiontuple( OVERWINTER_SUPPORT) self.canAlternateCoinVersions = ( versiontuple(firmware) >= versiontuple(ALTERNATIVE_COIN_VERSION) and firmwareInfo['specialVersion'] >= 0x20) if not checkFirmware(firmwareInfo): self.dongleObject.dongle.close() raise Exception(MSG_NEEDS_FW_UPDATE_GENERIC) try: self.dongleObject.getOperationMode() except BTChipException as e: if (e.sw == 0x6985): self.dongleObject.dongle.close() self.handler.get_setup() # Acquire the new client on the next run else: raise e if self.has_detached_pin_support( self.dongleObject) and not self.is_pin_validated( self.dongleObject) and (self.handler is not None): remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts( ) if remaining_attempts != 1: msg = "Enter your Ledger PIN - remaining attempts : " + str( remaining_attempts) else: msg = "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception( 'Aborted by user - please unplug the dongle and plug it again before retrying' ) pin = pin.encode() self.dongleObject.verifyPin(pin) if self.canAlternateCoinVersions: self.dongleObject.setAlternateCoinVersions( constants.net.ADDRTYPE_P2PKH, constants.net.ADDRTYPE_P2SH) except BTChipException as e: if (e.sw == 0x6faa): 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 perform_hw1_preflight(self): try: firmwareInfo = self.dongleObject.getFirmwareVersion() firmwareVersion = versiontuple(firmwareInfo['version']) self.bitcoinCashSupported = firmwareVersion >= BITCOIN_CASH_SUPPORT or \ self.is_hw1() and firmwareVersion >= BITCOIN_CASH_SUPPORT_HW1 self.cashaddrFWSupported = firmwareVersion >= CASHADDR_SUPPORT self.multiOutputSupported = firmwareVersion >= MULTI_OUTPUT_SUPPORT self.trustedInputsRequired = firmwareVersion >= TRUSTED_INPUTS_REQUIRED if not checkFirmware( firmwareInfo) or not self.supports_bitcoin_cash(): self.close() raise Exception( _("{} firmware version too old. Please update at https://www.ledgerwallet.com" ).format(self.device)) try: self.dongleObject.getOperationMode() except BTChipException as e: if (e.sw == 0x6985): self.close() self.handler.get_setup() # Acquire the new client on the next run else: raise e if self.has_detached_pin_support( self.dongleObject) and not self.is_pin_validated( self.dongleObject) and (self.handler is not None): remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts( ) if remaining_attempts != 1: msg = _( 'Enter your {} PIN - remaining attempts: {}').format( self.device, remaining_attempts) else: msg = _( 'Enter your {} PIN - WARNING: LAST ATTEMPT. If the PIN is not correct, the {} will be wiped.' ).format(self.device, self.device) confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception( _('Aborted by user - please unplug the {hw_device_name} and plug it in again before retrying' ).format(hw_device_name=self.device)) pin = pin.encode() self.dongleObject.verifyPin(pin) gwpkArgSpecs = inspect.getfullargspec( self.dongleObject.getWalletPublicKey) self.cashaddrSWSupported = 'cashAddr' in gwpkArgSpecs.args except BTChipException as e: if (e.sw == 0x6faa): raise Exception( _("{hw_device_name} is temporarily locked - please unplug and plug it in again." "\n\nIf this problem persists please exit and restart the Bitcoin Cash " "application running on the device.\n\nYou may also need to re-open this " "wallet window as well.").format( hw_device_name=self.device)) from e if ((e.sw & 0xFFF0) == 0x63c0): raise Exception( _('Invalid PIN - please unplug the {hw_device_name} and plug it in again before retrying' ).format(hw_device_name=self.device)) from e 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 {}.' ).format(self.device)) from e raise e
def perform_hw1_preflight(self): try: firmwareInfo = self.dongleObject.getFirmwareVersion() firmware = firmwareInfo['version'] self.bitcoinCashSupported = versiontuple(firmware) >= BITCOIN_CASH_SUPPORT or \ self.is_hw1() and versiontuple(firmware) >= BITCOIN_CASH_SUPPORT_HW1 self.cashaddrFWSupported = versiontuple( firmware) >= CASHADDR_SUPPORT if not checkFirmware( firmwareInfo) or not self.supports_bitcoin_cash(): self.dongleObject.dongle.close() raise Exception( "HW1 firmware version too old. Please update at https://www.ledgerwallet.com" ) try: self.dongleObject.getOperationMode() except BTChipException as e: if (e.sw == 0x6985): self.dongleObject.dongle.close() self.handler.get_setup() # Acquire the new client on the next run else: raise e if self.has_detached_pin_support( self.dongleObject) and not self.is_pin_validated( self.dongleObject) and (self.handler is not None): remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts( ) if remaining_attempts != 1: msg = "Enter your Ledger PIN - remaining attempts : " + str( remaining_attempts) else: msg = "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception( 'Aborted by user - please unplug the dongle and plug it again before retrying' ) pin = pin.encode() self.dongleObject.verifyPin(pin) gwpkArgSpecs = inspect.getfullargspec( self.dongleObject.getWalletPublicKey) self.cashaddrSWSupported = 'cashAddr' in gwpkArgSpecs.args except BTChipException as e: if (e.sw == 0x6faa): 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 perform_hw1_preflight(self): try: firmwareInfo = self.dongleObject.getFirmwareVersion() firmware = firmwareInfo['version'] self.multiOutputSupported = versiontuple(firmware) >= versiontuple( MULTI_OUTPUT_SUPPORT) self.nativeSegwitSupported = versiontuple( firmware) >= versiontuple(SEGWIT_SUPPORT) self.segwitSupported = self.nativeSegwitSupported or ( firmwareInfo['specialVersion'] == 0x20 and versiontuple(firmware) >= versiontuple(SEGWIT_SUPPORT_SPECIAL)) self.segwitTrustedInputs = versiontuple(firmware) >= versiontuple( SEGWIT_TRUSTEDINPUTS) if not checkFirmware(firmwareInfo): self.close() raise UserFacingException(MSG_NEEDS_FW_UPDATE_GENERIC) try: self.dongleObject.getOperationMode() except BTChipException as e: if (e.sw == 0x6985): self.close() self.handler.get_setup() # Acquire the new client on the next run else: raise e if self.has_detached_pin_support( self.dongleObject) and not self.is_pin_validated( self.dongleObject): assert self.handler, "no handler for client" remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts( ) if remaining_attempts != 1: msg = _("Enter your Ledger PIN - remaining attempts : {}" ).format(str(remaining_attempts)) else: msg = _( "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle " "will be wiped.") confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise UserFacingException( _('Aborted by user - please unplug the dongle and plug it again before retrying' )) pin = pin.encode() self.dongleObject.verifyPin(pin) self.dongleObject.setAlternateCoinVersions( constants.net.ADDRTYPE_P2PKH, constants.net.ADDRTYPE_P2SH) except BTChipException as e: if (e.sw == 0x6faa): raise UserFacingException( _("Dongle is temporarily locked - please unplug it and replug it again" )) if ((e.sw & 0xFFF0) == 0x63c0): raise UserFacingException( _("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 UserFacingException( _("Invalid channel.\n" "Please make sure that 'Browser support' is disabled on your device." )) raise e
def perform_hw1_preflight(self): try: app = btchip(self.dongleObject) firmwareInfo = app.getFirmwareVersion() firmware = firmwareInfo['version'] self.multiOutputSupported = versiontuple(firmware) >= versiontuple( MULTI_OUTPUT_SUPPORT) self.nativeSegwitSupported = versiontuple( firmware) >= versiontuple(SEGWIT_SUPPORT) self.segwitSupported = self.nativeSegwitSupported or ( firmwareInfo['specialVersion'] == 0x20 and versiontuple(firmware) >= versiontuple(SEGWIT_SUPPORT_SPECIAL)) if not checkFirmware(firmwareInfo): self.dongleObject.dongle.close() raise Exception(MSG_NEEDS_FW_UPDATE_GENERIC) try: app.getOperationMode() except BTChipException as e: if (e.sw == 0x6985): self.dongleObject.dongle.close() self.handler.get_setup() # Acquire the new client on the next run else: raise e status, remaining_attempts = app.getVerifyPinRemainingAttempts() if (status == False): if remaining_attempts <= 0: raise Exception("PIN is blocked - please unblock") if self.handler is not None: if remaining_attempts > 1: msg = "Enter your PIN. Remaining attempts : " + str( remaining_attempts) else: msg = "Enter your PIN. WARNING: LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception( 'Aborted by user - please unplug the dongle and plug it again before retrying' ) # pin = pin.encode() app.verifyPin(pin) except BTChipException as e: if (e.sw == 0x6faa): 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 perform_hw1_preflight(self): try: firmwareInfo = self.dongleObject.getFirmwareVersion() firmware = firmwareInfo['version'].split(".") self.multiOutputSupported = int(firmware[0]) >= 1 and int( firmware[1]) >= 1 and int(firmware[2]) >= 4 self.segwitSupported = (int(firmware[0]) >= 1 and int(firmware[1]) >= 1 and int(firmware[2]) >= 10) or ( firmwareInfo['specialVersion'] == 0x20 and int(firmware[0]) == 1 and int(firmware[1]) == 0 and int(firmware[2]) >= 4) self.nativeSegwitSupported = int(firmware[0]) >= 1 and int( firmware[1]) >= 1 and int(firmware[2]) >= 10 if not checkFirmware(firmware): self.dongleObject.dongle.close() raise Exception( "HW1 firmware version too old. Please update at https://www.ledgerwallet.com" ) try: self.dongleObject.getOperationMode() except BTChipException as e: print_error('perform_hw1_preflight ex1', e) if (e.sw == 0x6985): self.dongleObject.dongle.close() self.handler.get_setup() # Acquire the new client on the next run else: raise e if self.has_detached_pin_support( self.dongleObject) and not self.is_pin_validated( self.dongleObject) and (self.handler is not None): remaining_attempts = self.dongleObject.getVerifyPinRemainingAttempts( ) if remaining_attempts != 1: msg = "Enter your Ledger PIN - remaining attempts : " + str( remaining_attempts) else: msg = "Enter your Ledger PIN - WARNING : LAST ATTEMPT. If the PIN is not correct, the dongle will be wiped." confirmed, p, pin = self.password_dialog(msg) if not confirmed: raise Exception( 'Aborted by user - please unplug the dongle and plug it again before retrying' ) pin = pin.encode() self.dongleObject.verifyPin(pin) except BTChipException as e: if (e.sw == 0x6faa): 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." ) print('perform_hw1_preflight ex2', e) raise e