Merge pull request #1997 from btchip/hw1-fixes

Fix uninitialized HW.1/Nano and outputs swap with legacy firmware
This commit is contained in:
ThomasV 2016-10-24 15:48:00 +02:00 committed by GitHub
commit 4c2113326c
1 changed files with 9 additions and 3 deletions

View File

@ -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):