From 1fa414be75cc99b4d95d6a7f3048cbfe62bdeb9b Mon Sep 17 00:00:00 2001 From: edouardparis Date: Thu, 14 Dec 2023 13:56:14 +0100 Subject: [PATCH] fix bitbox unsupported status when no wallet yet During the install process, no wallet yet is created and bitbox should not be marked as unsupported if its fingerprint is not in any descriptor. --- gui/src/hw.rs | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/gui/src/hw.rs b/gui/src/hw.rs index 8592dcda..f67757e2 100644 --- a/gui/src/hw.rs +++ b/gui/src/hw.rs @@ -239,11 +239,27 @@ impl HardwareWallets { bitbox2 = bitbox2.with_policy(&desc)?; registered = bitbox2.is_policy_registered(&desc).await?; - } - if wallet - .map(|w| w.descriptor_keys().contains(&fingerprint)) - == Some(true) - { + if wallet.descriptor_keys().contains(&fingerprint) { + Ok(HardwareWallet::Supported { + id: id.clone(), + kind: DeviceKind::BitBox02, + fingerprint, + device: bitbox2.into(), + version: None, + registered: Some(registered), + alias: None, + }) + } else { + Ok(HardwareWallet::Unsupported { + id: id.clone(), + kind: DeviceKind::BitBox02, + version: None, + reason: UnsupportedReason::NotPartOfWallet( + fingerprint, + ), + }) + } + } else { Ok(HardwareWallet::Supported { id: id.clone(), kind: DeviceKind::BitBox02, @@ -253,15 +269,6 @@ impl HardwareWallets { registered: Some(registered), alias: None, }) - } else { - Ok(HardwareWallet::Unsupported { - id: id.clone(), - kind: DeviceKind::BitBox02, - version: None, - reason: UnsupportedReason::NotPartOfWallet( - fingerprint, - ), - }) } }, |res| HardwareWalletMessage::Unlocked(id_cloned, res),