| 291 | } |
| 292 | |
| 293 | void initial_config_opts(const tal_t *ctx, |
| 294 | int argc, char *argv[], |
| 295 | char **config_filename, |
| 296 | char **config_basedir, |
| 297 | char **config_netdir, |
| 298 | char **rpc_filename) |
| 299 | { |
| 300 | options_ctx = ctx; |
| 301 | |
| 302 | /* First, they could specify a config, which specifies a lightning dir |
| 303 | * or a network. */ |
| 304 | *config_filename = NULL; |
| 305 | opt_register_early_arg("--conf=<file>", opt_set_abspath, NULL, |
| 306 | config_filename, |
| 307 | "Specify configuration file"); |
| 308 | |
| 309 | /* Cmdline can also set lightning-dir. */ |
| 310 | *config_basedir = NULL; |
| 311 | opt_register_early_arg("--lightning-dir=<dir>", |
| 312 | opt_set_abspath, NULL, |
| 313 | config_basedir, |
| 314 | "Set base directory: network-specific subdirectory is under here"); |
| 315 | |
| 316 | /* Handle --version (and exit) here too */ |
| 317 | opt_register_version(); |
| 318 | |
| 319 | opt_early_parse_incomplete(argc, argv, opt_log_stderr_exit); |
| 320 | |
| 321 | /* Now, reset and ignore --conf option from now on. */ |
| 322 | opt_free_table(); |
| 323 | |
| 324 | /* This is only ever valid on cmdline */ |
| 325 | opt_register_early_arg("--conf=<file>", |
| 326 | opt_restricted_cmdline, NULL, |
| 327 | config_filename, |
| 328 | "Specify configuration file"); |
| 329 | |
| 330 | /* If they set --conf it can still set --lightning-dir */ |
| 331 | if (!*config_filename) { |
| 332 | opt_register_early_arg("--lightning-dir=<dir>", |
| 333 | opt_restricted_forceconf_only, opt_show_charp, |
| 334 | config_basedir, |
| 335 | "Set base directory: network-specific subdirectory is under here"); |
| 336 | } else { |
| 337 | opt_register_early_arg("--lightning-dir=<dir>", |
| 338 | opt_set_abspath, NULL, |
| 339 | config_basedir, |
| 340 | "Set base directory: network-specific subdirectory is under here"); |
| 341 | } |
| 342 | |
| 343 | /* Now, config file (or cmdline) can set network and lightning-dir */ |
| 344 | |
| 345 | /* We need to know network early, so we can set defaults (which normal |
| 346 | * options can change) and default config_netdir */ |
| 347 | opt_register_early_arg("--network", opt_set_network, opt_show_network, |
| 348 | NULL, |
| 349 | "Select the network parameters (bitcoin, testnet," |
| 350 | " signet, regtest, litecoin or litecoin-testnet)"); |
no test coverage detected