diff --git a/common/configvar.h b/common/configvar.h index dcfe5d3ac..81ffda172 100644 --- a/common/configvar.h +++ b/common/configvar.h @@ -58,6 +58,8 @@ struct configvar { #define OPT_SHOWMSATS (1 << (OPT_USER_START+4)) /* listconfigs should treat as a literal boolean `true` or `false` */ #define OPT_SHOWBOOL (1 << (OPT_USER_START+5)) +/* Can be changed at runtime */ +#define OPT_DYNAMIC (1 << (OPT_USER_START+6)) /* Use this instead of opt_register_*_arg if you want OPT_* from above */ #define clnopt_witharg(names, type, cb, show, arg, desc) \ diff --git a/doc/lightning-listconfigs.7.md b/doc/lightning-listconfigs.7.md index acb1b41e8..aa8ec475b 100644 --- a/doc/lightning-listconfigs.7.md +++ b/doc/lightning-listconfigs.7.md @@ -9,12 +9,27 @@ SYNOPSIS DESCRIPTION ----------- -*config* (optional) is a configuration option name, or "plugin" to show plugin options +*config* (optional) is a configuration option name to restrict return. -The **listconfigs** RPC command to list all configuration options, or with *config* only a selection. +The **listconfigs** RPC command to list all configuration options, or with *config* only one. The returned values reflect the current configuration, including -showing default values (`dev-` options are not shown). +showing default values (`dev-` options are not shown unless specified as *config* explicitly). + +Note: as plugins can add options, not all configuration settings are +listed here! The format of each entry is as follows: + +- **source** (string): source of configuration setting (`file`:`linenum`) +- **dynamic** (boolean, optional): true if this option is settable via setconfig +- **plugin** (string, optional): set if this is from a plugin + +Depending on the option type, exactly one of the following is present: + +- **set** (boolean, optional): for simple flag options +- **value\_str** (string, optional): for string options +- **value\_msat** (msat, optional): for msat options +- **value\_int** (integer, optional): for integer options +- **value\_bool** (boolean, optional): for boolean options EXAMPLE JSON REQUEST -------------------- @@ -177,6 +192,7 @@ On success, an object is returned, containing: - **min-capacity-sat** (object, optional): - **value\_int** (u64): field from config or cmdline, or default - **source** (string): source of configuration setting + - **dynamic** (boolean, optional): Can this be set by setconfig() (always *true*) - **addr** (object, optional): - **values\_str** (array of strings): - field from config or cmdline @@ -447,4 +463,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:2b3588b395919162c122cd386f0f4b320d906d0190e706bfa1b68db4126e7ee2) +[comment]: # ( SHA256STAMP:0440e4634e4a28681323f891307c7bb61143aacad4824f952f24f027a7543835) diff --git a/doc/schemas/listconfigs.schema.json b/doc/schemas/listconfigs.schema.json index 900dbbcf3..cac3ecbdf 100644 --- a/doc/schemas/listconfigs.schema.json +++ b/doc/schemas/listconfigs.schema.json @@ -834,6 +834,13 @@ "source": { "type": "string", "description": "source of configuration setting" + }, + "dynamic": { + "type": "boolean", + "enum": [ + true + ], + "description": "Can this be set by setconfig()" } } }, diff --git a/lightningd/configs.c b/lightningd/configs.c index ad1f50e9e..0d1565a2b 100644 --- a/lightningd/configs.c +++ b/lightningd/configs.c @@ -143,6 +143,8 @@ static void json_add_config(struct lightningd *ld, json_add_bool(response, "set", cv != NULL); json_add_source(response, "source", cv); json_add_config_plugin(response, ld->plugins, "plugin", ot); + if (ot->type & OPT_DYNAMIC) + json_add_bool(response, "dynamic", true); json_object_end(response); return; } @@ -167,6 +169,8 @@ static void json_add_config(struct lightningd *ld, } json_array_end(response); json_add_config_plugin(response, ld->plugins, "plugin", ot); + if (ot->type & OPT_DYNAMIC) + json_add_bool(response, "dynamic", true); json_object_end(response); return; } @@ -180,6 +184,8 @@ static void json_add_config(struct lightningd *ld, json_add_configval(response, configval_fieldname(ot), ot, val); json_add_source(response, "source", cv); json_add_config_plugin(response, ld->plugins, "plugin", ot); + if (ot->type & OPT_DYNAMIC) + json_add_bool(response, "dynamic", true); json_object_end(response); } diff --git a/lightningd/options.c b/lightningd/options.c index ab4eeb0cd..97bcd9ac9 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1352,7 +1352,7 @@ static void register_opts(struct lightningd *ld) opt_set_msat, opt_show_msat, &ld->config.max_dust_htlc_exposure_msat, "Max HTLC amount that can be trimmed"); - clnopt_witharg("--min-capacity-sat", OPT_SHOWINT, opt_set_u64, opt_show_u64, + clnopt_witharg("--min-capacity-sat", OPT_SHOWINT|OPT_DYNAMIC, opt_set_u64, opt_show_u64, &ld->config.min_capacity_sat, "Minimum capacity in satoshis for accepting channels"); clnopt_witharg("--addr", OPT_MULTI, opt_add_addr, NULL,