MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_getinfo

Function json_getinfo

lightningd/peer_control.c:3558–3687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3556AUTODATA(json_command, &disconnect_command);
3557
3558static struct command_result *json_getinfo(struct command *cmd,
3559 const char *buffer,
3560 const jsmntok_t *obj UNNEEDED,
3561 const jsmntok_t *params)
3562{
3563 struct json_stream *response;
3564 struct peer *peer;
3565 struct channel *channel;
3566 unsigned int pending_channels = 0, active_channels = 0,
3567 inactive_channels = 0, num_peers = 0;
3568 size_t count_announceable;
3569 struct peer_node_id_map_iter it;
3570
3571 if (!param(cmd, buffer, params, NULL))
3572 return command_param_failed();
3573
3574 response = json_stream_success(cmd);
3575 json_add_node_id(response, "id", &cmd->ld->our_nodeid);
3576 json_add_string(response, "alias", (const char *)cmd->ld->alias);
3577 json_add_hex_talarr(response, "color", cmd->ld->rgb);
3578
3579 /* Add some peer and channel stats */
3580 for (peer = peer_node_id_map_first(cmd->ld->peers, &it);
3581 peer;
3582 peer = peer_node_id_map_next(cmd->ld->peers, &it)) {
3583 num_peers++;
3584
3585 list_for_each(&peer->channels, channel, list) {
3586 switch (channel->state) {
3587 case CHANNELD_AWAITING_LOCKIN:
3588 case DUALOPEND_OPEN_INIT:
3589 case DUALOPEND_OPEN_COMMIT_READY:
3590 case DUALOPEND_OPEN_COMMITTED:
3591 case DUALOPEND_AWAITING_LOCKIN:
3592 pending_channels++;
3593 continue;
3594 case CHANNELD_AWAITING_SPLICE:
3595 case CHANNELD_SHUTTING_DOWN:
3596 case CHANNELD_NORMAL:
3597 case CLOSINGD_SIGEXCHANGE:
3598 active_channels++;
3599 continue;
3600 case CLOSINGD_COMPLETE:
3601 case AWAITING_UNILATERAL:
3602 case FUNDING_SPEND_SEEN:
3603 case ONCHAIN:
3604 case CLOSED:
3605 inactive_channels++;
3606 continue;
3607 }
3608 abort();
3609 }
3610 }
3611 json_add_num(response, "num_peers", num_peers);
3612 json_add_num(response, "num_pending_channels", pending_channels);
3613 json_add_num(response, "num_active_channels", active_channels);
3614 json_add_num(response, "num_inactive_channels", inactive_channels);
3615

Callers

nothing calls this directly

Calls 15

json_add_node_idFunction · 0.85
json_add_hex_talarrFunction · 0.85
abortFunction · 0.85
json_add_numFunction · 0.85
json_array_startFunction · 0.85
json_add_addressFunction · 0.85
wireaddr_arr_containsFunction · 0.85
json_array_endFunction · 0.85
versionFunction · 0.85
topology_syncedFunction · 0.85
json_add_amount_msatFunction · 0.85

Tested by

no test coverage detected