Browse Source

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 <rusty@rustcorp.com.au>
fee-tracking2
Rusty Russell 6 years ago
parent
commit
030fe1ce53
  1. 4
      gossipd/gossipd.c
  2. 12
      tests/test_invoices.py

4
gossipd/gossipd.c

@ -1538,6 +1538,10 @@ static struct io_plan *get_incoming_channels(struct io_conn *conn,
const struct half_chan *hc; const struct half_chan *hc;
struct route_info *ri; struct route_info *ri;
/* Don't leak private channels. */
if (!is_chan_public(c))
continue;
hc = &c->half[half_chan_to(node, c)]; hc = &c->half[half_chan_to(node, c)];
if (!is_halfchan_enabled(hc)) if (!is_halfchan_enabled(hc))

12
tests/test_invoices.py

@ -117,11 +117,19 @@ def test_invoice_preimage(node_factory):
l2.rpc.invoice(123456, 'inv2', '?', preimage=invoice_preimage) 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. """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 # Make invoice and pay it
inv = l2.rpc.invoice(msatoshi=123456, label="inv1", description="?") inv = l2.rpc.invoice(msatoshi=123456, label="inv1", description="?")
# Check routeboost. # Check routeboost.

Loading…
Cancel
Save