mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-09 16:14:19 +01:00
lightningd: allow false as a default for flags.
defaults were deprecated in 0df97547dd, but that was a bit
harsh as several plugins do that (summary, for example). So allow false, but warn
that we ignore anything else.
Reported-by: @microsatoshi on Discord.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: Plugins: ...actually, `default` `false` still accepted on `flag` type parameters.
This commit is contained in:
@@ -960,9 +960,22 @@ static const char *plugin_opt_add(struct plugin *plugin, const char *buffer,
|
||||
|
||||
if (json_tok_streq(buffer, typetok, "flag")) {
|
||||
if (defaulttok) {
|
||||
if (!deprecated_apis) {
|
||||
return tal_fmt(plugin, "%s type flag cannot have default",
|
||||
popt->name);
|
||||
bool val;
|
||||
/* We used to allow (ignore) anything, now make sure it's 'false' */
|
||||
if (!json_to_bool(buffer, defaulttok, &val)
|
||||
|| val != false) {
|
||||
if (!deprecated_apis)
|
||||
return tal_fmt(plugin, "%s type flag default must be 'false' not %.*s",
|
||||
popt->name,
|
||||
json_tok_full_len(defaulttok),
|
||||
json_tok_full(buffer, defaulttok));
|
||||
else {
|
||||
/* At least warn that we're ignoring! */
|
||||
log_broken(plugin->log, "Ignoring default %.*s for %s (if set, must be 'false'!)",
|
||||
json_tok_full_len(defaulttok),
|
||||
json_tok_full(buffer, defaulttok),
|
||||
popt->name);
|
||||
}
|
||||
}
|
||||
defaulttok = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user