Skip to content

Commit

Permalink
gossipd: don't expose private channels for routeboost.
Browse files Browse the repository at this point in the history
We don't create unannouncable channels, but other implementations can.
Not only is it rude to expose these via invoices, it's probably not
useable anyway.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Oct 15, 2018
1 parent d0de7b4 commit 030fe1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,10 @@ static struct io_plan *get_incoming_channels(struct io_conn *conn,
const struct half_chan *hc;
struct route_info *ri;

/* Don't leak private channels. */
if (!is_chan_public(c))
continue;

hc = &c->half[half_chan_to(node, c)];

if (!is_halfchan_enabled(hc))
Expand Down
12 changes: 10 additions & 2 deletions tests/test_invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,19 @@ def test_invoice_preimage(node_factory):
l2.rpc.invoice(123456, 'inv2', '?', preimage=invoice_preimage)


def test_invoice_routeboost(node_factory):
def test_invoice_routeboost(node_factory, bitcoind):
"""Test routeboost 'r' hint in bolt11 invoice.
"""
l1, l2 = node_factory.line_graph(2, announce=True, fundamount=10**4)
l1, l2 = node_factory.line_graph(2, fundamount=10**4)

# Won't get reference to route until channel is public.
inv = l2.rpc.invoice(msatoshi=123456, label="inv0", description="?")
assert 'warning_capacity' in inv

bitcoind.generate_block(5)
wait_for(lambda: [c['public'] for c in l2.rpc.listchannels()['channels']] == [True, True])

# Check routeboost.
# Make invoice and pay it
inv = l2.rpc.invoice(msatoshi=123456, label="inv1", description="?")
# Check routeboost.
Expand Down

0 comments on commit 030fe1c

Please sign in to comment.