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) 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, wallet, force_pair=True, noPin=False): aborted = False client = self.client if not client or client.bad: try: d = getDongle(BTCHIP_DEBUG) client = btchip(d) ver = client.getFirmwareVersion() firmware = ver['version'].split(".") wallet.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) 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) if wallet.canAlternateCoinVersions: client.setAlternateCoinVersions( PUBKEY_ADDR, SCRIPT_ADDR)
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 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)