From 05712328918839292d4bb7945829a19acdcb8a76 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 10 Dec 2024 18:19:23 +0100 Subject: [PATCH] pay: Print the HTLC result as soon as it's known We used to not print what happened with an HTLC in the `pay` plugin. This meant that to follow the HTLCs we'd have to map the `pay` HTLCs to the `lightningd` HTLCs, and then trace that. BY having `pay` print the outcome as it sees it, we can make that tracking much simpler, even allowing for tooling to do it for us. Changelog-None This is a log-only change --- plugins/libplugin-pay.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index 17254703ff07..19ba39e42147 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -1639,6 +1639,10 @@ payment_waitsendpay_finished(struct command *cmd, payment_result_infer(p->route, p->result); if (p->result->state == PAYMENT_COMPLETE) { + paymod_log(p, LOG_INFORM, + "HTLC result state=success, sent=%s, deliver=%s", + fmt_amount_msat(tmpctx, p->result->amount_sent), + fmt_amount_msat(tmpctx, p->final_amount)); payment_set_step(p, PAYMENT_STEP_SUCCESS); return payment_continue(p); } @@ -1657,9 +1661,23 @@ payment_waitsendpay_finished(struct command *cmd, payment_addgossip_success, payment_addgossip_failure, p); json_add_hex_talarr(req->js, "message", update); + + paymod_log(p, LOG_INFORM, + "HTLC result state=failed, sent=%s, todeliver=%s, " + "code=%d (%s)", + fmt_amount_msat(tmpctx, p->result->amount_sent), + fmt_amount_msat(tmpctx, p->final_amount), + p->result->code, p->result->failcodename); + return send_outreq(req); } + paymod_log( + p, LOG_INFORM, + "HTLC result state=failed, sent=%s, todeliver=%s, code=%d (%s)", + fmt_amount_msat(tmpctx, p->result->amount_sent), + fmt_amount_msat(tmpctx, p->final_amount), p->result->code, + p->result->failcodename); return payment_addgossip_success(cmd, NULL, NULL, NULL, p); }