Skip to content

Commit

Permalink
Merge #1403: Disable edit of defined key in multisig template recover…
Browse files Browse the repository at this point in the history
…y path

59c7300 Disable edit of defined key in multisig template recovery path (edouardparis)

Pull request description:

  The primary keys shouldn't be editable from the recovery path in the Multisig Savings template but only from the primary path. It could bring to weird behaviors and corner cases.

ACKs for top commit:
  jp1ac4:
    Tested ACK 59c7300.

Tree-SHA512: 0fa72bfeac7a32fc188f041c395f46ce2e3de72d7f750343641bff68b92d885d3510f3cd4600cc09856a5192a493fe7b3afca70a7ca78c0aeeb9ee0f3411fda5
  • Loading branch information
edouardparis committed Oct 30, 2024
2 parents 799ec10 + 59c7300 commit cbc46e9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 16 deletions.
33 changes: 33 additions & 0 deletions gui/src/installer/view/editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,39 @@ pub fn path(
.into()
}

pub fn uneditable_defined_key<'a>(
alias: &'a str,
color: iced::Color,
title: impl Into<Cow<'a, str>>,
warning: Option<&'static str>,
) -> Element<'a, message::DefineKey> {
card::simple(
Row::new()
.spacing(10)
.width(Length::Fill)
.align_items(Alignment::Center)
.push(icon::round_key_icon().size(H3_SIZE).style(color))
.push(
Column::new()
.width(Length::Fill)
.spacing(5)
.push(
Row::new()
.spacing(10)
.push(p1_regular(title).style(color::GREY_2))
.push(p1_bold(alias)),
)
.push_maybe(warning.map(|w| p2_regular(w).style(color::RED))),
)
.push_maybe(if warning.is_none() {
Some(icon::check_icon().style(color::GREEN))
} else {
None
}),
)
.into()
}

pub fn defined_key<'a>(
alias: &'a str,
color: iced::Color,
Expand Down
44 changes: 28 additions & 16 deletions gui/src/installer/view/editor/template/multisig_security_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use crate::installer::{
message::{self, Message},
step::descriptor::editor::key::Key,
view::{
editor::{define_descriptor_advanced_settings, defined_key, path, undefined_key},
editor::{
define_descriptor_advanced_settings, defined_key, path, undefined_key,
uneditable_defined_key,
},
layout,
},
};
Expand Down Expand Up @@ -168,21 +171,30 @@ pub fn multisig_security_template<'a>(
.enumerate()
.map(|(j, recovery_key)| {
if let Some(key) = recovery_key {
defined_key(
&key.name,
if j < 2 { color::GREEN } else { color::ORANGE },
if j < 2 {
format!("Primary key #{}", j + 1)
} else {
"Recovery key".to_string()
},
if use_taproot && !key.is_compatible_taproot {
Some("Key is not compatible with Taproot")
} else {
None
},
true,
)
if j < 2 {
uneditable_defined_key(
&key.name,
color::GREEN,
format!("Primary key #{}", j + 1),
if use_taproot && !key.is_compatible_taproot {
Some("Key is not compatible with Taproot")
} else {
None
},
)
} else {
defined_key(
&key.name,
color::ORANGE,
"Recovery key".to_string(),
if use_taproot && !key.is_compatible_taproot {
Some("Key is not compatible with Taproot")
} else {
None
},
true,
)
}
} else {
undefined_key(
if j < 2 { color::GREEN } else { color::ORANGE },
Expand Down

0 comments on commit cbc46e9

Please sign in to comment.