Merge #1511: fix: send-to-self payments should only include change outputs from outgoing transactions

020fef4b31a108e39b590b645aaca080c75871c9 fix: send-to-self payments include change from outgoing only (Michael Mallan)

Pull request description:

  This is a follow-up fix to #1507.

  Only those change outputs from outgoing transactions should be considered send-to-self payments.

ACKs for top commit:
  edouardparis:
    utACK 020fef4b31a108e39b590b645aaca080c75871c9

Tree-SHA512: 92a699d8bfd2724c1c309e7f957fe9bf9dd2460f562ff8f93d4e0fb026d43cae0f270fbc96d0ca6002ba9ce70c2ee09da80ff8c08b08d08db81d03ff2f78251c
This commit is contained in:
edouardparis 2025-01-02 17:24:49 +01:00
commit 2e7fe80613
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F

View File

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