From 1b4c03ecc54a1ea192546e379cb3dbdc2953455f Mon Sep 17 00:00:00 2001 From: BTChip Date: Mon, 24 Oct 2016 15:45:54 +0200 Subject: [PATCH] Fix uninitialized HW.1/Nano and outputs swap with legacy firmware --- plugins/ledger/ledger.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/ledger/ledger.py b/plugins/ledger/ledger.py index 17a63ecc..4b8bbd6c 100644 --- a/plugins/ledger/ledger.py +++ b/plugins/ledger/ledger.py @@ -114,13 +114,13 @@ class Ledger_Client(): try: firmware = self.dongleObject.getFirmwareVersion()['version'].split(".") if not checkFirmware(firmware): - self.dongleObject.close() + 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.close() + self.dongleObject.dongle.close() dialog = StartBTChipPersoDialog() dialog.exec_() # Acquire the new client on the next run @@ -260,6 +260,7 @@ class Ledger_KeyStore(Hardware_KeyStore): output = None outputAmount = None p2shTransaction = False + reorganize = False pin = "" self.get_client() # prompt for the PIN before displaying the dialog if necessary @@ -339,6 +340,7 @@ class Ledger_KeyStore(Hardware_KeyStore): if not p2shTransaction: outputData = self.get_client().finalizeInput(output, format_satoshis_plain(outputAmount), format_satoshis_plain(tx.get_fee()), changePath, bytearray(rawTx.decode('hex'))) + reorganize = True else: outputData = self.get_client().finalizeInputFull(txOutput) outputData['outputData'] = txOutput @@ -403,7 +405,11 @@ class Ledger_KeyStore(Hardware_KeyStore): inputIndex = inputIndex + 1 updatedTransaction = format_transaction(transactionOutput, preparedTrustedInputs) updatedTransaction = hexlify(updatedTransaction) - tx.update_signatures(updatedTransaction) + + if reorganize: + tx.update(updatedTransaction) + else: + tx.update_signatures(updatedTransaction) self.signing = False def password_dialog(self, msg=None):