Skip to content

Commit

Permalink
pay: don't discard high-htlc_min channels when searching for routehin…
Browse files Browse the repository at this point in the history
…t starts.

As side-effect, getroute(0) is special too.

Reported-by: MiddleW4y in Discord
Fixes: #6577
Changelog-Fixed: `pay` will still use an invoice routehint if path to it doesn't take 1-msat payments.
  • Loading branch information
rustyrussell committed Aug 18, 2023
1 parent 2c3f8b8 commit d3c7d48
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion common/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ bool route_can_carry_even_disabled(const struct gossmap *map,
{
if (!gossmap_chan_set(c, dir))
return false;
if (!gossmap_chan_capacity(c, dir, amount))
/* Amount 0 is a special "ignore min" probe case */
if (!amount_msat_eq(amount, AMOUNT_MSAT(0))
&& !gossmap_chan_capacity(c, dir, amount))
return false;
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion doc/lightning-getroute.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ arrive at *id* with *cltv*-blocks to spare (default 9).
*amount\_msat* is in millisatoshi precision; it can be a whole number, or a
whole number ending in *msat* or *sat*, or a number with three decimal
places ending in *sat*, or a number with 1 to 11 decimal places ending
in *btc*.
in *btc*. The 0 value is special: it ignores any *htlc\_minimum\_msat*
setting on channels, and simply returns a possible route (if any) which
is useful for simple probing.

There are two considerations for how good a route is: how low the fees
are, and how long your payment will get stuck in a delayed output if a
Expand Down
6 changes: 3 additions & 3 deletions plugins/libplugin-pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -2521,7 +2521,7 @@ static struct route_info **filter_routehints(struct gossmap *map,
}

distance = dijkstra_distance(
dijkstra(tmpctx, map, entrynode, AMOUNT_MSAT(1), 1,
dijkstra(tmpctx, map, entrynode, AMOUNT_MSAT(0), 1,
payment_route_can_carry_even_disabled,
route_score_cheaper, p),
gossmap_node_idx(map, src));
Expand Down Expand Up @@ -2763,12 +2763,12 @@ static void routehint_check_reachable(struct payment *p)
if (dst == NULL)
d->destination_reachable = false;
else if (src != NULL) {
dij = dijkstra(tmpctx, gossmap, dst, AMOUNT_MSAT(1000),
dij = dijkstra(tmpctx, gossmap, dst, AMOUNT_MSAT(0),
10 / 1000000.0,
payment_route_can_carry_even_disabled,
route_score_cheaper, p);
r = route_from_dijkstra(tmpctx, gossmap, dij, src,
AMOUNT_MSAT(1000), 0);
AMOUNT_MSAT(0), 0);

/* If there was a route the destination is reachable
* without routehints. */
Expand Down
1 change: 0 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -5389,7 +5389,6 @@ def test_listsendpays_crash(node_factory):
l1.rpc.listsendpays('lightning:' + inv)


@pytest.mark.xfail(strict=True)
@pytest.mark.developer("updates are delayed without --dev-fast-gossip")
def test_pay_routehint_minhtlc(node_factory, bitcoind):
# l1 -> l2 -> l3 private -> l4
Expand Down

0 comments on commit d3c7d48

Please sign in to comment.