remote-wallet: add usb pids for ledger nano s plus

This commit is contained in:
Trent Nelson 2022-07-08 17:20:02 -06:00 committed by mergify[bot]
parent dcab37ecca
commit 6be835d887
1 changed files with 12 additions and 3 deletions

View File

@ -35,7 +35,7 @@ const APDU_SUCCESS_CODE: usize = 0x9000;
/// Ledger vendor ID
const LEDGER_VID: u16 = 0x2c97;
/// Ledger product IDs: Nano S and Nano X
/// Ledger product IDs
const LEDGER_NANO_S_PIDS: [u16; 33] = [
0x0001, 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006, 0x1007, 0x1008, 0x1009, 0x100a,
0x100b, 0x100c, 0x100d, 0x100e, 0x100f, 0x1010, 0x1011, 0x1012, 0x1013, 0x1014, 0x1015, 0x1016,
@ -46,6 +46,11 @@ const LEDGER_NANO_X_PIDS: [u16; 33] = [
0x400b, 0x400c, 0x400d, 0x400e, 0x400f, 0x4010, 0x4011, 0x4012, 0x4013, 0x4014, 0x4015, 0x4016,
0x4017, 0x4018, 0x4019, 0x401a, 0x401b, 0x401c, 0x401d, 0x401e, 0x401f,
];
const LEDGER_NANO_S_PLUS_PIDS: [u16; 33] = [
0x0005, 0x5000, 0x5001, 0x5002, 0x5003, 0x5004, 0x5005, 0x5006, 0x5007, 0x5008, 0x5009, 0x500a,
0x500b, 0x500c, 0x500d, 0x500e, 0x500f, 0x5010, 0x5011, 0x5012, 0x5013, 0x5014, 0x5015, 0x5016,
0x5017, 0x5018, 0x5019, 0x501a, 0x501b, 0x501c, 0x501d, 0x501e, 0x501f,
];
const LEDGER_TRANSPORT_HEADER_LEN: usize = 5;
const HID_PACKET_SIZE: usize = 64 + HID_PREFIX_ZERO;
@ -508,8 +513,12 @@ impl RemoteWallet<hidapi::DeviceInfo> for LedgerWallet {
/// Check if the detected device is a valid `Ledger device` by checking both the product ID and the vendor ID
pub fn is_valid_ledger(vendor_id: u16, product_id: u16) -> bool {
vendor_id == LEDGER_VID
&& (LEDGER_NANO_S_PIDS.contains(&product_id) || LEDGER_NANO_X_PIDS.contains(&product_id))
let product_ids = [
LEDGER_NANO_S_PIDS,
LEDGER_NANO_X_PIDS,
LEDGER_NANO_S_PLUS_PIDS,
];
vendor_id == LEDGER_VID && product_ids.iter().any(|pids| pids.contains(&product_id))
}
/// Build the derivation path byte array from a DerivationPath selection