lightningd: change config-dir from plugin / wallet / hsm POV into <network> subdir

Changelog-changed: .lightningd plugins and files moved into <network>/ subdir
Changelog-changed: WARNING: If you don't have a config file, you now may need to specify the network to lightning-cli
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-11-23 12:16:40 +10:30
parent dc23c308e4
commit aab83e729b
20 changed files with 143 additions and 98 deletions

View File

@@ -111,13 +111,14 @@ static void copy_column(void *dst, size_t size,
int main(int argc, char *argv[])
{
char *config_dir, *config_filename, *rpc_filename, *hsmfile, *dbfile;
char *config_dir, *net_dir, *config_filename, *rpc_filename, *hsmfile, *dbfile;
sqlite3 *sql;
sqlite3_stmt *stmt;
int flags = SQLITE_OPEN_READONLY, dberr;
struct secret *hsm_secret;
bool verbose = false;
size_t num, num_ok;
const tal_t *top_ctx = tal(NULL, char);
setup_locale();
wally_init(0);
@@ -125,8 +126,9 @@ int main(int argc, char *argv[])
setup_option_allocators();
initial_config_opts(NULL, argc, argv,
&config_filename, &config_dir, &rpc_filename);
initial_config_opts(top_ctx, argc, argv,
&config_filename, &config_dir, &net_dir,
&rpc_filename);
opt_register_noarg("-v|--verbose", opt_set_bool, &verbose,
"Print everything");
@@ -135,8 +137,8 @@ int main(int argc, char *argv[])
if (argc != 1)
errx(1, "no arguments accepted");
hsmfile = path_join(config_dir, config_dir, "hsm_secret");
dbfile = path_join(config_dir, config_dir, "lightningd.sqlite3");
hsmfile = path_join(top_ctx, net_dir, "hsm_secret");
dbfile = path_join(top_ctx, net_dir, "lightningd.sqlite3");
dberr = sqlite3_open_v2(dbfile, &sql, flags, NULL);
if (dberr != SQLITE_OK)
@@ -235,5 +237,5 @@ int main(int argc, char *argv[])
printf("\nCheck passed!\n");
else
errx(1, "%zu channels incorrect.", num - num_ok);
tal_free(config_dir);
tal_free(top_ctx);
}