plugin: Check that we have a non-empty route in libplugin

Changelog-Fixed: pay: Payments with an empty route (self-payment) are now aborted.
This commit is contained in:
Christian Decker
2021-02-07 20:53:35 +01:00
parent d2281f53df
commit 9869083a79
2 changed files with 9 additions and 2 deletions

View File

@@ -807,6 +807,12 @@ static struct command_result *payment_getroute(struct payment *p)
p->step = PAYMENT_STEP_GOT_ROUTE;
p->route = route_hops_from_route(p, p, r);
if (tal_count(p->route) == 0) {
payment_root(p)->abort = true;
payment_fail(p, "Empty route returned by getroute, are you "
"trying to pay yourself?");
}
fee = payment_route_fee(p);
/* Ensure that our fee and CLTV budgets are respected. */