From 020fef4b31a108e39b590b645aaca080c75871c9 Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Thu, 2 Jan 2025 15:47:10 +0000 Subject: [PATCH] fix: send-to-self payments include change from outgoing only An incoming transaction will not contain any send-to-self payments. --- liana-gui/src/daemon/model.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/liana-gui/src/daemon/model.rs b/liana-gui/src/daemon/model.rs index 99c5fd02..34af3d05 100644 --- a/liana-gui/src/daemon/model.rs +++ b/liana-gui/src/daemon/model.rs @@ -388,6 +388,13 @@ impl HistoryTransaction { ) } + pub fn is_outgoing(&self) -> bool { + matches!( + self.kind, + TransactionKind::OutgoingPaymentBatch(_) | TransactionKind::OutgoingSinglePayment(_) + ) + } + pub fn is_send_to_self(&self) -> bool { matches!(self.kind, TransactionKind::SendToSelf) } @@ -492,7 +499,8 @@ pub fn payments_from_tx(history_tx: HistoryTransaction) -> Vec { time, amount: output.value, kind: if history_tx.is_send_to_self() - || history_tx.change_indexes.contains(&output_index) + || (history_tx.is_outgoing() + && history_tx.change_indexes.contains(&output_index)) { PaymentKind::SendToSelf } else if history_tx.is_external() {