Merge #879: fix bitbox unsupported status when no wallet yet

1fa414be75cc99b4d95d6a7f3048cbfe62bdeb9b fix bitbox unsupported status when no wallet yet (edouardparis)

Pull request description:

  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.

ACKs for top commit:
  edouardparis:
    Self-ACK 1fa414be75cc99b4d95d6a7f3048cbfe62bdeb9b

Tree-SHA512: 6f6287bf4e001253c369b282ae9ef3eec7163fdd45b09022e77e61c2e08ddf656c60414239a69fd466448132bc837655fbe68b9cebc6d74fa5524f0d8b4adc7c
This commit is contained in:
edouardparis 2023-12-14 14:11:12 +01:00
commit 683a500dd0
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F

View File

@ -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),