Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions doc/lightningd-config.5
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'\" t
.\" Title: lightningd-config
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: 04/11/2019
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/30/2019
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "LIGHTNINGD\-CONFIG" "5" "04/11/2019" "\ \&" "\ \&"
.TH "LIGHTNINGD\-CONFIG" "5" "06/30/2019" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -121,6 +121,11 @@ The bitcoind(1) RPC host to connect to\&.
The bitcoind(1) RPC port to connect to\&.
.RE
.PP
\fBbitcoin\-retry\-timeout\fR=\fISECONDS\fR
.RS 4
Number of seconds to keep trying a bitcoin\-cli(1) command\&. If the command keeps failing after this time, exit with a fatal error\&.
.RE
.PP
\fBrescan\fR=\fIBLOCKS\fR
.RS 4
Number of blocks to rescan from the current head, or absolute blockheight if negative\&. This is only needed if something goes badly wrong\&.
Expand Down
5 changes: 5 additions & 0 deletions doc/lightningd-config.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ Bitcoin control options:
*bitcoin-rpcport*='PORT'::
The bitcoind(1) RPC port to connect to.

*bitcoin-retry-timeout*='SECONDS'::
Number of seconds to keep trying a bitcoin-cli(1) command.
If the command keeps failing after this time, exit with a
fatal error.

*rescan*='BLOCKS'::
Number of blocks to rescan from the current head, or absolute blockheight
if negative. This is only needed if something goes badly wrong.
Expand Down
11 changes: 8 additions & 3 deletions lightningd/bitcoind.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ static void bcli_failure(struct bitcoind *bitcoind,
bitcoind->first_error_time = time_mono();

t = timemono_between(time_mono(), bitcoind->first_error_time);
if (time_greater(t, time_from_sec(60)))
fatal("%s exited %u (after %u other errors) '%.*s'",
if (time_greater(t, time_from_sec(bitcoind->retry_timeout)))
fatal("%s exited %u (after %u other errors) '%.*s'; "
"we have been retrying command for "
"--bitcoin-retry-timeout=%"PRIu64" seconds; "
"bitcoind setup or our --bitcoin-* configs broken?",
bcli_args(tmpctx, bcli),
exitstatus,
bitcoind->error_count,
(int)bcli->output_bytes,
bcli->output);
bcli->output,
bitcoind->retry_timeout);

log_unusual(bitcoind->log,
"%s exited with status %u",
Expand Down Expand Up @@ -876,6 +880,7 @@ struct bitcoind *new_bitcoind(const tal_t *ctx,
}
bitcoind->shutdown = false;
bitcoind->error_count = 0;
bitcoind->retry_timeout = 60;
bitcoind->rpcuser = NULL;
bitcoind->rpcpass = NULL;
bitcoind->rpcconnect = NULL;
Expand Down
4 changes: 4 additions & 0 deletions lightningd/bitcoind.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ struct bitcoind {
/* Ignore results, we're shutting down. */
bool shutdown;

/* How long to keep trying to contact bitcoind
* before fatally exiting. */
u64 retry_timeout;

/* Passthrough parameters for bitcoin-cli */
char *rpcuser, *rpcpass, *rpcconnect, *rpcport;
};
Expand Down
6 changes: 6 additions & 0 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,12 @@ void register_opts(struct lightningd *ld)
opt_register_arg("--bitcoin-rpcport", opt_set_talstr, NULL,
&ld->topology->bitcoind->rpcport,
"bitcoind RPC port");
opt_register_arg("--bitcoin-retry-timeout",
opt_set_u64, opt_show_u64,
&ld->topology->bitcoind->retry_timeout,
"how long to keep trying to contact bitcoind "
"before fatally exiting");

opt_register_arg("--pid-file=<file>", opt_set_talstr, opt_show_charp,
&ld->pidfile,
"Specify pid file");
Expand Down