ledger: always use finalizeInput in sign_transaction

related #4749
This commit is contained in:
SomberNight 2018-10-02 15:52:24 +02:00
parent a61953673a
commit 788b5b04fe
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9

View file

@ -318,7 +318,6 @@ class Ledger_KeyStore(Hardware_KeyStore):
chipInputs = [] chipInputs = []
redeemScripts = [] redeemScripts = []
signatures = [] signatures = []
preparedTrustedInputs = []
changePath = "" changePath = ""
output = None output = None
p2shTransaction = False p2shTransaction = False
@ -377,8 +376,8 @@ class Ledger_KeyStore(Hardware_KeyStore):
self.give_error("P2SH / regular input mixed in same transaction not supported") # should never happen self.give_error("P2SH / regular input mixed in same transaction not supported") # should never happen
txOutput = var_int(len(tx.outputs())) txOutput = var_int(len(tx.outputs()))
for txout in tx.outputs(): for o in tx.outputs():
output_type, addr, amount = txout output_type, addr, amount = o.type, o.address, o.value
txOutput += int_to_hex(amount, 8) txOutput += int_to_hex(amount, 8)
script = tx.pay_script(output_type, addr) script = tx.pay_script(output_type, addr)
txOutput += var_int(len(script)//2) txOutput += var_int(len(script)//2)
@ -442,14 +441,10 @@ class Ledger_KeyStore(Hardware_KeyStore):
if segwitTransaction: if segwitTransaction:
self.get_client().startUntrustedTransaction(True, inputIndex, self.get_client().startUntrustedTransaction(True, inputIndex,
chipInputs, redeemScripts[inputIndex]) chipInputs, redeemScripts[inputIndex])
if changePath: # we don't set meaningful outputAddress, amount and fees
# we don't set meaningful outputAddress, amount and fees # as we only care about the alternateEncoding==True branch
# as we only care about the alternateEncoding==True branch outputData = self.get_client().finalizeInput(b'', 0, 0, changePath, bfh(rawTx))
outputData = self.get_client().finalizeInput(b'', 0, 0, changePath, bfh(rawTx))
else:
outputData = self.get_client().finalizeInputFull(txOutput)
outputData['outputData'] = txOutput outputData['outputData'] = txOutput
transactionOutput = outputData['outputData']
if outputData['confirmationNeeded']: if outputData['confirmationNeeded']:
outputData['address'] = output outputData['address'] = output
self.handler.finished() self.handler.finished()
@ -469,16 +464,11 @@ class Ledger_KeyStore(Hardware_KeyStore):
else: else:
while inputIndex < len(inputs): while inputIndex < len(inputs):
self.get_client().startUntrustedTransaction(firstTransaction, inputIndex, self.get_client().startUntrustedTransaction(firstTransaction, inputIndex,
chipInputs, redeemScripts[inputIndex]) chipInputs, redeemScripts[inputIndex])
if changePath: # we don't set meaningful outputAddress, amount and fees
# we don't set meaningful outputAddress, amount and fees # as we only care about the alternateEncoding==True branch
# as we only care about the alternateEncoding==True branch outputData = self.get_client().finalizeInput(b'', 0, 0, changePath, bfh(rawTx))
outputData = self.get_client().finalizeInput(b'', 0, 0, changePath, bfh(rawTx))
else:
outputData = self.get_client().finalizeInputFull(txOutput)
outputData['outputData'] = txOutput outputData['outputData'] = txOutput
if firstTransaction:
transactionOutput = outputData['outputData']
if outputData['confirmationNeeded']: if outputData['confirmationNeeded']:
outputData['address'] = output outputData['address'] = output
self.handler.finished() self.handler.finished()