Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gui: update labels if user signed an unsaved tx #765

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions gui/src/app/state/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl PsbtState {
self.wallet.clone(),
cache.datadir_path.clone(),
cache.network,
self.saved,
);
let cmd = action.load(daemon);
self.action = Some(Box::new(action));
Expand Down Expand Up @@ -318,6 +319,7 @@ pub struct SignAction {
hws: HardwareWallets,
error: Option<Error>,
signed: HashSet<Fingerprint>,
is_saved: bool,
}

impl SignAction {
Expand All @@ -326,6 +328,7 @@ impl SignAction {
wallet: Arc<Wallet>,
datadir_path: PathBuf,
network: Network,
is_saved: bool,
) -> Self {
Self {
chosen_hw: None,
Expand All @@ -334,6 +337,7 @@ impl SignAction {
wallet,
error: None,
signed,
is_saved,
}
}
}
Expand Down Expand Up @@ -384,10 +388,28 @@ impl Action for SignAction {
self.signed.insert(fingerprint);
let daemon = daemon.clone();
tx.psbt = psbt.clone();
return Command::perform(
async move { daemon.update_spend_tx(&psbt).map_err(|e| e.into()) },
Message::Updated,
);
if self.is_saved {
return Command::perform(
async move { daemon.update_spend_tx(&psbt).map_err(|e| e.into()) },
Message::Updated,
);
// If the spend transaction was never saved before, then both the psbt and
// labels attached to it must be updated.
} else {
let mut labels = HashMap::<LabelItem, Option<String>>::new();
for (item, label) in tx.labels() {
if !label.is_empty() {
labels.insert(label_item_from_str(item), Some(label.clone()));
}
}
return Command::perform(
async move {
daemon.update_spend_tx(&psbt)?;
daemon.update_labels(&labels).map_err(|e| e.into())
},
Message::Updated,
);
}
}
},
Message::Updated(res) => match res {
Expand Down
Loading