Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix routehint finding with minhtlc #6579

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
27 changes: 27 additions & 0 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -5387,3 +5387,30 @@ def test_listsendpays_crash(node_factory):

inv = l1.rpc.invoice(40, "inv", "inv")["bolt11"]
l1.rpc.listsendpays('lightning:' + inv)


@pytest.mark.developer("updates are delayed without --dev-fast-gossip")
def test_pay_routehint_minhtlc(node_factory, bitcoind):
# l1 -> l2 -> l3 private -> l4
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True)
l4 = node_factory.get_node()

l3.fundchannel(l4, announce_channel=False)

# l2->l3 required htlc of at least 1sat
scid = only_one(l2.rpc.setchannel(l3.info['id'], htlcmin=1000)['channels'])['short_channel_id']

# Make sure l4 knows about l1
wait_for(lambda: l4.rpc.listnodes(l1.info['id'])['nodes'] != [])

# And make sure l1 knows that l2->l3 has htlcmin 1000
wait_for(lambda: l1.rpc.listchannels(scid)['channels'][0]['htlc_minimum_msat'] == Millisatoshi(1000))

inv = l4.rpc.invoice(100000, "inv", "inv")
assert only_one(l1.rpc.decodepay(inv['bolt11'])['routes'])

# You should be able to pay the invoice!
l1.rpc.pay(inv['bolt11'])

# And you should also be able to getroute (and have it ignore htlc_min/max constraints!)
l1.rpc.getroute(l3.info['id'], amount_msat=0, riskfactor=1)
Loading