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

Function plugin_setconfig_done

lightningd/plugin.c:2245–2293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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