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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-11-11 12:09:23 +10:30 committed by Christian Decker
parent 89f016f524
commit f95afc55d8

View File

@ -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)
@ -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);