From c27d7a31106eff60bdc7bff6481586e5565aff98 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj jxPCSnmZ Date: Tue, 25 Aug 2020 09:54:52 +0800 Subject: [PATCH] plugins/libplugin-pay.c: Store the route description, and re-report on failure. --- plugins/libplugin-pay.c | 17 +++++++++++++++++ plugins/libplugin-pay.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index 645feae3c..970bb8d91 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -32,6 +32,7 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd, p->temp_exclusion = NULL; p->failroute_retry = false; p->bolt11 = NULL; + p->routetxt = NULL; /* Copy over the relevant pieces of information. */ if (parent != NULL) { @@ -875,6 +876,12 @@ handle_final_failure(struct command *cmd, goto nonerror; } + paymod_log(p, LOG_DBG, + "Final node %s reported %04x (%s) on route %s", + type_to_string(tmpctx, struct node_id, final_id), + failcode, onion_type_name(failcode), + p->routetxt); + /* We use an exhaustive switch statement here so you get a compile * warning when new ones are added, and can think about where they go */ switch (failcode) { @@ -969,6 +976,14 @@ handle_intermediate_failure(struct command *cmd, { struct payment *root = payment_root(p); + paymod_log(p, LOG_DBG, + "Intermediate node %s reported %04x (%s) at %s on route %s", + type_to_string(tmpctx, struct node_id, errnode), + failcode, onion_type_name(failcode), + type_to_string(tmpctx, struct short_channel_id, + &errchan->channel_id), + p->routetxt); + /* We use an exhaustive switch statement here so you get a compile * warning when new ones are added, and can think about where they go */ switch (failcode) { @@ -1309,6 +1324,8 @@ static void payment_compute_onion_payloads(struct payment *p) paymod_log(p, LOG_DBG, "Created outgoing onion for route: %s", routetxt); + p->routetxt = tal_steal(p, routetxt); + /* Now allow all the modifiers to mess with the payloads, before we * serialize via a call to createonion in the next step. */ payment_continue(p); diff --git a/plugins/libplugin-pay.h b/plugins/libplugin-pay.h index d6f844760..393e26453 100644 --- a/plugins/libplugin-pay.h +++ b/plugins/libplugin-pay.h @@ -265,6 +265,9 @@ struct payment { /* A unique id for the root of this payment. */ u64 id; + + /* A short description of the route of this payment. */ + char *routetxt; }; struct payment_modifier {