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

Function parse_getnetworkinfo_result

plugins/bcli.c:749–784  ·  view source on GitHub ↗

Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */

Source from the content-addressed store, hash-verified

747
748/* Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */
749static void parse_getnetworkinfo_result(struct plugin *p, const char *buf)
750{
751 const jsmntok_t *result;
752 bool tx_relay;
753 u32 min_version = 220000;
754 const char *err;
755
756 result = json_parse_simple(NULL, buf, strlen(buf));
757 if (!result)
758 plugin_err(p, "Invalid response to '%s': '%s'. Can not "
759 "continue without proceeding to sanity checks.",
760 args_string(tmpctx, gather_args(bitcoind, NULL, "getnetworkinfo", NULL), NULL),
761 buf);
762
763 /* Check that we have a fully-featured `estimatesmartfee`. */
764 err = json_scan(tmpctx, buf, result, "{version:%,localrelay:%}",
765 JSON_SCAN(json_to_u32, &bitcoind->version),
766 JSON_SCAN(json_to_bool, &tx_relay));
767 if (err)
768 plugin_err(p, "%s. Got '%.*s'. Can not"
769 " continue without proceeding to sanity checks.",
770 err,
771 json_tok_full_len(result), json_tok_full(buf, result));
772
773 if (bitcoind->version < min_version)
774 plugin_err(p, "Unsupported bitcoind version %"PRIu32", at least"
775 " %"PRIu32" required.", bitcoind->version, min_version);
776
777 /* We don't support 'blocksonly', as we rely on transaction relay for fee
778 * estimates. */
779 if (!tx_relay)
780 plugin_err(p, "The 'blocksonly' mode of bitcoind, or any option "
781 "deactivating transaction relay is not supported.");
782
783 tal_free(result);
784}
785
786static void wait_and_check_bitcoind(struct plugin *p)
787{

Callers 1

wait_and_check_bitcoindFunction · 0.85

Calls 8

json_parse_simpleFunction · 0.85
args_stringFunction · 0.85
tal_freeFunction · 0.85
plugin_errFunction · 0.70
gather_argsFunction · 0.70
json_scanFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected