channeld: support private channel creation, fixes #2125

Adds a new 'announce' field for `fundchannel`, which if false
won't broadcast a `channel_announcement`.
This commit is contained in:
lisa neigut
2018-12-07 15:38:41 -08:00
committed by neil saitug
parent eab992cecd
commit a39c97c960
5 changed files with 47 additions and 5 deletions

View File

@@ -791,6 +791,21 @@ def test_channel_persistence(node_factory, bitcoind, executor):
l1.daemon.wait_for_log(' to ONCHAIN')
def test_private_channel(node_factory):
l1, l2 = node_factory.line_graph(2, announce_channels=False, wait_for_announce=False)
l3, l4 = node_factory.line_graph(2, announce_channels=True, wait_for_announce=True)
assert l1.daemon.is_in_log('Will open private channel with node {}'.format(l2.info['id']))
assert not l2.daemon.is_in_log('Will open private channel with node {}'.format(l1.info['id']))
assert not l3.daemon.is_in_log('Will open private channel with node {}'.format(l4.info['id']))
l3.daemon.wait_for_log('Received node_announcement for node {}'.format(l4.info['id']))
l4.daemon.wait_for_log('Received node_announcement for node {}'.format(l3.info['id']))
assert not l1.daemon.is_in_log('Received node_announcement for node {}'.format(l2.info['id']))
assert not l2.daemon.is_in_log('Received node_announcement for node {}'.format(l1.info['id']))
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for --dev-broadcast-interval")
def test_channel_reenable(node_factory):
l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True}, fundchannel=True, wait_for_announce=True)

View File

@@ -788,9 +788,10 @@ class NodeFactory(object):
raise
return node
def line_graph(self, num_nodes, fundchannel=True, fundamount=10**6, wait_for_announce=False, opts=None):
def line_graph(self, num_nodes, fundchannel=True, fundamount=10**6, wait_for_announce=False, opts=None, announce_channels=True):
""" Create nodes, connect them and optionally fund channels.
"""
assert not (wait_for_announce and not announce_channels), "You've asked to wait for an announcement that's not coming. (wait_for_announce=True,announce_channels=False)"
nodes = self.get_nodes(num_nodes, opts=opts)
bitcoin = nodes[0].bitcoin
connections = [(nodes[i], nodes[i + 1]) for i in range(0, num_nodes - 1)]
@@ -813,7 +814,7 @@ class NodeFactory(object):
bitcoin.generate_block(1)
for src, dst in connections:
wait_for(lambda: len(src.rpc.listfunds()['outputs']) > 0)
tx = src.rpc.fundchannel(dst.info['id'], fundamount)
tx = src.rpc.fundchannel(dst.info['id'], fundamount, announce=announce_channels)
wait_for(lambda: tx['txid'] in bitcoin.rpc.getrawmempool())
# Confirm all channels and wait for them to become usable