From 5953a5051c5b1e30b99adb6ee57eb1bf363f6055 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 2 Sep 2019 17:48:37 +0200 Subject: [PATCH] cli: Add command line option to specify the wallet location Will be demuxed into starting the selected DB backend in one of the next commits. Defaults to the old database location. Signed-off-by: Christian Decker --- doc/lightningd-config.5 | 6 ++++++ doc/lightningd-config.5.md | 5 +++++ lightningd/lightningd.h | 2 ++ lightningd/options.c | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/doc/lightningd-config.5 b/doc/lightningd-config.5 index 9cdf50e09..161c8cdba 100644 --- a/doc/lightningd-config.5 +++ b/doc/lightningd-config.5 @@ -149,6 +149,12 @@ is a relative path, it is relative to the starting directory, not readable (we allow missing files in the default case)\. Using this inside a configuration file is meaningless\. + + \fBwallet\fR=\fIDSN\fR +Identify the location of the wallet\. This is a fully qualified data source +name, including a scheme such as \fBsqlite3\fR or \fBpostgres\fR followed by the +connection parameters\. + .SH Lightning node customization options \fBalias\fR=\fIRRGGBB\fR diff --git a/doc/lightningd-config.5.md b/doc/lightningd-config.5.md index 1b6a08ea6..7b341fbe3 100644 --- a/doc/lightningd-config.5.md +++ b/doc/lightningd-config.5.md @@ -128,6 +128,11 @@ is a relative path, it is relative to the starting directory, not readable (we allow missing files in the default case). Using this inside a configuration file is meaningless. + **wallet**=*DSN* +Identify the location of the wallet. This is a fully qualified data source +name, including a scheme such as `sqlite3` or `postgres` followed by the +connection parameters. + ### Lightning node customization options **alias**=*RRGGBB* diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 04e08ceae..06452c58f 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -228,6 +228,8 @@ struct lightningd { const char *original_directory; struct plugins *plugins; + + char *wallet_dsn; }; /* Turning this on allows a tal allocation to return NULL, rather than aborting. diff --git a/lightningd/options.c b/lightningd/options.c index 613604388..8b35ce8ab 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -808,6 +808,11 @@ static void handle_minimal_config_opts(struct lightningd *ld, opt_ignore_talstr, opt_show_charp, &ld->config_dir, "Set working directory. All other files are relative to this"); + + ld->wallet_dsn = tal_fmt(ld, "sqlite3://%s/lightningd.sqlite3", ld->config_dir); + opt_register_early_arg("--wallet", opt_set_talstr, NULL, + &ld->wallet_dsn, + "Location of the wallet database."); } static void register_opts(struct lightningd *ld)