spesmilo / electrum

Electrum Bitcoin Wallet
https://electrum.org
MIT License
7.33k stars 3.05k forks source link

Error when signing transaction transferred via QR Code - Ledger Nano S #7257

Open user5289361 opened 3 years ago

user5289361 commented 3 years ago

Error when attempting to sign transaction with a Ledger Nano S after transferring unsigned transaction via QR Code to offline computer running Electrum.

Transaction transferred via QR code shows the following error upon attempting to sign with a Ledger Nano S:

Error: fromhex() argument must be str, not None

Log data provides the following information relating to the error:

20210429T072254.005389Z | INFO | plugin.DeviceMgr | getting client for keystore 20210429T072254.005389Z | INFO | plugin.DeviceMgr | scanning devices... 20210429T072254.061315Z | DEBUG | util.profiler | DeviceMgr.scan_devices 0.0559 20210429T072254.061315Z | INFO | plugin.DeviceMgr | end client for keystore 20210429T072254.092567Z | INFO | plugin.DeviceMgr | getting client for keystore 20210429T072254.092567Z | INFO | plugin.DeviceMgr | scanning devices... 20210429T072254.155052Z | DEBUG | util.profiler | DeviceMgr.scan_devices 0.0625 20210429T072254.155052Z | INFO | plugin.DeviceMgr | end client for keystore 20210429T072254.155052Z | INFO | plugin.DeviceMgr | getting client for keystore 20210429T072254.155052Z | INFO | plugin.DeviceMgr | scanning devices... 20210429T072254.204624Z | DEBUG | util.profiler | DeviceMgr.scan_devices 0.0496 20210429T072254.204624Z | INFO | plugin.DeviceMgr | end client for keystore 20210429T072254.204624Z | ERROR | plugins.ledger.ledger.Ledger_KeyStore | Traceback (most recent call last): File "C:\Program Files (x86)\Electrum\electrum\plugins\ledger\ledger.py", line 459, in sign_transaction txtmp = bitcoinTransaction(bfh(utxo[0])) TypeError: fromhex() argument must be str, not None 20210429T072254.204624Z | INFO | plugins.ledger.ledger | fromhex() argument must be str, not None

Other forms of transfer (text/USB file) are able to sign transaction correctly via the Ledger Nano S. QR transfer of transaction appears to correctly transfer input and output for transaction, but fails with the above error at signing point.

Error log appears to have shown up in the past in relation to [ https://github.com/spesmilo/electrum/issues/3302 ], which relates to offline signing with Ledger Nano S requiring additional information to sign transaction.

This error is occurring with a nested segwit transaction.

SomberNight commented 3 years ago

Ah right... This is in relation to https://github.com/spesmilo/electrum/pull/6293, where ledger started requiring full previous transactions even for segwit inputs. Due to https://github.com/spesmilo/electrum/pull/6198 (and related CVE) most hardware wallets started to require this...

Other forms of transfer (text/USB file) are able to sign transaction correctly via the Ledger Nano S. QR transfer of transaction appears to correctly transfer input and output for transaction, but fails with the above error at signing point.

The reason QR codes behave differently is because specifically for QR codes we don't include the full prev txs; QR codes have a small capacity and for all but the smallest of txs this compromise is needed.