bitcoin-core / HWI

Bitcoin Hardware Wallet Interface
MIT License
486 stars 192 forks source link

Trezor detection issues #628

Closed minioff closed 1 year ago

minioff commented 2 years ago

Hi,

having issues with HWI on Ubuntu 18.04.6 LTS and Trezor T and HWI 2.1.1.

Observe:

/tmp/hwi-2.1.12097600960383665175.tmp --version
hwi-2.1.12097600960383665175.tmp 2.1.1

/tmp/hwi-2.1.12097600960383665175.tmp enumerate
Please confirm action on your Trezor device

** HERE PASSWORD IS ENTERED ON TREZOR **

ERROR:jade:Exception causing JadeAPI context exit.
ERROR:jade:<class 'TypeError'>
ERROR:jade:a bytes-like object is required, not 'str'
  File "hwilib/devices/jade.py", line 542, in enumerate
  File "hwilib/devices/jadepy/jade.py", line 185, in get_version_info
  File "hwilib/devices/jadepy/jade.py", line 159, in _jadeRpc
  File "hwilib/devices/jadepy/jade.py", line 653, in make_rpc_call
  File "hwilib/devices/jadepy/jade.py", line 632, in read_response
  File "hwilib/devices/jadepy/jade.py", line 604, in read_cbor_message
WARNING:jade:Draining interface...
WARNING:jade-device:1 Ubuntu-4ubuntu0.7

** THERE IS ABOUT 1 MINUTE WAIT TIME BEFORE NEXT LINE SHOWS UP **

WARNING:jade-device:
[{"type": "trezor", "path": "webusb:001:3", "label": "label_is_here", "model": "trezor_t", "needs_pin_sent": false, "needs_passphrase_sent": false, "fingerprint": "fp_is_here"}]

So it seems like two issues:

Tested different cable, different usb port, different hw wallet (also model t). Do not see any issues with bridge, trezord or trezor suite.

prusnak commented 1 year ago

Honestly, this seems like the Jade code being the culprit interrupting the standard Trezor flow.

@achow101 Is there a way how to turn off support of a particular HW wallet at start? Maybe via --skip-jade switch or something like that.

// cc @JamieDriver

JamieDriver commented 1 year ago

I'm guessing the trezor has already enumerated successfully, but then the enumerate loop moves onto jade ?

ERROR:jade:a bytes-like object is required, not 'str'
  File "hwilib/devices/jade.py", line 542, in enumerate
...

This is where the code is probing for the test jade simulator by trying to connect to the simulator port, tcp:127.0.0.1:2222.
It would appear that maybe there is something running on this port ?
Saying that, everything inside 'test for simulator' is supposed to catch any errors and just ignore/continue - but it's possible it is hanging trying to disconnect.

Maybe we need to ignore (not try to enumerate) simulators by default, and only probe for them if a certain flag is present (which the tests would set) ?

I don't think 'device detected as jade' is true - I think the trezor device is detected fine (from that enumerate output) - I think the issue is when it gets in a pickle trying to probe for a 'jade simulator' (ie. completely separate from trezor).

prusnak commented 1 year ago

It would appear that maybe there is something running on this port ?

I suggest you use a different port (5 digits to decrease chance of collisions). There is a high chance you will have collisions on low ports and especially 2222 is very bad since lot of people use it to run sshd (originally 22).

JamieDriver commented 1 year ago

Yeah, that may be the simplest option! Will look into it asap.

JamieDriver commented 1 year ago

Jade master branch updated to run simulator on 30121 - hwi test client updated in #645

prusnak commented 1 year ago

@minioff please reopen if you still encounter the issue