go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

accounts/usbwallet: fails to list Trezors

Open jtolio opened this issue 6 months ago • 4 comments

System information

OS & Version: Linux and macOS Commit hash : c8be0f9a74fdabe5f82fa5b647e9973c9c3567ef

Expected behaviour

I expect the following code to print out wallets when my Trezor is attached (and working with Trezor Suite):

	hub, err := usbwallet.NewTrezorHubWithWebUSB()
	if err != nil {
		panic(err)
	}
	for _, wallet := range hub.Wallets() {
		fmt.Println(wallet)
	}

Actual behaviour

No USB wallets found.

Steps to reproduce the behaviour

I have spent a bunch of time trying to understand what's happening. As far as I can tell, on both macOS and Linux, when I connect my Trezor (I have tried both a Trezor Model One with the latest firmware and a Trezor Model T with the latest firmware), github.com/karalabe/hid does find a USB entry for the Trezor, but it is for Interface 1, not Interface 0. No matter what I do, on Linux and macOS, only the FIDO/U2F interface shows up. However, the Trezor Suite still works, of course.

So it might be a change to recent Trezor firmware builds? It doesn't appear to be OS specific (Linux and Mac both have this problem). It doesn't appear to be Trezor specific (two different models of Trezor have this problem). So I think we need to rework how Trezors talk to the usbwallet library? Perhaps they need to be initialized or something?

jtolio avatar May 17 '25 05:05 jtolio

Trezor Model T won't let me downgrade back past 2.8.7, and Trezor Model T 2.8.7 has this problem.

jtolio avatar May 17 '25 16:05 jtolio

go-ethereum's USB library, github.com/karalabe/hid, does find a USB entry for the Trezor, but it is for USB Interface 1, not Interface 0.

This is expected. Interface 0 is a WebUSB interface, not HID interface (which is only used for FIDO).

However, this does not explain why usbwallet.NewTrezorHubWithWebUSB() does not work (hopefully that uses WebUSB correctly).

prusnak avatar May 18 '25 12:05 prusnak

You're saying it's expected that github.com/karalabe/hid only returns USB interface 1?

This part of the usbwallet library hasn't changed in 6 years (https://github.com/ethereum/go-ethereum/blame/master/accounts/usbwallet/hub.go#L95-L104), definitely worked in that time range, and is explicitly looking for interface 0.

So this is a hint that it used to return USB interface 0 and maybe what changed is that?

(Hmm, github.com/karalabe/hid hasn't appreciably changed in over a year either)

jtolio avatar May 18 '25 12:05 jtolio

You're saying it's expected that github.com/karalabe/hid only returns USB interface 1?

Yes. Interface 0 is WebUSB not HID.

Ignore NewTrezorHubWithHID - this is for very ancient versions of Trezor One devices. The code should have been removed imo.

Pay attention only to NewTrezorHubWithWebUSB‎.

prusnak avatar May 18 '25 12:05 prusnak

I'm also experiencing this problem. I'm trying to add Trezor support to this lib: https://github.com/base/eip712sign and I'm not able to get any wallets returned from NewTrezorHubWithWebUSB‎.

blmalone avatar Jun 24 '25 14:06 blmalone