From 030fe1ce53b618d9c935ae2783901ba183643ccf Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 15 Oct 2018 15:23:55 +1030 Subject: [PATCH] gossipd: don't expose private channels for routeboost. 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 --- gossipd/gossipd.c | 4 ++++ tests/test_invoices.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index d821702fe..f74f5efdf 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -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)) diff --git a/tests/test_invoices.py b/tests/test_invoices.py index 24681fc84..6b9f59d92 100644 --- a/tests/test_invoices.py +++ b/tests/test_invoices.py @@ -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.