mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 00:24:19 +01:00
pay: fix corner case where we eliminate our own hint.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Fixed: `pay`: Fix occasional crash paying an invoice with a routehint to us.
This commit is contained in:
@@ -2361,6 +2361,7 @@ static struct route_info **filter_routehints(struct gossmap *map,
|
|||||||
"Removed empty routehint %zu. ", i);
|
"Removed empty routehint %zu. ", i);
|
||||||
tal_arr_remove(&hints, i);
|
tal_arr_remove(&hints, i);
|
||||||
i--;
|
i--;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If routehint entrypoint is unreachable there's no
|
/* If routehint entrypoint is unreachable there's no
|
||||||
|
|||||||
@@ -4255,3 +4255,26 @@ def test_unreachable_routehint(node_factory, bitcoind):
|
|||||||
# both directly, and via the routehints we should now just have a
|
# both directly, and via the routehints we should now just have a
|
||||||
# single attempt.
|
# single attempt.
|
||||||
assert(len(excinfo.value.error['attempts']) == 1)
|
assert(len(excinfo.value.error['attempts']) == 1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_routehint_tous(node_factory, bitcoind):
|
||||||
|
"""
|
||||||
|
Test bug where trying to pay an invoice from an *offline* node which
|
||||||
|
gives a routehint straight to us causes an issue
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Existence of l1 makes l3 use l2 for routehint (otherwise it sees deadend)
|
||||||
|
l1, l2 = node_factory.line_graph(2, wait_for_announce=True)
|
||||||
|
l3 = node_factory.get_node()
|
||||||
|
l3.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||||
|
scid23, _ = l2.fundchannel(l3, 1000000, announce_channel=False)
|
||||||
|
# Make sure l3 sees l1->l2 channel.
|
||||||
|
wait_for(lambda: l3.rpc.listnodes(l1.info['id'])['nodes'] != [])
|
||||||
|
|
||||||
|
inv = l3.rpc.invoice(10, "test", "test")['bolt11']
|
||||||
|
decoded = l3.rpc.decodepay(inv)
|
||||||
|
assert(only_one(only_one(decoded['routes']))['short_channel_id'] == scid23)
|
||||||
|
|
||||||
|
l3.stop()
|
||||||
|
with pytest.raises(RpcError, match=r'Destination .* is not reachable directly and all routehints were unusable'):
|
||||||
|
l2.rpc.pay(inv)
|
||||||
|
|||||||
Reference in New Issue
Block a user