From ac4c396537d1f5da7f7825ef02ade16a28213d7e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 25 Jan 2024 10:58:53 +1030 Subject: [PATCH] lightningd: reuse code for "dynamic" getmanifest response parsing. And clean up weird indent. Signed-off-by: Rusty Russell --- lightningd/plugin.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 8e36efd6a..8e0a6f885 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -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");