def initDevice(self): with self.lock: self.status = 0 self.clearDevice() self.dongle = getDongle(False) printOK('Ledger Nano S drivers found') self.chip = btchip(self.dongle) printDbg("Ledger Initialized") ver = self.chip.getFirmwareVersion() printOK("Ledger HW device connected [v. %s]" % str(ver.get('version'))) # Check device is unlocked bip32_path = MPATH + "%d'/0/%d" % (0, 0) self.status = 1 firstKey = self.chip.getWalletPublicKey(bip32_path) self.status = 2
def initDevice(self): printDbg("Initializing Ledger") with self.lock: self.status = 0 self.dongle = getDongle(False) printOK('Ledger Nano drivers found') self.chip = btchip(self.dongle) printDbg("Ledger Initialized") self.status = 1 ver = self.chip.getFirmwareVersion() printOK("Ledger HW device connected [v. %s]" % str(ver.get('version'))) # Check device is unlocked bip32_path = MPATH + "%d'/0/%d" % (0, 0) _ = self.chip.getWalletPublicKey(bip32_path) self.status = 2 self.sig_progress.connect(self.updateSigProgress)
def initDevice(self): try: if hasattr(self, 'dongle'): self.dongle.close() self.dongle = getDongle(False) printOK('Ledger Nano S drivers found') self.chip = btchip(self.dongle) printDbg("Ledger Initialized") self.initialized = True ver = self.chip.getFirmwareVersion() printOK("Ledger HW device connected [v. %s]" % str(ver.get('version'))) except Exception as e: err_msg = 'error Initializing Ledger' printException(getCallerName(), getFunctionName(), err_msg, e.args) self.initialized = False if hasattr(self, 'dongle'): self.dongle.close()
def initDevice(self): try: self.lock.acquire() self.status = 0 if hasattr(self, 'dongle'): self.dongle.close() self.dongle = getDongle(False) printOK('Ledger Nano S drivers found') self.chip = btchip(self.dongle) printDbg("Ledger Initialized") ver = self.chip.getFirmwareVersion() printOK("Ledger HW device connected [v. %s]" % str(ver.get('version'))) self.status = 2 except Exception as e: if hasattr(self, 'dongle'): self.status = 1 self.dongle.close() finally: self.lock.release()
print("Enter password of keyfile or ctrl+c to cancel") pw = getpass() print("Applying hard key derivation function. Wait a little") k = decode_keystore_json(json, pw) # Prepare a new transaction (decoded transaction seems immutable...) tx = Transaction( tx.nonce, tx.gasprice, tx.startgas, tx.to, tx.value, tx.data ) tx.sign(k) # Using Ledger HW1 in DEV mode (SIGNVERIFY_IMMEDIATE) if args.keytype == 'dongle': from btchip.btchip import getDongle, btchip from bitcoin import decode_sig as bitcoin_decode_sig dongle = getDongle(True) app = btchip(dongle) print("Enter pin of dongle or ctrl+c to cancel") pin = getpass('Pin:') app.verifyPin(pin) # Sign with dongle rawhash = sha3(encode(tx, UnsignedTransaction)) signature = app.signImmediate(bytearray(decode_hex(args.keyfile)), rawhash) # ASN.1 Decoding inspired from electrum rLength = signature[3] r = signature[4: 4 + rLength] sLength = signature[4 + rLength + 1] s = signature[4 + rLength + 2:] if rLength == 33: