LedgerHQ / ledgerjs

⛔️ MOVED to monorepo "ledger-live"
https://github.com/LedgerHQ/ledger-live
Apache License 2.0
574 stars 382 forks source link

Segwit transaction used as UTXO in non-segwit transaction causes Internal Error #226

Open kantai opened 5 years ago

kantai commented 5 years ago

If one of the UTXOs for a transaction comes from a segwit transaction, and the transaction itself is non-segwit, then an internal error is triggered on the Ledger app.

See this issue:

https://github.com/LedgerHQ/ledger-app-btc/issues/57

I am pretty sure that the issue is somewhere around here for single-sig TXs:

https://github.com/LedgerHQ/ledgerjs/blob/master/packages/hw-app-btc/src/Btc.js#L561

And here for P2SH TXs:

https://github.com/LedgerHQ/ledgerjs/blob/master/packages/hw-app-btc/src/Btc.js#L832

I believe this is caused by the JS library sending a segwit formatted TX to the hardware device for preparing a trusted input. I only tested this with P2SH transactions, but I believe it to be the case for the normal P2PKH transactions as well (it looks like it makes the same assumption that all inputs to a P2PKH transaction will be non-segwit).

kantai commented 5 years ago

Any update here?