Skip to content

Commit

Permalink
pay: Print the HTLC result as soon as it's known
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cdecker authored and rustyrussell committed Jan 29, 2025
1 parent 9df9441 commit 94e70b8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugins/libplugin-pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}

Expand Down

0 comments on commit 94e70b8

Please sign in to comment.