Skip to content

Commit

Permalink
lightningd: allow false as a default for flags.
Browse files Browse the repository at this point in the history
defaults were deprecated in 0df9754, 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 <[email protected]>
Changelog-Deprecated: Plugins: ...actually, `default` `false` still accepted on `flag` type parameters.
  • Loading branch information
rustyrussell committed Jun 7, 2023
1 parent 55119e6 commit e457681
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e457681

Please sign in to comment.