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 25, 2020
1 parent 380f820 commit dcdb1d6
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions plugins/ledger/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,21 @@ 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 (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 # Needed for CashAddr display
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 dcdb1d6

Please sign in to comment.