@@ -47,6 +47,8 @@ type Hub struct {
47
47
scheme string // Protocol scheme prefixing account and wallet URLs.
48
48
vendorID uint16 // USB vendor identifier used for device discovery
49
49
productIDs []uint16 // USB product identifiers used for device discovery
50
+ usageID uint16 // USB usage page identifier used for macOS device discovery
51
+ endpointID int // USB endpoint identifier used for non-macOS device discovery
50
52
makeDriver func (log.Logger ) driver // Factory method to construct a vendor specific driver
51
53
52
54
refreshed time.Time // Time instance when the list of wallets was last refreshed
@@ -66,23 +68,25 @@ type Hub struct {
66
68
67
69
// NewLedgerHub creates a new hardware wallet manager for Ledger devices.
68
70
func NewLedgerHub () (* Hub , error ) {
69
- return newHub (LedgerScheme , 0x2c97 , []uint16 {0x0000 /* Ledger Blue */ , 0x0001 /* Ledger Nano S */ }, newLedgerDriver )
71
+ return newHub (LedgerScheme , 0x2c97 , []uint16 {0x0000 /* Ledger Blue */ , 0x0001 /* Ledger Nano S */ }, 0xffa0 , 0 , newLedgerDriver )
70
72
}
71
73
72
74
// NewTrezorHub creates a new hardware wallet manager for Trezor devices.
73
75
func NewTrezorHub () (* Hub , error ) {
74
- return newHub (TrezorScheme , 0x534c , []uint16 {0x0001 /* Trezor 1 */ }, newTrezorDriver )
76
+ return newHub (TrezorScheme , 0x534c , []uint16 {0x0001 /* Trezor 1 */ }, 0xff00 , 0 , newTrezorDriver )
75
77
}
76
78
77
79
// newHub creates a new hardware wallet manager for generic USB devices.
78
- func newHub (scheme string , vendorID uint16 , productIDs []uint16 , makeDriver func (log.Logger ) driver ) (* Hub , error ) {
80
+ func newHub (scheme string , vendorID uint16 , productIDs []uint16 , usageID uint16 , endpointID int , makeDriver func (log.Logger ) driver ) (* Hub , error ) {
79
81
if ! hid .Supported () {
80
82
return nil , errors .New ("unsupported platform" )
81
83
}
82
84
hub := & Hub {
83
85
scheme : scheme ,
84
86
vendorID : vendorID ,
85
87
productIDs : productIDs ,
88
+ usageID : usageID ,
89
+ endpointID : endpointID ,
86
90
makeDriver : makeDriver ,
87
91
quit : make (chan chan error ),
88
92
}
@@ -133,7 +137,7 @@ func (hub *Hub) refreshWallets() {
133
137
}
134
138
for _ , info := range hid .Enumerate (hub .vendorID , 0 ) {
135
139
for _ , id := range hub .productIDs {
136
- if info .ProductID == id && info .Interface == 0 {
140
+ if info .ProductID == id && ( info .UsagePage == hub . usageID || info . Interface == hub . endpointID ) {
137
141
devices = append (devices , info )
138
142
break
139
143
}
0 commit comments