fix: treat change outputs as send-to-self payments

This commit is contained in:
Michael Mallan 2024-12-31 08:57:09 +00:00
parent cfe15b360d
commit 55b92b3da7
No known key found for this signature in database
GPG Key ID: 5177CDCEDB0EABEB

View File

@ -423,6 +423,8 @@ pub struct Payment {
pub enum PaymentKind {
Outgoing,
Incoming,
/// A payment to self, which could be either from a self-transfer
/// or a change output from an outgoing transaction.
SendToSelf,
}
@ -489,7 +491,9 @@ pub fn payments_from_tx(history_tx: HistoryTransaction) -> Vec<Payment> {
outpoint,
time,
amount: output.value,
kind: if history_tx.is_send_to_self() {
kind: if history_tx.is_send_to_self()
|| history_tx.change_indexes.contains(&output_index)
{
PaymentKind::SendToSelf
} else if history_tx.is_external() {
PaymentKind::Incoming