From d56a9a8a40671ad0ab0f4d8ccb8c6fa861d40429 Mon Sep 17 00:00:00 2001 From: edouardparis Date: Tue, 31 Oct 2023 14:39:20 +0100 Subject: [PATCH] fix single payment output label When a transaction has only one payment, then its txid label is attached to the payment label. While modifying the label of an output it did not change the whole transaction label, which is a bug. --- gui/src/app/view/home.rs | 1 + gui/src/app/view/psbt.rs | 19 +++++++++++++------ gui/src/app/view/spend/mod.rs | 1 + gui/src/app/view/transactions.rs | 1 + 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gui/src/app/view/home.rs b/gui/src/app/view/home.rs index 72a3fc0f..abd1e078 100644 --- a/gui/src/app/view/home.rs +++ b/gui/src/app/view/home.rs @@ -325,6 +325,7 @@ pub fn payment_view<'a>( }, &tx.labels, labels_editing, + tx.is_single_payment().is_some(), )) .spacing(20), ) diff --git a/gui/src/app/view/psbt.rs b/gui/src/app/view/psbt.rs index c1912c7c..697ba849 100644 --- a/gui/src/app/view/psbt.rs +++ b/gui/src/app/view/psbt.rs @@ -82,6 +82,7 @@ pub fn psbt_view<'a>( Some(tx.change_indexes.clone()), &tx.labels, labels_editing, + tx.is_single_payment().is_some(), )) .push(if saved { Row::new() @@ -542,6 +543,7 @@ pub fn inputs_and_outputs_view<'a>( change_indexes: Option>, labels: &'a HashMap, labels_editing: &'a HashMap>, + is_single_payment: bool, ) -> Element<'a, Message> { let change_indexes_copy = change_indexes.clone(); Column::new() @@ -674,6 +676,7 @@ pub fn inputs_and_outputs_view<'a>( network, labels, labels_editing, + is_single_payment, )) }, ) @@ -825,6 +828,7 @@ fn payment_view<'a>( network: Network, labels: &'a HashMap, labels_editing: &'a HashMap>, + is_single: bool, ) -> Element<'a, Message> { let addr = Address::from_script(&output.script_pubkey, network) .ok() @@ -834,6 +838,13 @@ fn payment_view<'a>( vout: i as u32, } .to_string(); + // if the payment is single in the transaction, then the label of the txid + // is attached to the label of the payment. + let change_labels = if is_single { + vec![outpoint.clone(), txid.to_string()] + } else { + vec![outpoint.clone()] + }; Column::new() .width(Length::Fill) .spacing(5) @@ -843,13 +854,9 @@ fn payment_view<'a>( .align_items(Alignment::Center) .push( Container::new(if let Some(label) = labels_editing.get(&outpoint) { - label::label_editing(vec![outpoint.clone()], label, text::P1_SIZE) + label::label_editing(change_labels, label, text::P1_SIZE) } else { - label::label_editable( - vec![outpoint.clone()], - labels.get(&outpoint), - text::P1_SIZE, - ) + label::label_editable(change_labels, labels.get(&outpoint), text::P1_SIZE) }) .width(Length::Fill), ) diff --git a/gui/src/app/view/spend/mod.rs b/gui/src/app/view/spend/mod.rs index 10ba1e65..54b273ca 100644 --- a/gui/src/app/view/spend/mod.rs +++ b/gui/src/app/view/spend/mod.rs @@ -56,6 +56,7 @@ pub fn spend_view<'a>( Some(tx.change_indexes.clone()), &tx.labels, labels_editing, + tx.is_single_payment().is_some(), )) .push(if saved { Row::new() diff --git a/gui/src/app/view/transactions.rs b/gui/src/app/view/transactions.rs index 4a0cff87..75a6217d 100644 --- a/gui/src/app/view/transactions.rs +++ b/gui/src/app/view/transactions.rs @@ -260,6 +260,7 @@ pub fn tx_view<'a>( }, &tx.labels, labels_editing, + tx.is_single_payment().is_some(), )) .spacing(20), )