diff --git a/doc/lightningd-config.5 b/doc/lightningd-config.5
index 039d7ddba..d11e421bb 100644
--- a/doc/lightningd-config.5
+++ b/doc/lightningd-config.5
@@ -2,12 +2,12 @@
.\" Title: lightningd-config
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1
-.\" Date: 06/23/2018
+.\" Date: 07/12/2018
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "LIGHTNINGD\-CONFIG" "5" "06/23/2018" "\ \&" "\ \&"
+.TH "LIGHTNINGD\-CONFIG" "5" "07/12/2018" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -168,6 +168,11 @@ Set JSON\-RPC socket (or /dev/tty), such as for lightning\-cli(1)\&.
.RS 4
Run in the background, suppress stdout and stderr\&.
.RE
+.PP
+\fBconf\fR=\fIPATH\fR
+.RS 4
+Sets configuration file\&. Relative paths will be prefixed by lightning\-dir location\&. (default: config)
+.RE
.sp
Lightning node customization options:
.PP
diff --git a/doc/lightningd-config.5.txt b/doc/lightningd-config.5.txt
index f7fb97af9..342db6e08 100644
--- a/doc/lightningd-config.5.txt
+++ b/doc/lightningd-config.5.txt
@@ -91,7 +91,7 @@ Bitcoin control options:
*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.
+ if negative. This is only needed if something goes badly wrong.
Lightning daemon options:
@@ -117,6 +117,9 @@ Lightning daemon options:
*daemon*::
Run in the background, suppress stdout and stderr.
+*conf*='PATH'::
+ Sets configuration file. Relative paths will be prefixed by lightning-dir location. (default: config)
+
Lightning node customization options:
*rgb*='RRGGBB'::
diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c
index d520d0f1c..99995c1b9 100644
--- a/lightningd/lightningd.c
+++ b/lightningd/lightningd.c
@@ -80,6 +80,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
timers_init(&ld->timers, time_mono());
ld->topology = new_topology(ld, ld->log);
ld->daemon = false;
+ ld->config_filename = NULL;
ld->pidfile = NULL;
ld->ini_autocleaninvoice_cycle = 0;
ld->ini_autocleaninvoice_expiredby = 86400;
diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h
index 3a979507c..f085a881d 100644
--- a/lightningd/lightningd.h
+++ b/lightningd/lightningd.h
@@ -80,6 +80,8 @@ struct lightningd {
char *config_dir;
char *rpc_filename;
+ /* Configuration file name */
+ char *config_filename;
/* Configuration settings. */
struct config config;
diff --git a/lightningd/options.c b/lightningd/options.c
index 137979a51..6852cf536 100644
--- a/lightningd/options.c
+++ b/lightningd/options.c
@@ -339,6 +339,9 @@ static char *opt_set_locktime(const char *arg, u32 *u)
static void config_register_opts(struct lightningd *ld)
{
+ opt_register_early_arg("--conf=", opt_set_talstr, NULL,
+ &ld->config_filename,
+ "Specify configuration file. Relative paths will be prefixed by lightning-dir location. (default: config)");
opt_register_noarg("--daemon", opt_set_bool, &ld->daemon,
"Run in the background, suppress stdout/stderr");
opt_register_arg("--ignore-fee-limits", opt_set_bool_arg, opt_show_bool,
@@ -697,10 +700,14 @@ static void opt_parse_from_config(struct lightningd *ld)
char *argv[3];
int i, argc;
- contents = grab_file(ld, "config");
- /* Doesn't have to exist. */
+ if (ld->config_filename != NULL) {
+ contents = grab_file(ld, ld->config_filename);
+ } else
+ contents = grab_file(ld, "config");
+ /* The default config doesn't have to exist, but if the config was
+ * specified on the command line it has to exist. */
if (!contents) {
- if (errno != ENOENT)
+ if ((errno != ENOENT) || (ld->config_filename != NULL))
fatal("Opening and reading config: %s",
strerror(errno));
/* Now we can set up defaults, since no config file. */