mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-09 00:54:22 +01:00
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:
@@ -431,7 +431,7 @@ int main(int argc, char *argv[])
|
||||
jsmntok_t *toks;
|
||||
const jsmntok_t *result, *error, *id;
|
||||
const tal_t *ctx = tal(NULL, char);
|
||||
char *config_filename, *lightning_dir, *rpc_filename;
|
||||
char *config_filename, *lightning_dir, *net_dir, *rpc_filename;
|
||||
jsmn_parser parser;
|
||||
int parserr;
|
||||
enum format format = DEFAULT_FORMAT;
|
||||
@@ -446,7 +446,8 @@ int main(int argc, char *argv[])
|
||||
setup_option_allocators();
|
||||
|
||||
initial_config_opts(ctx, argc, argv,
|
||||
&config_filename, &lightning_dir, &rpc_filename);
|
||||
&config_filename, &lightning_dir, &net_dir,
|
||||
&rpc_filename);
|
||||
|
||||
opt_register_noarg("--help|-h", opt_usage_and_exit,
|
||||
"<command> [<params>...]", "Show this message. Use the command help (without hyphens -- \"lightning-cli help\") to get a list of all RPC commands");
|
||||
@@ -491,9 +492,9 @@ int main(int argc, char *argv[])
|
||||
tal_free(page);
|
||||
}
|
||||
|
||||
if (chdir(lightning_dir) != 0)
|
||||
if (chdir(net_dir) != 0)
|
||||
err(ERROR_TALKING_TO_LIGHTNINGD, "Moving into '%s'",
|
||||
lightning_dir);
|
||||
net_dir);
|
||||
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (strlen(rpc_filename) + 1 > sizeof(addr.sun_path))
|
||||
@@ -627,8 +628,6 @@ int main(int argc, char *argv[])
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
tal_free(lightning_dir);
|
||||
tal_free(rpc_filename);
|
||||
tal_free(ctx);
|
||||
opt_free_table();
|
||||
return 0;
|
||||
@@ -641,8 +640,6 @@ int main(int argc, char *argv[])
|
||||
print_json(resp, error, "");
|
||||
printf("\n");
|
||||
}
|
||||
tal_free(lightning_dir);
|
||||
tal_free(rpc_filename);
|
||||
tal_free(ctx);
|
||||
opt_free_table();
|
||||
return 1;
|
||||
|
||||
@@ -15,6 +15,7 @@ int test_connect(int sockfd, const struct sockaddr *addr,
|
||||
socklen_t addrlen);
|
||||
int test_getpid(void);
|
||||
int test_printf(const char *format, ...);
|
||||
int test_chdir(const char *path);
|
||||
|
||||
#define main test_main
|
||||
#define read test_read
|
||||
@@ -22,6 +23,7 @@ int test_printf(const char *format, ...);
|
||||
#define connect test_connect
|
||||
#define getpid test_getpid
|
||||
#define printf test_printf
|
||||
#define chdir test_chdir
|
||||
|
||||
#include "../lightning-cli.c"
|
||||
#undef main
|
||||
@@ -79,6 +81,11 @@ int test_printf(const char *fmt UNUSED, ...)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_chdir(const char *path)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *response;
|
||||
static size_t response_off, max_read_return;
|
||||
|
||||
@@ -140,5 +147,7 @@ int main(int argc UNUSED, char *argv[])
|
||||
max_read_return = -1;
|
||||
assert(test_main(3, fake_argv) == 0);
|
||||
tal_free(response);
|
||||
assert(!taken_any());
|
||||
take_cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ int test_connect(int sockfd, const struct sockaddr *addr,
|
||||
int test_getpid(void);
|
||||
int test_printf(const char *format, ...);
|
||||
int test_fputc(int c, FILE *stream);
|
||||
int test_chdir(const char *path);
|
||||
|
||||
#define main test_main
|
||||
#define read test_read
|
||||
@@ -25,6 +26,7 @@ int test_fputc(int c, FILE *stream);
|
||||
#define getpid test_getpid
|
||||
#define printf test_printf
|
||||
#define fputc test_fputc
|
||||
#define chdir test_chdir
|
||||
|
||||
#include "../lightning-cli.c"
|
||||
#undef main
|
||||
@@ -106,6 +108,11 @@ int test_fputc(int c, FILE *stream)
|
||||
return (unsigned)c;
|
||||
}
|
||||
|
||||
int test_chdir(const char *path)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc UNUSED, char *argv[])
|
||||
{
|
||||
setup_locale();
|
||||
@@ -114,7 +121,6 @@ int main(int argc UNUSED, char *argv[])
|
||||
|
||||
output = tal_strdup(NULL, "");
|
||||
assert(test_main(3, fake_argv) == 0);
|
||||
assert(!taken_any());
|
||||
|
||||
assert(streq(output, "channels=\n"
|
||||
"\n"
|
||||
@@ -130,6 +136,7 @@ int main(int argc UNUSED, char *argv[])
|
||||
"num_channels=1\n"
|
||||
"num_connected=1\n"));
|
||||
tal_free(output);
|
||||
assert(!taken_any());
|
||||
take_cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user