Merge #1566: gui(installer): allow deletion of any primary key and prevent deletion of all recovery paths

99ba17d0920d9d00a6d0df6d3c5169fe524b1363 gui(installer): allow deletion of any prim key if more than one (Michael Mallan)
ca3bd63667c7c357e899aeceb91d7adb512d65eb gui(installer): prevent deletion of all recovery paths (Michael Mallan)

Pull request description:

  This is to fix #1411 and #1407, which relate to whether primary or recovery keys, respectively, can be deleted in the installer.

  It lets a user delete any primary key as long as there are two or more.

  It lets a user delete a key from a recovery path only if there are at least two recovery paths or at least two keys in the given recovery path.

ACKs for top commit:
  edouardparis:
    ACK 99ba17d0920d9d00a6d0df6d3c5169fe524b1363

Tree-SHA512: 3838c29d92b1f0f5bd60cee303771e98434382c4fcf2a38a013b86a66cd9943dc299129534530469a0cb7c3eb62929b4fedb346e40d90fb3fd18b27c4c376fb4
This commit is contained in:
edouardparis 2025-02-10 15:18:39 +01:00
commit 4dc10d1d7c
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
2 changed files with 10 additions and 4 deletions

View File

@ -508,6 +508,7 @@ impl Step for DefineDescriptor {
threshold: p.threshold,
keys: self.path_keys(p),
}),
self.paths.len().saturating_sub(1), // subtract 1 for primary path
self.valid(),
),
};

View File

@ -59,8 +59,10 @@ pub fn custom_template<'a>(
use_taproot: bool,
primary_path: Path<'a>,
recovery_paths: &mut dyn Iterator<Item = Path<'a>>,
num_recovery_paths: usize,
valid: bool,
) -> Element<'a, Message> {
let prim_keys_fixed = primary_path.keys.len() < 2; // can only delete a primary key if there are 2 or more
layout(
progress,
None,
@ -113,14 +115,14 @@ pub fn custom_template<'a>(
} else {
None
},
i == 0,
prim_keys_fixed,
)
} else {
undefined_key(
color::GREEN,
"Primary key",
!primary_path.keys[0..i].iter().any(|k| k.is_none()),
i == 0,
prim_keys_fixed,
)
}
.map(move |msg| message::DefinePath::Key(i, msg))
@ -144,6 +146,9 @@ pub fn custom_template<'a>(
.iter()
.enumerate()
.map(|(j, recovery_key)| {
// We cannot delete a key if doing so would remove all recovery paths,
// i.e. if there is only 1 recovery path and it contains only 1 key.
let fixed = num_recovery_paths < 2 && p.keys.len() < 2;
if let Some(key) = recovery_key {
defined_key(
&key.name,
@ -154,14 +159,14 @@ pub fn custom_template<'a>(
} else {
None
},
false,
fixed,
)
} else {
undefined_key(
color::ORANGE,
"Recovery key",
!p.keys[0..j].iter().any(|k| k.is_none()),
false,
fixed,
)
}
.map(move |msg| message::DefinePath::Key(j, msg))