mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
bitcoind: warn if their bitcoin config not on testnet/regtest.
Otherwise you get weird errors as bitcoind refuses our testnet addresses. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
34e32978b8
commit
980d0d2bf1
@ -303,6 +303,8 @@ void check_bitcoind_config(struct lightningd_state *dstate)
|
|||||||
void *ctx = tal(dstate, char);
|
void *ctx = tal(dstate, char);
|
||||||
char *path, *config, **lines;
|
char *path, *config, **lines;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
bool nowalletbroadcast = false;
|
||||||
|
int testnet = -1, regtest = -1;
|
||||||
|
|
||||||
path = path_simplify(ctx, path_join(ctx, path_cwd(ctx),
|
path = path_simplify(ctx, path_join(ctx, path_cwd(ctx),
|
||||||
"../.bitcoin/bitcoin.conf"));
|
"../.bitcoin/bitcoin.conf"));
|
||||||
@ -315,14 +317,32 @@ void check_bitcoind_config(struct lightningd_state *dstate)
|
|||||||
|
|
||||||
lines = tal_strsplit(ctx, config, "\n", STR_NO_EMPTY);
|
lines = tal_strsplit(ctx, config, "\n", STR_NO_EMPTY);
|
||||||
for (i = 0; lines[i]; i++) {
|
for (i = 0; lines[i]; i++) {
|
||||||
|
char *str;
|
||||||
if (tal_strreg(ctx, lines[i],
|
if (tal_strreg(ctx, lines[i],
|
||||||
"^[ \t]*walletbroadcast[ \t]*=[ \t]*0"))
|
"^[ \t]*walletbroadcast[ \t]*=[ \t]*0"))
|
||||||
goto out;
|
nowalletbroadcast = true;
|
||||||
|
else if (tal_strreg(ctx, lines[i],
|
||||||
|
"^[ \t]*testnet[ \t]*=[ \t]*([01])", &str))
|
||||||
|
testnet = atoi(str);
|
||||||
|
else if (tal_strreg(ctx, lines[i],
|
||||||
|
"^[ \t]*regtest[ \t]*=[ \t]*([01])", &str))
|
||||||
|
regtest = atoi(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!nowalletbroadcast)
|
||||||
log_unusual(dstate->base_log, "%s does not contain walletbroadcast=0",
|
log_unusual(dstate->base_log,
|
||||||
|
"%s does not contain walletbroadcast=0",
|
||||||
path);
|
path);
|
||||||
|
if (dstate->config.testnet) {
|
||||||
|
if (testnet != 1 && regtest != 1)
|
||||||
|
log_unusual(dstate->base_log,
|
||||||
|
"%s does not set testnet/regtest,"
|
||||||
|
" but we are on testnet.",
|
||||||
|
path);
|
||||||
|
} else if (testnet == 1 || regtest == 1)
|
||||||
|
log_unusual(dstate->base_log,
|
||||||
|
"%s sets %s, but we are not on testnet",
|
||||||
|
path, testnet == 1 ? "testnet" : "regtest");
|
||||||
out:
|
out:
|
||||||
tal_free(ctx);
|
tal_free(ctx);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user