Skip to content

Commit 5e324ab

Browse files
author
Michael de Hoog
authored
Merge pull request #13 from base-org/michael/ledger-flex
Add support for ledger flex
2 parents e6e3594 + 40d32c6 commit 5e324ab

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

usbwallet/hub.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,22 @@ func NewLedgerHub() (*Hub, error) {
7373
return newHub(LedgerScheme, 0x2c97, []uint16{
7474

7575
// Device definitions taken from
76-
// https://github.com/LedgerHQ/ledger-live/blob/38012bc8899e0f07149ea9cfe7e64b2c146bc92b/libs/ledgerjs/packages/devices/src/index.ts
76+
// https://github.com/LedgerHQ/ledger-live/blob/595cb73b7e6622dbbcfc11867082ddc886f1bf01/libs/ledgerjs/packages/devices/src/index.ts
7777

7878
// Original product IDs
7979
0x0000, /* Ledger Blue */
8080
0x0001, /* Ledger Nano S */
8181
0x0004, /* Ledger Nano X */
8282
0x0005, /* Ledger Nano S Plus */
8383
0x0006, /* Ledger Nano FTS */
84+
0x0007, /* Ledger Flex */
8485

8586
0x0000, /* WebUSB Ledger Blue */
8687
0x1000, /* WebUSB Ledger Nano S */
8788
0x4000, /* WebUSB Ledger Nano X */
8889
0x5000, /* WebUSB Ledger Nano S Plus */
8990
0x6000, /* WebUSB Ledger Nano FTS */
91+
0x7000, /* WebUSB Ledger Flex */
9092
}, 0xffa0, 0, newLedgerDriver)
9193
}
9294

@@ -168,9 +170,11 @@ func (hub *Hub) refreshWallets() {
168170

169171
for _, info := range infos {
170172
for _, id := range hub.productIDs {
173+
// We check both the raw ProductID (legacy) and just the upper byte, as Ledger
174+
// uses `MMII`, encoding a model (MM) and an interface bitfield (II)
175+
mmOnly := info.ProductID & 0xff00
171176
// Windows and Macos use UsageID matching, Linux uses Interface matching
172-
upperId := info.ProductID & 0xff00
173-
if (info.ProductID == id || upperId == id) && (info.UsagePage == hub.usageID || info.Interface == hub.endpointID) {
177+
if (info.ProductID == id || mmOnly == id) && (info.UsagePage == hub.usageID || info.Interface == hub.endpointID) {
174178
devices = append(devices, info)
175179
break
176180
}

0 commit comments

Comments
 (0)