Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */
| 824 | |
| 825 | /* Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */ |
| 826 | static 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 | |
| 862 | static void wait_and_check_bitcoind(struct plugin *p) |
| 863 | { |
no test coverage detected