From daa14f48f212409afd8bad38a30314aeb50ae070 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 19 Mar 2018 09:56:07 +1030 Subject: [PATCH] peer_control: don't list opening channels as connected=false. I saw a failure in test_funding_fail(): assert l2.rpc.listpeers()['peers'][0]['connected'] This can happen if l2 hasn't yet handed back to gossipd. Turns out we didn't mark uncommitted channels as connected: [{'id': '03afa3c78bb39217feb8aac308852e6383d59409839c2b91955b2d992421f4a41e', 'connected': False, 'channels': [{'state': 'OPENINGD', 'owner': 'lightning_openingd', 'funder': 'REMOTE', 'status': ['Incoming channel: accepted, now waiting for them to create funding tx']}]}] Signed-off-by: Rusty Russell --- lightningd/peer_control.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 32e6c4b67..8e348cd09 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -636,8 +636,14 @@ static void gossipd_getpeers_complete(struct subd *gossip, const u8 *msg, json_object_start(response, NULL); json_add_pubkey(response, "id", &p->id); - channel = peer_active_channel(p); - connected = (channel && channel->owner != NULL); + + /* Channel is also connected if uncommitted channel */ + if (p->uncommitted_channel) + connected = true; + else { + channel = peer_active_channel(p); + connected = channel && channel->owner; + } json_add_bool(response, "connected", connected); if (connected) {