lightningd: reuse code for "dynamic" getmanifest response parsing.

And clean up weird indent.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2024-01-25 10:58:53 +10:30
parent ba2c912a39
commit ac4c396537

View File

@@ -1613,9 +1613,9 @@ static const char *plugin_parse_getmanifest_response(const char *buffer,
const jsmntok_t *toks, const jsmntok_t *toks,
const jsmntok_t *idtok, const jsmntok_t *idtok,
struct plugin *plugin, struct plugin *plugin,
const char **disabled) const char **disabled)
{ {
const jsmntok_t *resulttok, *dynamictok, *featurestok, *custommsgtok, *tok; const jsmntok_t *resulttok, *featurestok, *custommsgtok, *tok;
const char *err; const char *err;
*disabled = NULL; *disabled = NULL;
@@ -1635,12 +1635,10 @@ static const char *plugin_parse_getmanifest_response(const char *buffer,
return NULL; return NULL;
} }
dynamictok = json_get_member(buffer, resulttok, "dynamic"); err = bool_setting(plugin, "getmanifest", buffer, resulttok, "dynamic",
if (dynamictok && !json_to_bool(buffer, dynamictok, &plugin->dynamic)) { &plugin->dynamic);
return tal_fmt(plugin, "Bad 'dynamic' field ('%.*s')", if (err)
json_tok_full_len(dynamictok), return err;
json_tok_full(buffer, dynamictok));
}
featurestok = json_get_member(buffer, resulttok, "featurebits"); featurestok = json_get_member(buffer, resulttok, "featurebits");