Skip to content

Commit 88216a5

Browse files
rustyrussellcdecker
authored andcommitted
rpc: report netaddr as array.
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]>
1 parent 58d22ea commit 88216a5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lightningd/peer_control.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,10 +842,12 @@ static void gossipd_getpeers_complete(struct subd *gossip, const u8 *msg,
842842
list_for_each(&gpa->cmd->ld->peers, p, list) {
843843
json_object_start(response, NULL);
844844
json_add_string(response, "state", peer_state_name(p->state));
845+
json_array_start(response, "netaddr");
845846
if (p->addr.type != ADDR_TYPE_PADDING)
846-
json_add_string(response, "netaddr",
847+
json_add_string(response, NULL,
847848
type_to_string(response, struct wireaddr,
848849
&p->addr));
850+
json_array_end(response);
849851
json_add_pubkey(response, "peerid", &p->id);
850852
json_add_bool(response, "connected", p->owner != NULL);
851853
if (p->owner)
@@ -880,9 +882,12 @@ static void gossipd_getpeers_complete(struct subd *gossip, const u8 *msg,
880882
/* Fake state. */
881883
json_add_string(response, "state", "GOSSIPING");
882884
json_add_pubkey(response, "peerid", ids+i);
883-
json_add_string(response, "netaddr",
884-
type_to_string(response, struct wireaddr,
885-
addrs + i));
885+
json_array_start(response, "netaddr");
886+
if (addrs[i].type != ADDR_TYPE_PADDING)
887+
json_add_string(response, NULL,
888+
type_to_string(response, struct wireaddr,
889+
addrs + i));
890+
json_array_end(response);
886891
json_add_bool(response, "connected", "true");
887892
json_add_string(response, "owner", gossip->name);
888893
json_object_end(response);

0 commit comments

Comments
 (0)