Browse Source

common: parse --allow-deprecated-apis extremely early.

We're going to want this for changing the default network.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 5 years ago
parent
commit
a56f2b25b0
  1. 12
      common/configdir.c
  2. 4
      common/configdir.h
  3. 5
      doc/lightning-cli.1.md
  4. 9
      lightningd/options.c
  5. 3
      lightningd/options.h

12
common/configdir.c

@ -11,6 +11,8 @@
#include <common/version.h>
#include <errno.h>
bool deprecated_apis = true;
/* The regrettable globals */
static const tal_t *options_ctx;
@ -304,6 +306,10 @@ void initial_config_opts(const tal_t *ctx,
opt_register_early_noarg("--mainnet",
opt_set_specific_network, "bitcoin",
"Alias for --network=bitcoin");
opt_register_early_arg("--allow-deprecated-apis",
opt_set_bool_arg, opt_show_bool,
&deprecated_apis,
"Enable deprecated options, JSONRPC commands, fields, etc.");
/* Read config file first, since cmdline must override */
if (*config_filename)
@ -347,6 +353,12 @@ void initial_config_opts(const tal_t *ctx,
opt_register_early_noarg("--mainnet", opt_ignore_noarg, NULL,
"Alias for --network=bitcoin");
/* They can set this later, it's just less effective. */
opt_register_early_arg("--allow-deprecated-apis",
opt_set_bool_arg, opt_show_bool,
&deprecated_apis,
"Enable deprecated options, JSONRPC commands, fields, etc.");
/* Set this up for when they parse cmdline proper. */
*rpc_filename = default_rpcfile(ctx);
opt_register_arg("--rpc-file", opt_set_talstr, opt_show_charp,

4
common/configdir.h

@ -3,6 +3,10 @@
#include "config.h"
#include <ccan/tal/tal.h>
/* Put things we're going to get rid of behind this, so testers can catch
* them early. */
extern bool deprecated_apis;
/* Helper for options which are tal() strings. */
char *opt_set_talstr(const char *arg, char **p);

5
doc/lightning-cli.1.md

@ -52,6 +52,11 @@ Print summary of options to standard output and exit.
**--version**/**-V**
Print version number to standard output and exit.
**allow-deprecated-apis**=*BOOL*
Enable deprecated options. It defaults to *true*, but you should set
it to *false* when testing to ensure that an upgrade won’t break your
configuration.
COMMANDS
--------

9
lightningd/options.c

@ -9,7 +9,6 @@
#include <ccan/str/hex/hex.h>
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <common/configdir.h>
#include <common/derive_basepoints.h>
#include <common/features.h>
#include <common/json_command.h>
@ -42,8 +41,6 @@
#include <unistd.h>
#include <wire/wire.h>
bool deprecated_apis = true;
/* Declare opt_add_addr here, because we we call opt_add_addr
* and opt_announce_addr vice versa
*/
@ -708,12 +705,6 @@ static void register_opts(struct lightningd *ld)
NULL, ld,
"Disable a particular plugin by filename/name");
/* This can effect commandline parsing */
opt_register_early_arg("--allow-deprecated-apis",
opt_set_bool_arg, opt_show_bool,
&deprecated_apis,
"Enable deprecated options, JSONRPC commands, fields, etc.");
/* Early, as it suppresses DNS lookups from cmdline too. */
opt_register_early_arg("--always-use-proxy",
opt_set_bool_arg, opt_show_bool,

3
lightningd/options.h

@ -2,6 +2,7 @@
#define LIGHTNING_LIGHTNINGD_OPTIONS_H
#include "config.h"
#include <ccan/tal/tal.h>
#include <common/configdir.h>
struct lightningd;
@ -14,6 +15,4 @@ void handle_opts(struct lightningd *ld, int argc, char *argv[]);
/* Derive default color and alias from the pubkey. */
void setup_color_and_alias(struct lightningd *ld);
/* Global to allow deprecated options. */
extern bool deprecated_apis;
#endif /* LIGHTNING_LIGHTNINGD_OPTIONS_H */

Loading…
Cancel
Save