Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */
| 747 | |
| 748 | /* Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */ |
| 749 | static 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 | |
| 786 | static void wait_and_check_bitcoind(struct plugin *p) |
| 787 | { |
no test coverage detected