diff --git a/common/configdir.c b/common/configdir.c index 8f8a30eec..c6ac3fdcf 100644 --- a/common/configdir.c +++ b/common/configdir.c @@ -179,7 +179,8 @@ void setup_option_allocators(void) static void parse_configvars(struct configvar **cvs, bool early, - bool full_knowledge) + bool full_knowledge, + bool developer) { for (size_t i = 0; i < tal_count(cvs); i++) { const char *problem; @@ -194,7 +195,7 @@ static void parse_configvars(struct configvar **cvs, problem = configvar_parse(cvs[i], early, should_know, - IFDEV(true, false)); + developer); current_cv = NULL; if (!problem) continue; @@ -354,7 +355,7 @@ struct configvar **initial_config_opts(const tal_t *ctx, "Set JSON-RPC socket (or /dev/tty)"); cmdline_cvs = gather_cmdline_args(tmpctx, argc, argv, remove_args); - parse_configvars(cmdline_cvs, true, false); + parse_configvars(cmdline_cvs, true, false, false); /* Base default or direct config can set network */ if (*config_filename) { @@ -371,7 +372,7 @@ struct configvar **initial_config_opts(const tal_t *ctx, false, 0); /* This might set network! */ parse_configvars(configvar_join(tmpctx, base_cvs, cmdline_cvs), - true, false); + true, false, false); /* Now, we can get network config */ dir = path_join(tmpctx, dir, chainparams->network_name); @@ -385,7 +386,7 @@ struct configvar **initial_config_opts(const tal_t *ctx, /* This will be called again, once caller has added their own * early vars! */ - parse_configvars_early(cvs); + parse_configvars_early(cvs, false); *config_netdir = path_join(NULL, *config_basedir, chainparams->network_name); @@ -395,15 +396,16 @@ struct configvar **initial_config_opts(const tal_t *ctx, return cvs; } -void parse_configvars_early(struct configvar **cvs) +void parse_configvars_early(struct configvar **cvs, bool developer) { - parse_configvars(cvs, true, false); + parse_configvars(cvs, true, false, developer); } void parse_configvars_final(struct configvar **cvs, - bool full_knowledge) + bool full_knowledge, + bool developer) { - parse_configvars(cvs, false, full_knowledge); + parse_configvars(cvs, false, full_knowledge, developer); configvar_finalize_overrides(cvs); } diff --git a/common/configdir.h b/common/configdir.h index e25207be5..68e06ca27 100644 --- a/common/configdir.h +++ b/common/configdir.h @@ -30,12 +30,12 @@ struct configvar **initial_config_opts(const tal_t *ctx, char **rpc_filename); /* This is called before we know all the options. */ -void parse_configvars_early(struct configvar **cvs); +void parse_configvars_early(struct configvar **cvs, bool developer); /* This is called once, after we know all the options (if full_knowledge * is false, ignore unknown non-cmdline options). */ void parse_configvars_final(struct configvar **cvs, - bool full_knowledge); + bool full_knowledge, bool developer); /* For listconfigs to detect. */ bool is_restricted_ignored(const void *fn); diff --git a/doc/lightning-listconfigs.7.md b/doc/lightning-listconfigs.7.md index 79c0d2d59..667198b7c 100644 --- a/doc/lightning-listconfigs.7.md +++ b/doc/lightning-listconfigs.7.md @@ -54,6 +54,9 @@ On success, an object is returned, containing: - **conf** (object, optional): - **value\_str** (string): field from cmdline - **source** (string): source of configuration setting (always "cmdline") + - **developer** (object, optional) *(added v23.08)*: + - **set** (boolean): `true` if set in config or cmdline + - **source** (string): source of configuration setting - **clear-plugins** (object, optional): - **set** (boolean): `true` if set in config or cmdline - **source** (string): source of configuration setting @@ -352,6 +355,7 @@ On success, an object is returned, containing: - **dev-allowdustreserve** (boolean, optional): Whether we allow setting dust reserves **deprecated, removal in v24.05** - **announce-addr-dns** (boolean, optional): Whether we put DNS entries into node\_announcement **deprecated, removal in v24.05** *(added v22.11.1)* - **require-confirmed-inputs** (boolean, optional): Request peers to only send confirmed inputs (dual-fund only) **deprecated, removal in v24.05** +- **developer** (boolean, optional): Whether developer mode is enabled *(added v23.08)* - **commit-fee** (u64, optional): The percentage of the 6-block fee estimate to use for commitment transactions **deprecated, removal in v24.05** *(added v23.05)* - **min-emergency-msat** (msat, optional): field from config or cmdline, or default *(added v23.08)* @@ -471,4 +475,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:8e7ec36b820cb17ecfc3066802bb07e159fffdd8dfe049d092b8f3b804e05588) +[comment]: # ( SHA256STAMP:2ff237b19ffed3d97eabf67ff256df66d8c5063ad5086bb6a3d77e64f53f64db) diff --git a/doc/lightningd-config.5.md b/doc/lightningd-config.5.md index 17689262f..0a91c2bb2 100644 --- a/doc/lightningd-config.5.md +++ b/doc/lightningd-config.5.md @@ -45,10 +45,14 @@ OPTIONS ### General options +* **developer** + + This enables developer mode, allowing developer options and commands to be used. It also disabled deprecated APIs; use `allow-deprecated-apis=true` to re-enable them. + * **allow-deprecated-apis**=*BOOL* Enable deprecated options, JSONRPC commands, fields, etc. It defaults to -*true*, but you should set it to *false* when testing to ensure that an +*true* outside developer mode, but you should set it to *false* when testing to ensure that an upgrade won't break your configuration. * **help** diff --git a/doc/schemas/listconfigs.schema.json b/doc/schemas/listconfigs.schema.json index d2a639b5f..ece50df7a 100644 --- a/doc/schemas/listconfigs.schema.json +++ b/doc/schemas/listconfigs.schema.json @@ -32,6 +32,25 @@ } } }, + "developer": { + "type": "object", + "added": "v23.08", + "additionalProperties": false, + "required": [ + "set", + "source" + ], + "properties": { + "set": { + "type": "boolean", + "description": "`true` if set in config or cmdline" + }, + "source": { + "type": "string", + "description": "source of configuration setting" + } + } + }, "clear-plugins": { "type": "object", "additionalProperties": false, @@ -1731,6 +1750,11 @@ "type": "boolean", "description": "Request peers to only send confirmed inputs (dual-fund only)" }, + "developer": { + "added": "v23.08", + "type": "boolean", + "description": "Whether developer mode is enabled" + }, "commit-fee": { "deprecated": "v23.08", "type": "u64", diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 9e4f137d4..02c2e0bc5 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -116,6 +116,9 @@ static struct lightningd *new_lightningd(const tal_t *ctx) * us to use const more liberally: the style rule here is that you * should use 'const' on pointers if you can. */ + /* They can turn this on with --developer */ + ld->developer = IFDEV(true, false); + /*~ Note that we generally EXPLICITLY #if-wrap DEVELOPER code. This * is a nod to keeping it minimal and explicit: we need this code for * testing, but its existence means we're not actually testing the diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 37830d029..82fd3e82f 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -128,6 +128,9 @@ struct lightningd { * transaction. */ struct jsonrpc *jsonrpc; + /* --developer? */ + bool developer; + /* Configuration file name */ char *config_filename; /* Configuration settings. */ diff --git a/lightningd/options.c b/lightningd/options.c index a493f693c..c93b43df6 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1717,6 +1717,11 @@ void handle_early_opts(struct lightningd *ld, int argc, char *argv[]) list_features_and_exit, ld, "List the features configured, and exit immediately"); + /*~ We need to know this super-early, as it controls other options */ + clnopt_noarg("--developer", OPT_EARLY|OPT_SHOWBOOL, + opt_set_bool, &ld->developer, + "Enable developer commands/options, disable legacy APIs"); + /*~ This does enough parsing to get us the base configuration options */ ld->configvars = initial_config_opts(ld, &argc, argv, true, &ld->config_filename, @@ -1763,6 +1768,10 @@ void handle_early_opts(struct lightningd *ld, int argc, char *argv[]) ld->config_netdir, strerror(errno)); } + /* --developer changes default for APIs */ + if (ld->developer) + ld->deprecated_apis = false; + /*~ We move files from old locations on first upgrade. */ promote_missing_files(ld); @@ -1772,7 +1781,7 @@ void handle_early_opts(struct lightningd *ld, int argc, char *argv[]) /* Now, first-pass of parsing. But only handle the early * options (testnet, plugins etc), others may be added on-demand */ - parse_configvars_early(ld->configvars); + parse_configvars_early(ld->configvars, ld->developer); /* Finalize the logging subsystem now. */ logging_options_parsed(ld->log_book); @@ -1782,7 +1791,7 @@ void handle_opts(struct lightningd *ld) { /* Now we know all the options, finish parsing and finish * populating ld->configvars with cmdline. */ - parse_configvars_final(ld->configvars, true); + parse_configvars_final(ld->configvars, true, ld->developer); /* We keep a separate variable rather than overriding always_use_proxy, * so listconfigs shows the correct thing. */ diff --git a/tools/check-manpage.sh b/tools/check-manpage.sh index d333fd1b8..e50be1e9c 100755 --- a/tools/check-manpage.sh +++ b/tools/check-manpage.sh @@ -13,7 +13,7 @@ get_cmd_opts() COLUMNS=1000 $1 --help | sed -n 's/^\(-.|\)\?\(--[^ ]*\)\( \| \).*/\2/p' | while IFS=$'\n' read -r opt; do case "$opt" in # We don't document dev options. - --dev*) + --dev-*) ;; --*=*|--*' '*) echo "${opt%%[ =]*}=" | cut -c3-