diff --git a/daemon/bitcoind.c b/daemon/bitcoind.c index 1c7f7f009..8a4795658 100644 --- a/daemon/bitcoind.c +++ b/daemon/bitcoind.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -293,3 +295,34 @@ void bitcoind_create_payment(struct lightningd_state *dstate, start_bitcoin_cli(dstate, process_sendtoaddress, cb, peer, "sendtoaddress", addr, amtstr, NULL); } + +/* We make sure they have walletbroadcast=0, so we don't broadcast + * the anchor. */ +void check_bitcoind_config(struct lightningd_state *dstate) +{ + void *ctx = tal(dstate, char); + char *path, *config, **lines; + size_t i; + + path = path_simplify(ctx, path_join(ctx, path_cwd(ctx), + "../.bitcoin/bitcoin.conf")); + config = grab_file(ctx, path); + if (!config) { + log_unusual(dstate->base_log, "Could not open %s to check it", + path); + goto out; + } + + lines = tal_strsplit(ctx, config, "\n", STR_NO_EMPTY); + for (i = 0; lines[i]; i++) { + if (tal_strreg(ctx, lines[i], + "^[ \t]*walletbroadcast[ \t]*=[ \t]*0")) + goto out; + } + + + log_unusual(dstate->base_log, "%s does not contain walletbroadcast=0", + path); +out: + tal_free(ctx); +} diff --git a/daemon/bitcoind.h b/daemon/bitcoind.h index fe61be878..2b2a9e5bb 100644 --- a/daemon/bitcoind.h +++ b/daemon/bitcoind.h @@ -43,4 +43,5 @@ void bitcoind_create_payment(struct lightningd_state *dstate, struct peer *peer), struct peer *peer); +void check_bitcoind_config(struct lightningd_state *dstate); #endif /* LIGHTNING_DAEMON_BITCOIND_H */ diff --git a/daemon/lightningd.c b/daemon/lightningd.c index 586d20627..a67bfe9f1 100644 --- a/daemon/lightningd.c +++ b/daemon/lightningd.c @@ -1,3 +1,4 @@ +#include "bitcoind.h" #include "configdir.h" #include "jsonrpc.h" #include "lightningd.h" @@ -196,6 +197,8 @@ int main(int argc, char *argv[]) if (argc != 1) errx(1, "no arguments accepted"); + check_bitcoind_config(dstate); + /* Create RPC socket (if any) */ setup_jsonrpc(dstate, dstate->rpc_filename);