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

pay: fix corner case where we eliminate our own hint. #4555

Merged
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
1 change: 1 addition & 0 deletions plugins/libplugin-pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,7 @@ static struct route_info **filter_routehints(struct gossmap *map,
"Removed empty routehint %zu. ", i);
tal_arr_remove(&hints, i);
i--;
continue;
}

/* If routehint entrypoint is unreachable there's no
Expand Down
23 changes: 23 additions & 0 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -4255,3 +4255,26 @@ def test_unreachable_routehint(node_factory, bitcoind):
# both directly, and via the routehints we should now just have a
# single attempt.
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
"""
Comment on lines +4262 to +4264
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: indentation


# 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)