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

Function parse_getnetworkinfo_result

plugins/bcli.c:826–860  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

824
825/* Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */
826static void parse_getnetworkinfo_result(struct plugin *p, const char *buf)
827{
828 const jsmntok_t *result;
829 bool tx_relay;
830 u32 min_version = 160000;
831 const char *err;
832
833 result = json_parse_simple(NULL, buf, strlen(buf));
834 if (!result)
835 plugin_err(p, "Invalid response to '%s': '%s'. Can not "
836 "continue without proceeding to sanity checks.",
837 gather_args(bitcoind, "getnetworkinfo", NULL), buf);
838
839 /* Check that we have a fully-featured `estimatesmartfee`. */
840 err = json_scan(tmpctx, buf, result, "{version:%,localrelay:%}",
841 JSON_SCAN(json_to_u32, &bitcoind->version),
842 JSON_SCAN(json_to_bool, &tx_relay));
843 if (err)
844 plugin_err(p, "%s. Got '%s'. Can not"
845 " continue without proceeding to sanity checks.",
846 err,
847 gather_args(bitcoind, "getnetworkinfo", NULL), buf);
848
849 if (bitcoind->version < min_version)
850 plugin_err(p, "Unsupported bitcoind version %"PRIu32", at least"
851 " %"PRIu32" required.", bitcoind->version, min_version);
852
853 /* We don't support 'blocksonly', as we rely on transaction relay for fee
854 * estimates. */
855 if (!tx_relay)
856 plugin_err(p, "The 'blocksonly' mode of bitcoind, or any option "
857 "deactivating transaction relay is not supported.");
858
859 tal_free(result);
860}
861
862static void wait_and_check_bitcoind(struct plugin *p)
863{

Callers 1

wait_and_check_bitcoindFunction · 0.85

Calls 5

tal_freeFunction · 0.85
plugin_errFunction · 0.70
gather_argsFunction · 0.70
json_parse_simpleFunction · 0.50
json_scanFunction · 0.50

Tested by

no test coverage detected