diff --git a/doc/lightning-connect.7 b/doc/lightning-connect.7 index f3ec7ebf5a1f..20bac2c6d022 100644 --- a/doc/lightning-connect.7 +++ b/doc/lightning-connect.7 @@ -42,7 +42,8 @@ another node\. Once the peer is connected a channel can be opened with .SH RETURN VALUE -On success the peer \fIid\fR is returned\. +On success the peer \fIid\fR is returned, as well as a hexidecimal \fIfeatures\fR +bitmap\. .SH ERRORS diff --git a/doc/lightning-connect.7.md b/doc/lightning-connect.7.md index 48e0960220cc..572ee6d7d00b 100644 --- a/doc/lightning-connect.7.md +++ b/doc/lightning-connect.7.md @@ -39,7 +39,8 @@ lightning-fundchannel(7). RETURN VALUE ------------ -On success the peer *id* is returned. +On success the peer *id* is returned, as well as a hexidecimal *features* +bitmap. ERRORS ------ diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index 1e80e9701521..5e5d119ee56a 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -68,10 +68,11 @@ static struct connect *find_connect(struct lightningd *ld, } static struct command_result *connect_cmd_succeed(struct command *cmd, - const struct node_id *id) + const struct peer *peer) { struct json_stream *response = json_stream_success(cmd); - json_add_node_id(response, "id", id); + json_add_node_id(response, "id", &peer->id); + json_add_hex_talarr(response, "features", peer->features); return command_success(cmd, response); } @@ -139,7 +140,7 @@ static struct command_result *json_connect(struct command *cmd, if (peer->uncommitted_channel || (channel && channel->connected)) { - return connect_cmd_succeed(cmd, &id); + return connect_cmd_succeed(cmd, peer); } } @@ -256,14 +257,14 @@ static void connect_failed(struct lightningd *ld, const u8 *msg) delay_then_reconnect(channel, seconds_to_delay, addrhint); } -void connect_succeeded(struct lightningd *ld, const struct node_id *id) +void connect_succeeded(struct lightningd *ld, const struct peer *peer) { struct connect *c; /* We can have multiple connect commands: fail them all */ - while ((c = find_connect(ld, id)) != NULL) { + while ((c = find_connect(ld, &peer->id)) != NULL) { /* They delete themselves from list */ - connect_cmd_succeed(c->cmd, id); + connect_cmd_succeed(c->cmd, peer); } } diff --git a/lightningd/connect_control.h b/lightningd/connect_control.h index fed15ef6e1dd..64c5adaa8f40 100644 --- a/lightningd/connect_control.h +++ b/lightningd/connect_control.h @@ -12,7 +12,7 @@ void connectd_activate(struct lightningd *ld); void delay_then_reconnect(struct channel *channel, u32 seconds_delay, const struct wireaddr_internal *addrhint TAKES); -void connect_succeeded(struct lightningd *ld, const struct node_id *id); +void connect_succeeded(struct lightningd *ld, const struct peer *peer); void gossip_connect_result(struct lightningd *ld, const u8 *msg); #endif /* LIGHTNING_LIGHTNINGD_CONNECT_CONTROL_H */ diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 20cba0bf8846..a860312bc2dd 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -996,9 +996,6 @@ void peer_connected(struct lightningd *ld, const u8 *msg, per_peer_state_set_fds(hook_payload->pps, peer_fd, gossip_fd, gossip_store_fd); - /* Complete any outstanding connect commands. */ - connect_succeeded(ld, &id); - /* If we're already dealing with this peer, hand off to correct * subdaemon. Otherwise, we'll hand to openingd to wait there. */ peer = peer_by_id(ld, &id); @@ -1010,6 +1007,9 @@ void peer_connected(struct lightningd *ld, const u8 *msg, peer_update_features(peer, features); + /* Complete any outstanding connect commands. */ + connect_succeeded(ld, peer); + /* Can't be opening, since we wouldn't have sent peer_disconnected. */ assert(!peer->uncommitted_channel); hook_payload->channel = peer_active_channel(peer); diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index daf9e0c81b98..b42a9593fcda 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -78,7 +78,7 @@ struct command_result *command_success(struct command *cmd UNNEEDED, { fprintf(stderr, "command_success called!\n"); abort(); } /* Generated stub for connect_succeeded */ -void connect_succeeded(struct lightningd *ld UNNEEDED, const struct node_id *id UNNEEDED) +void connect_succeeded(struct lightningd *ld UNNEEDED, const struct peer *peer UNNEEDED) { fprintf(stderr, "connect_succeeded called!\n"); abort(); } /* Generated stub for delay_then_reconnect */ void delay_then_reconnect(struct channel *channel UNNEEDED, u32 seconds_delay UNNEEDED, diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index bd185443c3d1..146d698ce0ef 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -80,7 +80,7 @@ struct command_result *command_success(struct command *cmd UNNEEDED, { fprintf(stderr, "command_success called!\n"); abort(); } /* Generated stub for connect_succeeded */ -void connect_succeeded(struct lightningd *ld UNNEEDED, const struct node_id *id UNNEEDED) +void connect_succeeded(struct lightningd *ld UNNEEDED, const struct peer *peer UNNEEDED) { fprintf(stderr, "connect_succeeded called!\n"); abort(); } /* Generated stub for create_onionreply */ struct onionreply *create_onionreply(const tal_t *ctx UNNEEDED,