| 438 | }; |
| 439 | |
| 440 | static void getchaininfo_callback(const char *buf, const jsmntok_t *toks, |
| 441 | const jsmntok_t *idtok, |
| 442 | struct getchaininfo_call *call) |
| 443 | { |
| 444 | const char *err, *chain; |
| 445 | u32 headers, blocks; |
| 446 | bool ibd; |
| 447 | |
| 448 | err = json_scan(tmpctx, buf, toks, |
| 449 | "{result:{chain:%,headercount:%,blockcount:%,ibd:%}}", |
| 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 | bitcoin_plugin_error(call->bitcoind, buf, toks, "getchaininfo", |
| 456 | "bad 'result' field: %s", err); |
| 457 | |
| 458 | db_begin_transaction(call->bitcoind->ld->wallet->db); |
| 459 | call->cb(call->bitcoind, chain, headers, blocks, ibd, |
| 460 | call->first_call, call->cb_arg); |
| 461 | db_commit_transaction(call->bitcoind->ld->wallet->db); |
| 462 | |
| 463 | tal_free(call); |
| 464 | } |
| 465 | |
| 466 | void bitcoind_getchaininfo_(struct bitcoind *bitcoind, |
| 467 | const bool first_call, |
nothing calls this directly
no test coverage detected