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

Function getchaininfo_callback

lightningd/bitcoind.c:542–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540};
541
542static void getchaininfo_callback(const char *buf, const jsmntok_t *toks,
543 const jsmntok_t *idtok,
544 struct getchaininfo_call *call)
545{
546 const jsmntok_t *resulttok;
547 const char *err, *chain;
548 u32 headers, blocks;
549 bool ibd;
550
551 resulttok = get_bitcoin_result(call->bitcoind, buf, toks, "getchaininfo");
552
553 err = json_scan(tmpctx, buf, resulttok,
554 "{chain:%,headercount:%,blockcount:%,ibd:%}",
555 JSON_SCAN_TAL(tmpctx, json_strdup, &chain),
556 JSON_SCAN(json_to_number, &headers),
557 JSON_SCAN(json_to_number, &blocks),
558 JSON_SCAN(json_to_bool, &ibd));
559 if (err)
560 bitcoin_plugin_error(call->bitcoind, buf, resulttok, "getchaininfo",
561 "bad 'result' field: %s", err);
562
563 call->cb(call->bitcoind, chain, headers, blocks, ibd,
564 call->cb_arg);
565
566 tal_free(call);
567}
568
569void bitcoind_getchaininfo_(const tal_t *ctx,
570 struct bitcoind *bitcoind,

Callers

nothing calls this directly

Calls 4

get_bitcoin_resultFunction · 0.85
bitcoin_plugin_errorFunction · 0.85
tal_freeFunction · 0.85
json_scanFunction · 0.50

Tested by

no test coverage detected