opt: make sure early cmdline options override config file.

I noticed that --network=regtest didn't override 'network=bitcoin' in
the config file.

Normally we parse the config file first, then the commandline (so the cmdline
wins).  But for early options, we do cmdline first so we can find the config
file.  That was fine when the only early option was the location of the
config file, but now it includes plugins and the network setting.

So do a boutique cmdline parse *just* to find the config file, then parse
the config file early options, then the cmdline early options.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-07-25 16:07:58 +09:30
parent 0b5b1faff5
commit f68c9fa9c9
4 changed files with 54 additions and 28 deletions

View File

@@ -659,10 +659,6 @@ int main(int argc, char *argv[])
if (!ld->daemon_dir)
errx(1, "Could not find daemons");
/*~ The ccan/opt code requires registration then parsing; we
* mimic this API here, even though they're on separate lines.*/
register_opts(ld);
/*~ Handle early options, but don't move to --lightning-dir
* just yet. Plugins may add new options, which is why we are
* splitting between early args (including --plugin