Skip to content

Commit

Permalink
Merge pull request #2003 from EchterAgo/ledger_fix_unverified_inputs
Browse files Browse the repository at this point in the history
Ledger: Fix warning about unverified inputs
  • Loading branch information
cculianu committed Sep 28, 2020
2 parents b713b63 + 08683d9 commit 1f47387
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions plugins/ledger/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,28 @@ def sign_transaction(self, tx, password, *, use_cache=False):
# Get trusted inputs from the original transactions
for utxo in inputs:
sequence = int_to_hex(utxo[5], 4)
txtmp = bitcoinTransaction(bfh(utxo[0]))
tmp = bfh(utxo[3])[::-1]
tmp += bfh(int_to_hex(utxo[1], 4))
tmp += txtmp.outputs[utxo[1]].amount
chipInputs.append({'value' : tmp, 'witness' : True, 'sequence' : sequence})
redeemScripts.append(bfh(utxo[2]))
if self.get_client_electrum().is_hw1():
txtmp = bitcoinTransaction(bfh(utxo[0]))
tmp = bfh(utxo[3])[::-1]
tmp += bfh(int_to_hex(utxo[1], 4))
tmp += txtmp.outputs[utxo[1]].amount
chipInputs.append({'value' : tmp, 'witness' : True, 'sequence' : sequence})
redeemScripts.append(bfh(utxo[2]))
elif (not p2shTransaction) or self.get_client_electrum().supports_multi_output():
txtmp = bitcoinTransaction(bfh(utxo[0]))
trustedInput = self.get_client().getTrustedInput(txtmp, utxo[1])
trustedInput['sequence'] = sequence
trustedInput['witness'] = True
chipInputs.append(trustedInput)
if p2shTransaction:
redeemScripts.append(bfh(utxo[2]))
else:
redeemScripts.append(txtmp.outputs[utxo[1]].script)
else:
tmp = bfh(utxo[3])[::-1]
tmp += bfh(int_to_hex(utxo[1], 4))
chipInputs.append({'value' : tmp, 'witness': True, 'sequence' : sequence})
redeemScripts.append(bfh(utxo[2]))

# Sign all inputs
inputIndex = 0
Expand Down

0 comments on commit 1f47387

Please sign in to comment.