MCPcopy Create free account
hub / github.com/ElementsProject/lightning / plugin_setconfig_done

Function plugin_setconfig_done

lightningd/plugin.c:2257–2305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2255};
2256
2257static void plugin_setconfig_done(const char *buffer,
2258 const jsmntok_t *toks,
2259 const jsmntok_t *idtok UNUSED,
2260 struct plugin_set_return *psr)
2261{
2262 const jsmntok_t *t;
2263 const struct opt_table *ot;
2264
2265 t = json_get_member(buffer, toks, "error");
2266 if (t) {
2267 const jsmntok_t *e;
2268 int ecode;
2269
2270 e = json_get_member(buffer, t, "code");
2271 if (!e || !json_to_int(buffer, e, &ecode))
2272 goto bad_response;
2273 e = json_get_member(buffer, t, "message");
2274 if (!e)
2275 goto bad_response;
2276 was_pending(command_fail(psr->cmd, ecode, "%.*s",
2277 e->end - e->start, buffer + e->start));
2278 return;
2279 }
2280
2281 /* We have to look this up again, since a new plugin could have added some
2282 * while we were in callback, and moved opt_table! */
2283 ot = opt_find_long(psr->optname, NULL);
2284 if (!ot) {
2285 log_broken(command_logger(psr->cmd),
2286 "Missing opt %s on plugin return?", psr->optname);
2287 was_pending(command_fail(psr->cmd, LIGHTNINGD,
2288 "Missing opt %s on plugin return?", psr->optname));
2289 return;
2290 }
2291
2292 t = json_get_member(buffer, toks, "result");
2293 if (!t)
2294 goto bad_response;
2295 was_pending(psr->success(psr->cmd, ot, psr->vals, psr->nvals, psr->transient));
2296 return;
2297
2298bad_response:
2299 log_broken(command_logger(psr->cmd),
2300 "Invalid setconfig %s response from plugin: %.*s",
2301 psr->optname,
2302 json_tok_full_len(toks), json_tok_full(buffer, toks));
2303 was_pending(command_fail(psr->cmd, LIGHTNINGD,
2304 "Malformed setvalue %s plugin return", psr->optname));
2305}
2306
2307struct command_result *plugin_set_dynamic_opt(struct command *cmd,
2308 const struct opt_table *ot,

Callers

nothing calls this directly

Calls 9

json_get_memberFunction · 0.85
json_to_intFunction · 0.85
opt_find_longFunction · 0.85
successMethod · 0.80
was_pendingFunction · 0.70
command_failFunction · 0.70
command_loggerFunction · 0.70
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected