Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pay: Print the HTLC result as soon as it's known #7930

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Dec 10, 2024

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

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
@Lagrang3
Copy link
Collaborator

I think one of the paymod_log to inform of a failed HTLC is repeated.
To log for the HTLC failure it would be enough to do so once after the
if(p->result->state==PAYMENT_COMPLETE){} block.

@cdecker
Copy link
Member Author

cdecker commented Dec 12, 2024

Each one of the paymod_log is directly followed by a return. I don't see how any of them could be duplicated?

@Lagrang3
Copy link
Collaborator

Why not this?:

diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c
index 17254703f..49a682f61 100644
--- a/plugins/libplugin-pay.c
+++ b/plugins/libplugin-pay.c
@@ -1639,9 +1639,19 @@ 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);
        }
+       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);
 
        payment_chanhints_unapply_route(p);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants