Merge #769: fix single payment output label

d56a9a8a40671ad0ab0f4d8ccb8c6fa861d40429 fix single payment output label (edouardparis)

Pull request description:

  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.

  backport of the fix for 3.x in #768

ACKs for top commit:
  edouardparis:
    Self-ACK d56a9a8a40671ad0ab0f4d8ccb8c6fa861d40429

Tree-SHA512: 0c2bca6f2a5527c37653c3644907926f6dacd01f826a2538a78c898fda407e49dceb40614ef8389ae7663228da1c1121decf4be21dc8e0f9a44fd788b3c76972
This commit is contained in:
edouardparis 2023-10-31 15:47:30 +01:00
commit c861368802
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
4 changed files with 16 additions and 6 deletions

View File

@ -325,6 +325,7 @@ pub fn payment_view<'a>(
},
&tx.labels,
labels_editing,
tx.is_single_payment().is_some(),
))
.spacing(20),
)

View File

@ -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<Vec<usize>>,
labels: &'a HashMap<String, String>,
labels_editing: &'a HashMap<String, form::Value<String>>,
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<String, String>,
labels_editing: &'a HashMap<String, form::Value<String>>,
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),
)

View File

@ -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()

View File

@ -260,6 +260,7 @@ pub fn tx_view<'a>(
},
&tx.labels,
labels_editing,
tx.is_single_payment().is_some(),
))
.spacing(20),
)