Skip to content

Commit

Permalink
Merge #606: gui: installer: convey registering on a signing device is…
Browse files Browse the repository at this point in the history
…n't always required

bba5cd6 gui: installer: convey registering on a signing device isn't always required (Antoine Poinsot)

Pull request description:

  As discussed in #545, in some cases we nudge the user to register the descriptor on their signing device although they might not have one. Those cases only ever arise when importing a descriptor (either when recovering from backup or participating in the creation of a descriptor on another laptop), since when the descriptor is created beforehand we can simply detect whether a signing device was used and thereby needs to be registered (implemented since #470).

  Therefore, detect when the registration step arises as part of an import process and if so adjust the language to convey registration on a signing device may not be necessary.

  Result:
  ![image](https://github.com/wizardsardine/liana/assets/22457751/b6964dbc-c1e4-4059-b85a-c61492ba523c)

  Fixes #545.

ACKs for top commit:
  edouardparis:
    ACK bba5cd6

Tree-SHA512: 5b25b0c980f3e57563fc3c301802a7c4da50d7c80802d3e6a7517f98ee1da60e9d5ebe890ce3b8c34ca882220d920e31c59b79877c9e8f48b72b092d3809acda
  • Loading branch information
edouardparis committed Aug 18, 2023
2 parents b2baed5 + bba5cd6 commit df7e575
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 10 deletions.
6 changes: 3 additions & 3 deletions gui/src/installer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Installer {
DefineDescriptor::new(self.signer.clone()).into(),
BackupMnemonic::new(self.signer.clone()).into(),
BackupDescriptor::default().into(),
RegisterDescriptor::default().into(),
RegisterDescriptor::new_create_wallet().into(),
DefineBitcoind::new().into(),
Final::new(hot_signer_fingerprint).into(),
];
Expand All @@ -126,7 +126,7 @@ impl Installer {
ImportDescriptor::new(false).into(),
BackupMnemonic::new(self.signer.clone()).into(),
BackupDescriptor::default().into(),
RegisterDescriptor::default().into(),
RegisterDescriptor::new_import_wallet().into(),
DefineBitcoind::new().into(),
Final::new(hot_signer_fingerprint).into(),
];
Expand All @@ -137,7 +137,7 @@ impl Installer {
Welcome::default().into(),
ImportDescriptor::new(true).into(),
RecoverMnemonic::default().into(),
RegisterDescriptor::default().into(),
RegisterDescriptor::new_import_wallet().into(),
DefineBitcoind::new().into(),
Final::new(hot_signer_fingerprint).into(),
];
Expand Down
2 changes: 1 addition & 1 deletion gui/src/installer/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ pub const DEFINE_DESCRIPTOR_RECOVERY_PATH_TOOLTIP: &str =
"Set key(s) that can be used to spend coins after a defined period of time.\n Different sets of keys can be set to become available at different times.";
pub const DEFINE_DESCRIPTOR_FINGERPRINT_TOOLTIP: &str =
"The alias is applied on all the keys derived from the same seed";
pub const REGISTER_DESCRIPTOR_HELP: &str = "To be used with the wallet, a device needs the descriptor. If the descriptor contains one or more keys imported from an external signing device, the descriptor must be registered on it. Registration confirms that the device is able to handle the policy. Registration on a device is not a substitute for backing up the descriptor.";
pub const REGISTER_DESCRIPTOR_HELP: &str = "To be used with the wallet, a signing device needs the descriptor. If the descriptor contains one or more keys imported from an external signing device, the descriptor must be registered on it. Registration confirms that the device is able to handle the policy. Registration on a device is not a substitute for backing up the descriptor.";
pub const MNEMONIC_HELP: &str = "A hot key generated on this computer was used for creating this wallet. It needs to be backed up. \n Keep it in a safe place. Never share it with anyone.";
pub const RECOVER_MNEMONIC_HELP: &str = "If you were using a hot key (a key stored on the computer) in your wallet, you will need to recover it from mnemonics to be able to sign transactions again. Otherwise you can directly go the next step.";
32 changes: 31 additions & 1 deletion gui/src/installer/step/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,6 @@ impl From<ImportDescriptor> for Box<dyn Step> {
}
}

#[derive(Default)]
pub struct RegisterDescriptor {
descriptor: Option<LianaDescriptor>,
keys_aliases: HashMap<Fingerprint, String>,
Expand All @@ -1328,6 +1327,36 @@ pub struct RegisterDescriptor {
registered: HashSet<Fingerprint>,
error: Option<Error>,
done: bool,
/// Whether this step is part of the descriptor creation process. This is used to detect when
/// it's instead shown as part of the descriptor *import* process, where we can't detect
/// whether a signing device is used, to explicit this step is not required if the user isn't
/// using a signing device.
created_desc: bool,
}

impl RegisterDescriptor {
fn new(created_desc: bool) -> Self {
Self {
created_desc,
descriptor: Default::default(),
keys_aliases: Default::default(),
processing: Default::default(),
chosen_hw: Default::default(),
hws: Default::default(),
hmacs: Default::default(),
registered: Default::default(),
error: Default::default(),
done: Default::default(),
}
}

pub fn new_create_wallet() -> Self {
Self::new(true)
}

pub fn new_import_wallet() -> Self {
Self::new(false)
}
}

impl Step for RegisterDescriptor {
Expand Down Expand Up @@ -1417,6 +1446,7 @@ impl Step for RegisterDescriptor {
self.processing,
self.chosen_hw,
self.done,
self.created_desc,
)
}
}
Expand Down
19 changes: 14 additions & 5 deletions gui/src/installer/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,15 @@ pub fn register_descriptor<'a>(
processing: bool,
chosen_hw: Option<usize>,
done: bool,
created_desc: bool,
) -> Element<'a, Message> {
layout(
progress,
"Register descriptor",
Column::new()
.push_maybe((!created_desc).then_some(
text("This step is only necessary if you are using a signing device.").bold(),
))
.push(card::simple(
Column::new()
.push(text("The descriptor:").small().bold())
Expand All @@ -687,8 +691,13 @@ pub fn register_descriptor<'a>(
.align_items(Alignment::Center)
.push(
Container::new(
text("Select hardware wallet to register descriptor on:")
.bold(),
if created_desc {
text("Select hardware wallet to register descriptor on:")
.bold()
} else {
text("If necessary, please select the signing device to register descriptor on:")
.bold()
},
)
.width(Length::Fill),
)
Expand All @@ -715,12 +724,12 @@ pub fn register_descriptor<'a>(
)
.width(Length::Fill),
)
.push(checkbox(
.push_maybe(created_desc.then_some(checkbox(
"I have registered the descriptor on my device(s)",
done,
Message::UserActionDone,
))
.push(if done && !processing {
)))
.push(if !created_desc || (done && !processing) {
button::primary(None, "Next")
.on_press(Message::Next)
.width(Length::Fixed(200.0))
Expand Down

0 comments on commit df7e575

Please sign in to comment.