| 432 | } |
| 433 | |
| 434 | static 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 | |
| 466 | enum feerate_levels { |
| 467 | FEERATE_HIGHEST, |
nothing calls this directly
no test coverage detected