diff options
Diffstat (limited to 'accounts')
-rw-r--r-- | accounts/usbwallet/hub.go | 26 | ||||
-rw-r--r-- | accounts/usbwallet/trezor.go | 2 | ||||
-rw-r--r-- | accounts/usbwallet/wallet.go | 6 |
3 files changed, 16 insertions, 18 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 { diff --git a/accounts/usbwallet/trezor.go b/accounts/usbwallet/trezor.go index 34079c881..1892097ba 100644 --- a/accounts/usbwallet/trezor.go +++ b/accounts/usbwallet/trezor.go @@ -36,8 +36,6 @@ import ( "github.com/golang/protobuf/proto" ) -var ErrInvalidDeviceType = errors.New("trezor: invalid device type") - // ErrTrezorPINNeeded is returned if opening the trezor requires a PIN code. In // this case, the calling application should display a pinpad and send back the // encoded passphrase. diff --git a/accounts/usbwallet/wallet.go b/accounts/usbwallet/wallet.go index df38f953d..ed786d9b4 100644 --- a/accounts/usbwallet/wallet.go +++ b/accounts/usbwallet/wallet.go @@ -31,7 +31,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" - "github.com/karalabe/hid" + "github.com/karalabe/usb" ) // Maximum time between wallet health checks to detect USB unplugs. @@ -77,8 +77,8 @@ type wallet struct { driver driver // Hardware implementation of the low level device operations url *accounts.URL // Textual URL uniquely identifying this wallet - info hid.DeviceInfo // Known USB device infos about the wallet - device hid.Device // USB device advertising itself as a hardware wallet + info usb.DeviceInfo // Known USB device infos about the wallet + device usb.Device // USB device advertising itself as a hardware wallet accounts []accounts.Account // List of derive accounts pinned on the hardware wallet paths map[common.Address]accounts.DerivationPath // Known derivation paths for signing operations |