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

Function parse_getnetworkinfo_result

plugins/bcli.c:742–777  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

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