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

Function process_getblockchaininfo

plugins/bcli.c:434–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434static struct command_result *process_getblockchaininfo(struct bitcoin_cli *bcli)
435{
436 const jsmntok_t *tokens;
437 struct json_stream *response;
438 bool ibd;
439 u32 headers, blocks;
440 const char *chain, *err;
441
442 tokens = json_parse_simple(bcli->output,
443 bcli->output, bcli->output_bytes);
444 if (!tokens) {
445 return command_err_bcli_badjson(bcli, "cannot parse");
446 }
447
448 err = json_scan(tmpctx, bcli->output, tokens,
449 "{chain:%,headers:%,blocks:%,initialblockdownload:%}",
450 JSON_SCAN_TAL(tmpctx, json_strdup, &chain),
451 JSON_SCAN(json_to_number, &headers),
452 JSON_SCAN(json_to_number, &blocks),
453 JSON_SCAN(json_to_bool, &ibd));
454 if (err)
455 return command_err_bcli_badjson(bcli, err);
456
457 response = jsonrpc_stream_success(bcli->cmd);
458 json_add_string(response, "chain", chain);
459 json_add_u32(response, "headercount", headers);
460 json_add_u32(response, "blockcount", blocks);
461 json_add_bool(response, "ibd", ibd);
462
463 return command_finished(bcli->cmd, response);
464}
465
466enum feerate_levels {
467 FEERATE_HIGHEST,

Callers

nothing calls this directly

Calls 8

command_err_bcli_badjsonFunction · 0.85
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
json_parse_simpleFunction · 0.50
json_scanFunction · 0.50
json_add_stringFunction · 0.50
json_add_u32Function · 0.50
json_add_boolFunction · 0.50

Tested by

no test coverage detected