Skip to content

Commit

Permalink
Ledger: Fix warning about unverified inputs
Browse files Browse the repository at this point in the history
Starting in version 1.4.0 of the Ledger Bitcoin app, additional data
needs to be sent for inputs to prevent the firmware warning about
unverified inputs. See https://donjon.ledger.com/lsb/010/
  • Loading branch information
EchterAgo committed Sep 26, 2020
1 parent 380f820 commit 08683d9
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 08683d9

Please sign in to comment.