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
1 changed files with 6 additions and 8 deletions

View File

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