Skip to content

Commit

Permalink
Merge #1347: Check coldcard version and request user to upgrade
Browse files Browse the repository at this point in the history
47b8ad2 Check coldcard version and request user to upgrade (edouardparis)

Pull request description:

  backport of #1346

ACKs for top commit:
  jp1ac4:
    utACK 47b8ad2.
  edouardparis:
    Self-ACK 47b8ad2

Tree-SHA512: a11e24928e5ad5aa268bb216563ec7c35fb95cbed14032b3fd4d099983dcc52473efd216ebe659e8beade18d0c6c7b26db5e1b479f5a6f2676b4d5965600f5bc
  • Loading branch information
edouardparis committed Sep 17, 2024
2 parents 38377c8 + 47b8ad2 commit 58624fb
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 15 deletions.
21 changes: 21 additions & 0 deletions gui/src/app/view/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ pub fn hw_list_view(
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
},
HardwareWallet::Locked {
Expand Down Expand Up @@ -117,6 +124,13 @@ pub fn hw_list_view_for_registration(
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
},
HardwareWallet::Locked {
Expand Down Expand Up @@ -189,6 +203,13 @@ pub fn hw_list_view_verify_address(
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
},
false,
Expand Down
56 changes: 41 additions & 15 deletions gui/src/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,22 +602,48 @@ async fn refresh(mut state: State) -> (HardwareWalletMessage, State) {
if let Ok((cc, _)) =
coldcard::api::Coldcard::open(AsRefWrap { inner: api }, sn, None)
{
match HardwareWallet::new(
id,
if let Some(wallet) = &state.wallet {
coldcard::Coldcard::from(cc)
.with_wallet_name(wallet.name.clone())
.into()
} else {
coldcard::Coldcard::from(cc).into()
},
Some(&state.keys_aliases),
)
.await
{
Err(e) => tracing::error!("Failed to connect to coldcard: {}", e),
Ok(hw) => hws.push(hw),
let device: Arc<dyn HWI + Send + Sync> = if let Some(wallet) = &state.wallet {
coldcard::Coldcard::from(cc)
.with_wallet_name(wallet.name.clone())
.into()
} else {
coldcard::Coldcard::from(cc).into()
};
match (
device.get_master_fingerprint().await,
device.get_version().await,
) {
(Ok(fingerprint), Ok(version)) => {
if version
>= (Version {
major: 6,
minor: 2,
patch: 1,
prerelease: None,
})
{
hws.push(HardwareWallet::Supported {
id,
device,
kind: DeviceKind::Coldcard,
fingerprint,
version: Some(version),
registered: None,
alias: state.keys_aliases.get(&fingerprint).cloned(),
});
} else {
hws.push(HardwareWallet::Unsupported {
id,
kind: device.device_kind(),
version: Some(version),
reason: UnsupportedReason::Version {
minimal_supported_version: "Edge firmware v6.2.1",
},
});
}
}
_ => tracing::error!("Failed to connect to coldcard"),
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions gui/src/installer/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,13 @@ pub fn hardware_wallet_xpubs<'a>(
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
},
HardwareWallet::Locked {
Expand Down Expand Up @@ -2120,6 +2127,13 @@ pub fn hw_list_view(
UnsupportedReason::WrongNetwork => {
hw::wrong_network_hardware_wallet(&kind.to_string(), version.as_ref())
}
UnsupportedReason::Version {
minimal_supported_version,
} => hw::unsupported_version_hardware_wallet(
&kind.to_string(),
version.as_ref(),
minimal_supported_version,
),
_ => hw::unsupported_hardware_wallet(&kind.to_string(), version.as_ref()),
},
HardwareWallet::Locked {
Expand Down
31 changes: 31 additions & 0 deletions gui/ui/src/component/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,37 @@ pub fn unsupported_hardware_wallet<'a, T: 'a, K: Display, V: Display>(
.padding(10)
}

pub fn unsupported_version_hardware_wallet<'a, T: 'a, K: Display, V: Display, S: Display>(
kind: K,
version: Option<V>,
requested_version: S,
) -> Container<'a, T> {
container(
row(vec![
column(vec![
text::p1_bold("Unsupported firmware version").into(),
text::p1_regular(format!("Install version {} or later", requested_version)).into(),
Row::new()
.spacing(5)
.push(text::caption(kind.to_string()))
.push_maybe(version.map(|v| text::caption(v.to_string())))
.into(),
])
.width(Length::Fill)
.into(),
tooltip::Tooltip::new(
icon::warning_icon(),
"Please upgrade firmware",
tooltip::Position::Bottom,
)
.style(theme::Container::Card(theme::Card::Simple))
.into(),
])
.align_items(Alignment::Center),
)
.padding(10)
}

pub fn sign_success_hot_signer<'a, T: 'a, F: Display>(
fingerprint: F,
alias: Option<impl Into<Cow<'a, str>>>,
Expand Down

0 comments on commit 58624fb

Please sign in to comment.