Merge #1685: gui: store SignModal state and allow to open export modal after signing

7281e6352967009419a493ccd3825887001afa14 gui: store SignModal state and allow to open export modal after signing in PSBT panel (pythcoiner)

Pull request description:

  This PR fixes #1681:
  - `PsbtState::modal` was not properly reset after signing modal closed
  - When `PsbtState::modal` is of type `SignModal` we store it's state, else we lost track of which key already signed.
  - `SignModal::display_modal` is not useful anymore, as we store the modal state, and only "hidding" the modal not let display another modal (export modal for instance)

ACKs for top commit:
  jp1ac4:
    tACK 7281e6352967009419a493ccd3825887001afa14.

Tree-SHA512: 6627c1f788048349fee2fd9f6fc1a9044da03c9b6ac61339b19c5ae503cb0d522501ce4438f70359906231c06928c8756b52715901898c56fa58dd7da5194cdc
This commit is contained in:
edouardparis 2025-05-21 10:26:47 +02:00
commit 30ae68c3b1
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F

View File

@ -92,6 +92,9 @@ pub struct PsbtState {
pub warning: Option<Error>,
pub labels_edited: LabelsEdited,
pub modal: Option<PsbtModal>,
// NOTE: sign_modal is used to store state of SignModal
// when another modal is selected
pub sign_modal: Option<PsbtModal>,
}
impl PsbtState {
@ -102,6 +105,7 @@ impl PsbtState {
labels_edited: LabelsEdited::default(),
warning: None,
modal: None,
sign_modal: None,
tx,
saved,
}
@ -165,19 +169,19 @@ impl PsbtState {
}
}
Message::View(view::Message::Spend(view::SpendTxMessage::Cancel)) => {
if let Some(PsbtModal::Sign(SignModal { display_modal, .. })) = &mut self.modal {
*display_modal = false;
return Task::none();
if matches!(self.modal, Some(PsbtModal::Sign(_))) {
// store SignModal state
self.sign_modal = self.modal.take();
}
self.modal = None;
}
Message::View(view::Message::Spend(view::SpendTxMessage::Delete)) => {
self.modal = Some(PsbtModal::Delete(DeleteModal::default()));
}
Message::View(view::Message::Spend(view::SpendTxMessage::Sign)) => {
if let Some(PsbtModal::Sign(SignModal { display_modal, .. })) = &mut self.modal {
*display_modal = true;
if self.sign_modal.is_some() {
// restore SignModal state
self.modal = self.sign_modal.take();
return Task::none();
}
@ -483,7 +487,6 @@ impl Modal for SignModal {
..
}) = self.hws.list.get(i)
{
self.display_modal = false;
self.signing.insert(*fingerprint);
let psbt = tx.psbt.clone();
let fingerprint = *fingerprint;
@ -558,7 +561,7 @@ impl Modal for SignModal {
Task::none()
}
fn view<'a>(&'a self, content: Element<'a, view::Message>) -> Element<'a, view::Message> {
let content = toast::Manager::new(
let content: Element<'a, view::Message> = toast::Manager::new(
content,
view::psbt::sign_action_toasts(self.error.as_ref(), &self.hws.list, &self.signing),
)