Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */
| 740 | |
| 741 | /* Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */ |
| 742 | static 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 | |
| 779 | static void wait_and_check_bitcoind(struct plugin *p) |
| 780 | { |
no test coverage detected