| 2243 | }; |
| 2244 | |
| 2245 | static 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 | |
| 2286 | bad_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 | |
| 2295 | struct command_result *plugin_set_dynamic_opt(struct command *cmd, |
| 2296 | const struct opt_table *ot, |
nothing calls this directly
no test coverage detected