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

Function getchaininfo_callback

lightningd/bitcoind.c:440–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438};
439
440static 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
466void bitcoind_getchaininfo_(struct bitcoind *bitcoind,
467 const bool first_call,

Callers

nothing calls this directly

Calls 4

bitcoin_plugin_errorFunction · 0.85
tal_freeFunction · 0.85
json_scanFunction · 0.50
db_commit_transactionFunction · 0.50

Tested by

no test coverage detected