diff options
Diffstat (limited to 'accounts/usbwallet/hub.go')
-rw-r--r-- | accounts/usbwallet/hub.go | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/accounts/usbwallet/hub.go b/accounts/usbwallet/hub.go index 35695dd1c..8f34d63e8 100644 --- a/accounts/usbwallet/hub.go +++ b/accounts/usbwallet/hub.go @@ -25,7 +25,7 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" - "github.com/karalabe/hid" + "github.com/karalabe/usb" ) // LedgerScheme is the protocol scheme prefixing account and wallet URLs. @@ -84,20 +84,20 @@ func NewLedgerHub() (*Hub, error) { }, 0xffa0, 0, newLedgerDriver) } -// NewTrezorHub creates a new hardware wallet manager for Trezor devices. -func NewTrezorHub() (*Hub, error) { - return newHub(TrezorScheme, 0x534c, []uint16{0x0001 /* Trezor 1 */}, 0xff00, 0, newTrezorDriver) +// NewTrezorHubWithHID creates a new hardware wallet manager for Trezor devices. +func NewTrezorHubWithHID() (*Hub, error) { + return newHub(TrezorScheme, 0x534c, []uint16{0x0001 /* Trezor HID */}, 0xff00, 0, newTrezorDriver) } -// NewWebUSBTrezorHub creates a new hardware wallet manager for Trezor devices with +// NewTrezorHubWithWebUSB creates a new hardware wallet manager for Trezor devices with // firmware version > 1.8.0 -func NewWebUSBTrezorHub() (*Hub, error) { - return newHub(TrezorScheme, 0x1209, []uint16{0x53c1 /* Trezor 1 WebUSB */}, 0, 0, newTrezorDriver) +func NewTrezorHubWithWebUSB() (*Hub, error) { + return newHub(TrezorScheme, 0x1209, []uint16{0x53c1 /* Trezor WebUSB */}, 0xffff /* No usage id on webusb, don't match unset (0) */, 0, newTrezorDriver) } // newHub creates a new hardware wallet manager for generic USB devices. func newHub(scheme string, vendorID uint16, productIDs []uint16, usageID uint16, endpointID int, makeDriver func(log.Logger) driver) (*Hub, error) { - if !hid.Supported() { + if !usb.Supported() { return nil, errors.New("unsupported platform") } hub := &Hub{ @@ -139,7 +139,7 @@ func (hub *Hub) refreshWallets() { return } // Retrieve the current list of USB wallet devices - var devices []hid.DeviceInfo + var devices []usb.DeviceInfo if runtime.GOOS == "linux" { // hidapi on Linux opens the device during enumeration to retrieve some infos, @@ -154,7 +154,7 @@ func (hub *Hub) refreshWallets() { return } } - infos, err := hid.Enumerate(hub.vendorID, 0) + infos, err := usb.Enumerate(hub.vendorID, 0) if err != nil { if runtime.GOOS == "linux" { // See rationale before the enumeration why this is needed and only on Linux. @@ -165,8 +165,8 @@ func (hub *Hub) refreshWallets() { } for _, info := range infos { for _, id := range hub.productIDs { - _, pid, endpoint, _ /* FIXME usageID */ := info.IDs() - if pid == id && ( /* FIXME usageID == hub.usageID || */ endpoint == hub.endpointID) { + // Windows and Macos use UsageID matching, Linux uses Interface matching + if info.ProductID == id && (info.UsagePage == hub.usageID || info.Interface == hub.endpointID) { devices = append(devices, info) break } @@ -185,7 +185,7 @@ func (hub *Hub) refreshWallets() { ) for _, device := range devices { - url := accounts.URL{Scheme: hub.scheme, Path: device.GetPath()} + url := accounts.URL{Scheme: hub.scheme, Path: device.Path} // Drop wallets in front of the next device or those that failed for some reason for len(hub.wallets) > 0 { |