From d6152fdc4000e441dcaec5bd0a00c03fa89c4586 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 17 Nov 2024 16:06:06 +1030 Subject: [PATCH] lightningd: don't include empty error in onion returned on failed injectpaymentonion. fail->msg can be NULL for local failures (the error message itself is more informative in this case). Use the generic "something went wrong" message. Signed-off-by: Rusty Russell --- lightningd/pay.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lightningd/pay.c b/lightningd/pay.c index 07b4abe3d..3694f3bc6 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -1684,8 +1684,17 @@ injectonion_fail(struct command *cmd, struct json_stream *js; /* Turn local errors into onion reply. */ - if (!onionreply) - onionreply = create_onionreply(tmpctx, shared_secret, fail->msg); + if (!onionreply) { + const u8 *err; + + /* Local error with no context, use default error */ + if (fail->msg) + err = fail->msg; + else + err = towire_temporary_channel_failure(tmpctx, NULL); + + onionreply = create_onionreply(tmpctx, shared_secret, err); + } js = json_stream_fail(cmd, PAY_INJECTPAYMENTONION_FAILED, errmsg); /* We wrap the onion reply, as it expects. */