From f8ecd087219f24d262cb1de616b823716634cbfc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 18 Jan 2019 17:07:08 +1030 Subject: [PATCH] pay: don't list dummy channel if error is from final hop. List the final one instead; if there's an error from the node it may actually make sense to blame that channel (ie. previous node did something wrong). Signed-off-by: Rusty Russell --- lightningd/pay.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lightningd/pay.c b/lightningd/pay.c index 7620bd42a..a574a1729 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -297,7 +297,6 @@ remote_routing_failure(const tal_t *ctx, const struct pubkey *erring_node; const struct short_channel_id *route_channels; const struct short_channel_id *erring_channel; - static const struct short_channel_id dummy_channel = { 0 }; int origin_index; int dir; @@ -310,9 +309,15 @@ remote_routing_failure(const tal_t *ctx, /* Check if at destination. */ if (origin_index == tal_count(route_nodes) - 1) { - /* FIXME: Don't set erring_channel or dir in this case! */ - erring_channel = &dummy_channel; - dir = 0; + /* If any channel is to blame, it's the last one. */ + erring_channel = &route_channels[origin_index]; + /* Single hop? */ + if (origin_index == 0) + dir = pubkey_idx(&ld->id, + &route_nodes[origin_index]); + else + dir = pubkey_idx(&route_nodes[origin_index - 1], + &route_nodes[origin_index]); /* BOLT #4: *