From a9ec1c01dd1311ba0a9213fa6158a5a2ac5cd062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Granh=C3=A3o?= Date: Mon, 6 Jan 2025 12:45:56 +0000 Subject: [PATCH] Fix fees shown for send chain swaps --- lib/core/src/model.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/core/src/model.rs b/lib/core/src/model.rs index 1d0f55b84..dd0f5083b 100644 --- a/lib/core/src/model.rs +++ b/lib/core/src/model.rs @@ -1538,7 +1538,13 @@ impl Payment { .unwrap_or(utils::now()), amount_sat: tx.amount_sat, fees_sat: match swap.as_ref() { - Some(s) => s.payer_amount_sat - tx.amount_sat, + Some(s) => match tx.payment_type { + // For receive swaps, to avoid some edge case issues related to potential past + // overpayments, we use the actual claim value as the final received amount + // for fee calculation. + PaymentType::Receive => s.payer_amount_sat - tx.amount_sat, + PaymentType::Send => s.payer_amount_sat - s.receiver_amount_sat, + }, None => match tx.payment_type { PaymentType::Receive => 0, PaymentType::Send => tx.fees_sat,