Skip to content

Commit

Permalink
pay: Do not attempt to filter routehints if we can't find outselves
Browse files Browse the repository at this point in the history
There are a couple of ways this can happen, but we shouldn't crash.

Fixed #4488
Fixes #4533

Changelog-Fixed: pay: Fixed an issue when filtering routehints when we can't find ourselves in the local network view.
  • Loading branch information
cdecker committed Jun 4, 2021
1 parent 5e1fadf commit 94bd509
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions plugins/libplugin-pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -2334,8 +2334,16 @@ static struct route_info **filter_routehints(struct gossmap *map,
{
const size_t max_hops = ROUTING_MAX_HOPS / 2;
char *mods = tal_strdup(tmpctx, "");
for (size_t i = 0; i < tal_count(hints); i++) {
struct gossmap_node *entrynode, *src;
struct gossmap_node *src = gossmap_find_node(map, p->local_id);

if (src == NULL) {
tal_append_fmt(&mods,
"Could not locate ourselves in the gossip map, "
"leaving routehints untouched. ");
}

for (size_t i = 0; i < tal_count(hints) && src != NULL; i++) {
struct gossmap_node *entrynode;
u32 distance;

/* Trim any routehint > 10 hops */
Expand Down Expand Up @@ -2367,8 +2375,6 @@ static struct route_info **filter_routehints(struct gossmap *map,
/* If routehint entrypoint is unreachable there's no
* point in keeping it. */
entrynode = gossmap_find_node(map, &hints[i][0].pubkey);
src = gossmap_find_node(map, p->local_id);

if (entrynode == NULL) {
tal_append_fmt(&mods,
"Removed routehint %zu because "
Expand Down

0 comments on commit 94bd509

Please sign in to comment.