Skip to content

Commit

Permalink
rpc: report netaddr as array.
Browse files Browse the repository at this point in the history
Thought we don't handle it at the moment, nodes can certainly have multiple
addresses, and we should display them all.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Nov 12, 2017
1 parent 89f016f commit f95afc5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,12 @@ static void gossipd_getpeers_complete(struct subd *gossip, const u8 *msg,
list_for_each(&gpa->cmd->ld->peers, p, list) {
json_object_start(response, NULL);
json_add_string(response, "state", peer_state_name(p->state));
json_array_start(response, "netaddr");
if (p->addr.type != ADDR_TYPE_PADDING)
json_add_string(response, "netaddr",
json_add_string(response, NULL,
type_to_string(response, struct wireaddr,
&p->addr));
json_array_end(response);
json_add_pubkey(response, "peerid", &p->id);
json_add_bool(response, "connected", p->owner != NULL);
if (p->owner)
Expand Down Expand Up @@ -880,9 +882,12 @@ static void gossipd_getpeers_complete(struct subd *gossip, const u8 *msg,
/* Fake state. */
json_add_string(response, "state", "GOSSIPING");
json_add_pubkey(response, "peerid", ids+i);
json_add_string(response, "netaddr",
type_to_string(response, struct wireaddr,
addrs + i));
json_array_start(response, "netaddr");
if (addrs[i].type != ADDR_TYPE_PADDING)
json_add_string(response, NULL,
type_to_string(response, struct wireaddr,
addrs + i));
json_array_end(response);
json_add_bool(response, "connected", "true");
json_add_string(response, "owner", gossip->name);
json_object_end(response);
Expand Down

0 comments on commit f95afc5

Please sign in to comment.