mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
lightningd: add --developer runtime option.
Currently it just defaults to the DEVELOPER compile option, but we'll move over to this. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Config: `--developer` enables developer options and changes default to be "disable deprecated APIs".
This commit is contained in:
parent
5882978147
commit
64ab7c0c1d
9 changed files with 65 additions and 16 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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: <https://github.com/ElementsProject/lightning>
|
||||
|
||||
[comment]: # ( SHA256STAMP:8e7ec36b820cb17ecfc3066802bb07e159fffdd8dfe049d092b8f3b804e05588)
|
||||
[comment]: # ( SHA256STAMP:2ff237b19ffed3d97eabf67ff256df66d8c5063ad5086bb6a3d77e64f53f64db)
|
||||
|
|
|
@ -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**
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -128,6 +128,9 @@ struct lightningd {
|
|||
* transaction. */
|
||||
struct jsonrpc *jsonrpc;
|
||||
|
||||
/* --developer? */
|
||||
bool developer;
|
||||
|
||||
/* Configuration file name */
|
||||
char *config_filename;
|
||||
/* Configuration settings. */
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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-*)
|
||||
;;
|
||||
--*=*|--*' <arg>'*)
|
||||
echo "${opt%%[ =]*}=" | cut -c3-
|
||||
|
|
Loading…
Add table
Reference in a new issue