Пример #1
0
 def perform_hw1_preflight(self):
     try:
         firmware = self.dongleObject.getFirmwareVersion()['version'].split(".")
         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()
                 dialog = StartBTChipPersoDialog()
                 dialog.exec_()
                 # 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)
Пример #2
0
 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()
                 dialog = StartBTChipPersoDialog()
                 dialog.exec_()
                 # 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)
Пример #3
0
    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)
Пример #4
0
    def get_client(self, noPin=False):
        if not BTCHIP:
            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)
                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")
                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)

            except BTChipException, e:
                try:
                    self.client.dongle.close()
                except:
                    pass
                self.client = None                
                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
Пример #5
0
    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)
Пример #6
0
 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)
Пример #7
0
    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)
Пример #8
0
 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)
Пример #9
0
 def setup_dialog(self):
     dialog = StartBTChipPersoDialog()
     dialog.exec_()
Пример #10
0
 def setup_dialog(self):
     dialog = StartBTChipPersoDialog()
     dialog.exec_()
Пример #11
0
    def get_client(self, noPin=False):
        if not BTCHIP:
            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)
                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"
                    )
                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)

            except BTChipException, e:
                try:
                    self.client.dongle.close()
                except:
                    pass
                self.client = None
                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