def signMess(self, caller, hwpath, message, isTestnet=False): if isTestnet: path = MPATH_TESTNET + hwpath else: path = MPATH + hwpath # Ledger doesn't accept characters other that ascii printable: # https://ledgerhq.github.io/btchip-doc/bitcoin-technical.html#_sign_message message = message.encode('ascii', 'ignore') message_sha = splitString(single_sha256(message).hex(), 32) # Connection pop-up mBox = QMessageBox(caller) warningText = "Another application (such as Ledger Wallet app) has probably taken over " warningText += "the communication with the Ledger device.<br><br>To continue, close that application and " warningText += "click the <b>Retry</b> button.\nTo cancel, click the <b>Abort</b> button" mBox.setText(warningText) mBox.setWindowTitle("WARNING") mBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Abort) # Ask confirmation with self.lock: info = self.chip.signMessagePrepare(path, message) while info['confirmationNeeded'] and info['confirmationType'] == 34: ans = mBox.exec_() if ans == QMessageBox.Abort: raise Exception("Reconnect HW device") # we need to reconnect the device self.initDevice() info = self.chip.signMessagePrepare(path, message) printOK('Signing Message') self.mBox = QMessageBox(caller) messageText = "Check display of your hardware device\n\n- message hash:\n\n%s\n\n-path:\t%s\n" % ( message_sha, path) self.mBox.setText(messageText) self.mBox.setIconPixmap( caller.tabMain.ledgerImg.scaledToHeight( 200, Qt.SmoothTransformation)) self.mBox.setWindowTitle("CHECK YOUR LEDGER") self.mBox.setStandardButtons(QMessageBox.NoButton) self.mBox.show() # Sign message ThreadFuns.runInThread(self.signMessageSign, (), self.signMessageFinish)
def signMess(self, caller, hwpath, message, isTestnet=False): if isTestnet: path = MPATH_TESTNET + hwpath else: path = MPATH + hwpath # Connection pop-up self.mBox = QMessageBox(caller) messageText = "Check display of your hardware device\n\n- message:\n\n%s\n\n-path:\t%s\n" % ( splitString(message, 32), path) self.mBox.setText(messageText) self.setBoxIcon(self.mBox, caller) self.mBox.setWindowTitle("CHECK YOUR TREZOR") self.mBox.setStandardButtons(QMessageBox.NoButton) self.mBox.show() # Sign message ThreadFuns.runInThread(self.signMessageSign, (path, message, isTestnet), self.signMessageFinish)