Skip to content

Commit

Permalink
Add taproot support to installer descriptor editor step
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Mar 20, 2024
1 parent 8bc0cac commit 2debb32
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 35 deletions.
3 changes: 2 additions & 1 deletion gui/src/app/view/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ pub fn hw_list_view(
alias.as_ref(),
)
} else if *registered == Some(false) {
hw::unregistered_hardware_wallet(
hw::warning_hardware_wallet(
kind,
version.as_ref(),
fingerprint,
alias.as_ref(),
"The wallet descriptor is not registered on the device.\n You can register it in the settings.",
)
} else {
hw::supported_hardware_wallet(kind, version.as_ref(), fingerprint, alias.as_ref())
Expand Down
21 changes: 21 additions & 0 deletions gui/src/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,3 +673,24 @@ fn ledger_version_supported(version: Option<&Version>) -> bool {
false
}
}

// Kind and minimal version of devices supporting tapminiscript.
// We cannot use a lazy_static HashMap yet, because DeviceKind does not implement Hash.
const DEVICES_COMPATIBLE_WITH_TAPMINISCRIPT: [(DeviceKind, Option<Version>); 0] = [];

pub fn is_compatible_with_tapminiscript(
device_kind: &DeviceKind,
version: Option<&Version>,
) -> bool {
DEVICES_COMPATIBLE_WITH_TAPMINISCRIPT
.iter()
.any(|(kind, minimal_version)| {
device_kind == kind
&& match (version, minimal_version) {
(Some(v1), Some(v2)) => v1 >= v2,
(None, Some(_)) => false,
(Some(_), None) => true,
(None, None) => true,
}
})
}
11 changes: 9 additions & 2 deletions gui/src/installer/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
download::Progress,
hw::HardwareWalletMessage,
};
use async_hwi::DeviceKind;
use async_hwi::{DeviceKind, Version};

#[derive(Debug, Clone)]
pub enum Message {
Expand All @@ -30,6 +30,7 @@ pub enum Message {
UseHotSigner,
Installed(Result<PathBuf, Error>),
Network(Network),
CreateTaprootDescriptor(bool),
SelectBitcoindType(SelectBitcoindTypeMsg),
InternalBitcoind(InternalBitcoindMsg),
DefineBitcoind(DefineBitcoind),
Expand Down Expand Up @@ -85,12 +86,18 @@ pub enum DefinePath {
EditSequence,
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone)]
pub enum DefineKey {
Delete,
Edit,
Clipboard(String),
Edited(String, DescriptorPublicKey, Option<DeviceKind>),
Edited(
String,
DescriptorPublicKey,
Option<DeviceKind>,
Option<Version>,
),
}

#[derive(Debug, Clone)]
Expand Down
Loading

0 comments on commit 2debb32

Please sign in to comment.