diff --git a/README.md b/README.md index d778c4a54..1e269fd04 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,8 @@ cli/lightning-cli fundchannel ``` This opens a connection and, on top of that connection, then opens a channel. -The funding transaction needs 6 confirmations in order for the channel to be usable. -You can check the status of the channel using `cli/lightning-cli getpeers`, which after 1 confirmation should say that the status is in _Normal operation_. -After 6 confirmations you can use `cli/lightning-cli getchannels` to verify that the channel shows up in the list of open channels. +The funding transaction needs 1 confirmations in order for the channel to be usable, and 6 to be broadcast for others to use. +You can check the status of the channel using `cli/lightning-cli getpeers`, which after 1 confirmation should say that `state` is `CHANNELD_NORMAL`; after 6 confirmations you can use `cli/lightning-cli getchannels` to verify that the `public` field is now `true`. ### Receiving and receiving payments diff --git a/gossipd/gossip.c b/gossipd/gossip.c index 9a4a83263..bc82e79bb 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -1059,6 +1059,7 @@ static struct io_plan *getchannels_req(struct io_conn *conn, struct daemon *daem entries[num_chans].destination = n->out[j]->dst->id; entries[num_chans].active = n->out[j]->active; entries[num_chans].flags = n->out[j]->flags; + entries[num_chans].public = (n->out[j]->channel_update != NULL); entries[num_chans].short_channel_id = n->out[j]->short_channel_id; entries[num_chans].last_update_timestamp = n->out[j]->last_timestamp; if (entries[num_chans].last_update_timestamp >= 0) { diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 6e2dd4984..48d285eba 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -292,6 +292,7 @@ static void json_getchannels_reply(struct subd *gossip, const u8 *reply, &entries[i].short_channel_id)); json_add_num(response, "flags", entries[i].flags); json_add_bool(response, "active", entries[i].active); + json_add_bool(response, "public", entries[i].public); if (entries[i].last_update_timestamp >= 0) { json_add_num(response, "last_update", entries[i].last_update_timestamp); diff --git a/lightningd/gossip_msg.c b/lightningd/gossip_msg.c index 6ad59863a..2b14cde09 100644 --- a/lightningd/gossip_msg.c +++ b/lightningd/gossip_msg.c @@ -51,6 +51,7 @@ void fromwire_gossip_getchannels_entry(const u8 **pptr, size_t *max, fromwire_pubkey(pptr, max, &entry->destination); entry->active = fromwire_bool(pptr, max); entry->flags = fromwire_u16(pptr, max); + entry->public = fromwire_bool(pptr, max); entry->last_update_timestamp = fromwire_u64(pptr, max); if (entry->last_update_timestamp >= 0) { entry->base_fee_msat = fromwire_u32(pptr, max); @@ -67,6 +68,7 @@ void towire_gossip_getchannels_entry( towire_pubkey(pptr, &entry->destination); towire_bool(pptr, entry->active); towire_u16(pptr, entry->flags); + towire_bool(pptr, entry->public); towire_u64(pptr, entry->last_update_timestamp); if (entry->last_update_timestamp >= 0) { towire_u32(pptr, entry->base_fee_msat); diff --git a/lightningd/gossip_msg.h b/lightningd/gossip_msg.h index d594f444a..d7ffbd856 100644 --- a/lightningd/gossip_msg.h +++ b/lightningd/gossip_msg.h @@ -14,6 +14,7 @@ struct gossip_getchannels_entry { bool active; struct short_channel_id short_channel_id; u16 flags; + bool public; s64 last_update_timestamp; /* -1 means never */ /* These are only set if last_update_timestamp >= 0 */ u32 delay; diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index a9e7f5d2e..7156ef4f6 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -1342,6 +1342,17 @@ class LightningDTests(BaseLightningDTests): # Make sure we can route through the channel, will raise on failure l1.rpc.getroute(l2.info['id'], 100, 1) + # Outgoing should be active, but not public. + channels = l1.rpc.getchannels()['channels'] + assert len(channels) == 1 + assert channels[0]['active'] == True + assert channels[0]['public'] == False + + channels = l2.rpc.getchannels()['channels'] + assert len(channels) == 1 + assert channels[0]['active'] == True + assert channels[0]['public'] == False + # Now proceed to funding-depth and do a full gossip round l1.bitcoin.generate_block(5) # Could happen in either order. @@ -1358,9 +1369,16 @@ class LightningDTests(BaseLightningDTests): l1.daemon.wait_for_log('peer_in WIRE_CHANNEL_UPDATE') l2.daemon.wait_for_log('peer_in WIRE_CHANNEL_UPDATE') + # Now should be active and public. channels = l1.rpc.getchannels()['channels'] assert len(channels) == 2 - wait_for(lambda: [c['active'] for c in channels] == [True, True]) + assert [c['active'] for c in channels] == [True, True] + assert [c['public'] for c in channels] == [True, True] + + channels = l2.rpc.getchannels()['channels'] + assert len(channels) == 2 + assert [c['active'] for c in channels] == [True, True] + assert [c['public'] for c in channels] == [True, True] def ping_tests(self, l1, l2): # 0-byte pong gives just type + length field.