Merge #1124: replace the descriptor by template in descriptor registration step

40f9dd9bc43bac0c966585ac2770a02aa4c92765 replace the descriptor by template + key vector in descriptor registration step (pythcoiner)

Pull request description:

  This PR replace the descriptor displayed in the installer descriptor registration step, by the wallet policies template + its keys, as almost (all?) signing devices displays the discriptor in this way for registration.

  ![image](https://github.com/wizardsardine/liana/assets/124568858/ac4d6dee-dbe9-448e-b89f-1d4cc6710676)

  closes #727

ACKs for top commit:
  jp1ac4:
    Tested ACK 40f9dd9bc43bac0c966585ac2770a02aa4c92765.

Tree-SHA512: 396d20d766b89b93d3f598b3168311dfa693fcd83efe02e0515ee6428e006a5e2db4f502e3b21f50a085f37e44a1049bbfa3e4e09719a6101396012b80486cea
This commit is contained in:
edouardparis 2024-06-21 10:23:08 +02:00
commit 93dbf6e2f6
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F

View File

@ -1,3 +1,4 @@
use async_hwi::utils::extract_keys_and_template;
use iced::widget::{
checkbox, container, pick_list, radio, scrollable, scrollable::Properties, slider, Space,
TextInput,
@ -617,6 +618,81 @@ pub fn register_descriptor<'a>(
done: bool,
created_desc: bool,
) -> Element<'a, Message> {
let displayed_descriptor = if let Ok((template, keys)) =
extract_keys_and_template::<String>(&descriptor)
{
let mut col = Column::new()
.push(
card::simple(
Column::new()
.push(text("Descriptor template:").small().bold())
.push(
scrollable(
Column::new()
.push(text(template.to_owned()).small())
.push(Space::with_height(Length::Fixed(5.0))),
)
.direction(
scrollable::Direction::Horizontal(
scrollable::Properties::new().width(5).scroller_width(5),
),
),
)
.spacing(10),
)
.width(Length::Fill),
)
.push(Space::with_height(5));
for (index, key) in keys.into_iter().enumerate() {
col = col
.push(
card::simple(
Column::new()
.push(text(format!("Key @{}:", index)).small().bold())
.push(
scrollable(
Column::new()
.push(text(key.to_owned()).small())
.push(Space::with_height(Length::Fixed(5.0))),
)
.direction(
scrollable::Direction::Horizontal(
scrollable::Properties::new().width(5).scroller_width(5),
),
),
)
.spacing(10),
)
.width(Length::Fill),
)
.push(Space::with_height(5));
}
col
} else {
Column::new().push(card::simple(
Column::new()
.push(text("The descriptor:").small().bold())
.push(
scrollable(
Column::new()
.push(text(descriptor.to_owned()).small())
.push(Space::with_height(Length::Fixed(5.0))),
)
.direction(scrollable::Direction::Horizontal(
scrollable::Properties::new().width(5).scroller_width(5),
)),
)
.push(
Row::new().push(Column::new().width(Length::Fill)).push(
button::secondary(Some(icon::clipboard_icon()), "Copy")
.on_press(Message::Clibpboard(descriptor)),
),
)
.spacing(10),
))
};
layout(
progress,
"Register descriptor",
@ -624,27 +700,7 @@ pub fn register_descriptor<'a>(
.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())
.push(
scrollable(
Column::new()
.push(text(descriptor.to_owned()).small())
.push(Space::with_height(Length::Fixed(5.0))),
)
.direction(scrollable::Direction::Horizontal(
scrollable::Properties::new().width(5).scroller_width(5),
)),
)
.push(
Row::new().push(Column::new().width(Length::Fill)).push(
button::secondary(Some(icon::clipboard_icon()), "Copy")
.on_press(Message::Clibpboard(descriptor)),
),
)
.spacing(10),
))
.push(displayed_descriptor)
.push(text(prompt::REGISTER_DESCRIPTOR_HELP))
.push_maybe(error.map(|e| card::error("Failed to register descriptor", e.to_string())))
.push(