mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-26 20:30:59 +01:00
lightningd: return features
in connect response.
This is useful in general, but in particular it allows fundchannel to avoid YA query to figure out if it can wumbo. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: JSON: `connect` returns `features` of the connected peer on success.
This commit is contained in:
parent
8cb364dd28
commit
41ebaffba3
7 changed files with 17 additions and 14 deletions
3
doc/lightning-connect.7
generated
3
doc/lightning-connect.7
generated
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
------
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue