From 55e1aa8d1164993a6207af8b7a8ae7dc363ac324 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sun, 12 Jul 2020 16:05:23 +0200 Subject: [PATCH] exemptfee: Only apply to the root payment and fix logs We were applying the fee exemption to all payments individually, which is ok until we switch to MPP, where amounts change. Also the log entry was referring to the total amount, and not the fee of the payment. --- plugins/libplugin-pay.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index 18bc0dbaf..c9b8ff92b 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -1661,17 +1661,18 @@ static struct exemptfee_data *exemptfee_data_init(struct payment *p) static void exemptfee_cb(struct exemptfee_data *d, struct payment *p) { - if (p->step != PAYMENT_STEP_INITIALIZED) + if (p->step != PAYMENT_STEP_INITIALIZED || p->parent != NULL) return payment_continue(p); if (amount_msat_greater_eq(d->amount, p->constraints.fee_budget)) { - p->constraints.fee_budget = d->amount; - p->start_constraints->fee_budget = d->amount; plugin_log( p->plugin, LOG_INFORM, - "Payment amount is below exemption threshold, " + "Payment fee constraint %s is below exemption threshold, " "allowing a maximum fee of %s", - type_to_string(tmpctx, struct amount_msat, &p->constraints.fee_budget)); + type_to_string(tmpctx, struct amount_msat, &p->constraints.fee_budget), + type_to_string(tmpctx, struct amount_msat, &d->amount)); + p->constraints.fee_budget = d->amount; + p->start_constraints->fee_budget = d->amount; } return payment_continue(p); }