diff --git a/gui/Cargo.lock b/gui/Cargo.lock index eecac727..9063ca28 100644 --- a/gui/Cargo.lock +++ b/gui/Cargo.lock @@ -145,9 +145,9 @@ dependencies = [ [[package]] name = "async-hwi" -version = "0.0.3" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5df769ed2ee66f45f290602647bfb48f7c652d6d8bb9dd8eb104fdfb0ac48919" +checksum = "b3b6805d43fc4b11c8f2a16f0aa8dca5b8b8702c3a23aa0a1a2ec1b42c98ebb7" dependencies = [ "async-trait", "base64", diff --git a/gui/Cargo.toml b/gui/Cargo.toml index 4763d2ab..88bf4296 100644 --- a/gui/Cargo.toml +++ b/gui/Cargo.toml @@ -14,7 +14,7 @@ name = "liana-gui" path = "src/main.rs" [dependencies] -async-hwi = "0.0.3" +async-hwi = "0.0.4" liana = { git = "https://github.com/wizardsardine/liana", branch = "master", default-features = false } backtrace = "0.3" base64 = "0.13" diff --git a/gui/src/hw.rs b/gui/src/hw.rs index 0ca5c8cc..e086f0f1 100644 --- a/gui/src/hw.rs +++ b/gui/src/hw.rs @@ -151,49 +151,58 @@ pub async fn list_hardware_wallets( debug!("{}", e); } } - match ledger::Ledger::try_connect_hid() { - Ok(mut device) => match device.get_master_fingerprint().await { - Ok(fingerprint) => { - if let Some((name, descriptor)) = wallet { - device - .load_wallet( - name, - descriptor, - cfg.iter() - .find(|cfg| cfg.fingerprint == fingerprint.to_string()) - .map(|cfg| cfg.token()), - ) - .expect("Configuration must be correct"); - } - - let version = device.get_version().await.ok(); - if ledger_version_supported(version.as_ref()) { - hws.push(HardwareWallet::Supported { - kind: device.device_kind(), - fingerprint, - device: Arc::new(device), - version, - }); - } else { - hws.push(HardwareWallet::Unsupported { - kind: device.device_kind(), - version, - message: "Minimal supported app version is 2.1.0".to_string(), - }); - } - } - Err(_) => { - hws.push(HardwareWallet::Unsupported { - kind: device.device_kind(), - version: None, - message: "Minimal supported app version is 2.1.0".to_string(), - }); - } - }, - Err(HWIError::DeviceNotFound) => {} + match ledger::HidApi::new() { Err(e) => { debug!("{}", e); } + Ok(api) => { + for detected in ledger::Ledger::::enumerate(&api) { + match ledger::Ledger::::connect(&api, detected) { + Ok(mut device) => match device.get_master_fingerprint().await { + Ok(fingerprint) => { + if let Some((name, descriptor)) = wallet { + device + .load_wallet( + name, + descriptor, + cfg.iter() + .find(|cfg| cfg.fingerprint == fingerprint.to_string()) + .map(|cfg| cfg.token()), + ) + .expect("Configuration must be correct"); + } + + let version = device.get_version().await.ok(); + if ledger_version_supported(version.as_ref()) { + hws.push(HardwareWallet::Supported { + kind: device.device_kind(), + fingerprint, + device: Arc::new(device), + version, + }); + } else { + hws.push(HardwareWallet::Unsupported { + kind: device.device_kind(), + version, + message: "Minimal supported app version is 2.1.0".to_string(), + }); + } + } + Err(_) => { + hws.push(HardwareWallet::Unsupported { + kind: device.device_kind(), + version: None, + message: "Minimal supported app version is 2.1.0".to_string(), + }); + } + }, + Err(HWIError::DeviceNotFound) => {} + Err(e) => { + debug!("{}", e); + } + } + } + } } hws }