diff --git a/cli/lightning-cli.c b/cli/lightning-cli.c index 108307048..5812fb4e9 100644 --- a/cli/lightning-cli.c +++ b/cli/lightning-cli.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -492,6 +493,13 @@ int main(int argc, char *argv[]) tal_free(page); } + /* If an absolute path to the RPC socket is given, it takes over other + * configuration options. */ + if (path_is_abs(rpc_filename)) { + net_dir = path_dirname(ctx, rpc_filename); + rpc_filename = path_basename(ctx, rpc_filename); + } + if (chdir(net_dir) != 0) err(ERROR_TALKING_TO_LIGHTNINGD, "Moving into '%s'", net_dir);