mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
bcli: explicitly check at startup that bitcoind does relay transactions
We've had problems with blocksonly in the past and bitcoind still allows to use outdated (thus potentially dangerous estimates) while running bitcoin with -blocksonly. ZmnSCPxj mentionned that we still don't document this, but i figured that in this specific case an explicit check and error seems preferable. Changelog-Added: We now explicitly check at startup that our default Bitcoin backend (bitcoind) does relay transactions. Proposed-by: ZmnSCPxj <zmnscpxj@protonmail.com> Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
This commit is contained in:
parent
5be07c5fe3
commit
905730341a
2 changed files with 21 additions and 8 deletions
|
@ -31,7 +31,7 @@ Don't hesitate to reach out to us on IRC at [#lightning-dev @ freenode.net][irc1
|
|||
|
||||
## Getting Started
|
||||
|
||||
c-lightning only works on Linux and Mac OS, and requires a locally (or remotely) running `bitcoind` (version 0.16 or above) that is fully caught up with the network you're testing on.
|
||||
c-lightning only works on Linux and Mac OS, and requires a locally (or remotely) running `bitcoind` (version 0.16 or above) that is fully caught up with the network you're running on, and relays transactions (ie with `blocksonly=0`).
|
||||
Pruning (`prune=n` option in `bitcoin.conf`) is partially supported, see [here](#pruning) for more details.
|
||||
|
||||
### Installation
|
||||
|
|
|
@ -840,15 +840,16 @@ static void bitcoind_failure(struct plugin *p, const char *error_message)
|
|||
/* Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */
|
||||
static void parse_getnetworkinfo_result(struct plugin *p, const char *buf)
|
||||
{
|
||||
const jsmntok_t *result, *versiontok;
|
||||
bool valid;
|
||||
const jsmntok_t *result, *versiontok, *relaytok;
|
||||
bool valid, tx_relay;
|
||||
u32 min_version = 160000;
|
||||
|
||||
result = json_parse_input(NULL,
|
||||
buf, strlen(buf),
|
||||
&valid);
|
||||
if (!result || !valid)
|
||||
plugin_err(p, "No or invalid response to '%s' ? Got '%s'. Can not"
|
||||
" continue without proceeding to sanity checks.",
|
||||
plugin_err(p, "Invalid response to '%s': '%s'. Can not "
|
||||
"continue without proceeding to sanity checks.",
|
||||
gather_args(bitcoind, "getnetworkinfo", NULL), buf);
|
||||
|
||||
/* Check that we have a fully-featured `estimatesmartfee`. */
|
||||
|
@ -863,9 +864,21 @@ static void parse_getnetworkinfo_result(struct plugin *p, const char *buf)
|
|||
" continue without proceeding to sanity checks.",
|
||||
gather_args(bitcoind, "getnetworkinfo", NULL), buf);
|
||||
|
||||
if (bitcoind->version < 160000)
|
||||
plugin_err(p, "Unsupported bitcoind version, you need to update"
|
||||
" Bitcoin Core.");
|
||||
if (bitcoind->version < min_version)
|
||||
plugin_err(p, "Unsupported bitcoind version %"PRIu32", at least"
|
||||
" %"PRIu32" required.", bitcoind->version, min_version);
|
||||
|
||||
/* We don't support 'blocksonly', as we rely on transaction relay for fee
|
||||
* estimates. */
|
||||
relaytok = json_get_member(buf, result, "localrelay");
|
||||
if (!relaytok || !json_to_bool(buf, relaytok, &tx_relay))
|
||||
plugin_err(p, "No 'localrelay' in '%s' ? Got '%s'. Can not"
|
||||
" continue without proceeding to sanity checks.",
|
||||
gather_args(bitcoind, "getnetworkinfo", NULL), buf);
|
||||
|
||||
if (!tx_relay)
|
||||
plugin_err(p, "The 'blocksonly' mode of bitcoind, or any option "
|
||||
"deactivating transaction relay is not supported.");
|
||||
|
||||
tal_free(result);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue