Merge #765: fix gui: update labels if user signed an unsaved tx
789f952433d7ccc0f09924359bd87b83b0bdcf55 fix gui: update labels if user signed an unsaved tx (edouardparis) Pull request description: It is a fix from #760 ACKs for top commit: edouardparis: Self-ACK 789f952433d7ccc0f09924359bd87b83b0bdcf55 Tree-SHA512: 3424577ba6d3215a3b7503a0861997ace0dbac0a82b0e43af5bc5fb5262450ab5074eaa54ce6a01021237b85dfb163d4eb436916d17f52b9dfd1a07cf7be269c
This commit is contained in:
commit
f6b89ce699
@ -111,6 +111,7 @@ impl PsbtState {
|
|||||||
self.wallet.clone(),
|
self.wallet.clone(),
|
||||||
cache.datadir_path.clone(),
|
cache.datadir_path.clone(),
|
||||||
cache.network,
|
cache.network,
|
||||||
|
self.saved,
|
||||||
);
|
);
|
||||||
let cmd = action.load(daemon);
|
let cmd = action.load(daemon);
|
||||||
self.action = Some(Box::new(action));
|
self.action = Some(Box::new(action));
|
||||||
@ -318,6 +319,7 @@ pub struct SignAction {
|
|||||||
hws: HardwareWallets,
|
hws: HardwareWallets,
|
||||||
error: Option<Error>,
|
error: Option<Error>,
|
||||||
signed: HashSet<Fingerprint>,
|
signed: HashSet<Fingerprint>,
|
||||||
|
is_saved: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SignAction {
|
impl SignAction {
|
||||||
@ -326,6 +328,7 @@ impl SignAction {
|
|||||||
wallet: Arc<Wallet>,
|
wallet: Arc<Wallet>,
|
||||||
datadir_path: PathBuf,
|
datadir_path: PathBuf,
|
||||||
network: Network,
|
network: Network,
|
||||||
|
is_saved: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
chosen_hw: None,
|
chosen_hw: None,
|
||||||
@ -334,6 +337,7 @@ impl SignAction {
|
|||||||
wallet,
|
wallet,
|
||||||
error: None,
|
error: None,
|
||||||
signed,
|
signed,
|
||||||
|
is_saved,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,10 +388,28 @@ impl Action for SignAction {
|
|||||||
self.signed.insert(fingerprint);
|
self.signed.insert(fingerprint);
|
||||||
let daemon = daemon.clone();
|
let daemon = daemon.clone();
|
||||||
tx.psbt = psbt.clone();
|
tx.psbt = psbt.clone();
|
||||||
return Command::perform(
|
if self.is_saved {
|
||||||
async move { daemon.update_spend_tx(&psbt).map_err(|e| e.into()) },
|
return Command::perform(
|
||||||
Message::Updated,
|
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 {
|
Message::Updated(res) => match res {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user