| 1246 | } |
| 1247 | |
| 1248 | static struct command_result * |
| 1249 | handle_getmanifest(struct command *getmanifest_cmd, |
| 1250 | const char *buf, |
| 1251 | const jsmntok_t *getmanifest_params) |
| 1252 | { |
| 1253 | struct json_stream *params = jsonrpc_stream_success(getmanifest_cmd); |
| 1254 | struct plugin *p = getmanifest_cmd->plugin; |
| 1255 | bool has_shutdown_notif; |
| 1256 | |
| 1257 | if (json_scan(tmpctx, buf, getmanifest_params, |
| 1258 | "{allow-deprecated-apis:%}", |
| 1259 | JSON_SCAN(json_to_bool, &p->deprecated_ok)) != NULL) { |
| 1260 | plugin_err(p, "Invalid allow-deprecated-apis in '%.*s'", |
| 1261 | json_tok_full_len(getmanifest_params), |
| 1262 | json_tok_full(buf, getmanifest_params)); |
| 1263 | } |
| 1264 | |
| 1265 | json_array_start(params, "options"); |
| 1266 | for (size_t i = 0; i < tal_count(p->opts); i++) { |
| 1267 | if (p->opts[i].dev_only && !p->developer) |
| 1268 | continue; |
| 1269 | json_object_start(params, NULL); |
| 1270 | json_add_string(params, "name", p->opts[i].name); |
| 1271 | json_add_string(params, "type", p->opts[i].type); |
| 1272 | json_add_string(params, "description", p->opts[i].description); |
| 1273 | json_add_deprecated(params, "deprecated", p->opts[i].depr_start, p->opts[i].depr_end); |
| 1274 | json_add_bool(params, "dynamic", p->opts[i].dynamic); |
| 1275 | json_add_bool(params, "multi", p->opts[i].multi); |
| 1276 | if (p->opts[i].jsonfmt) |
| 1277 | p->opts[i].jsonfmt(getmanifest_cmd, params, "default", p->opts[i].arg); |
| 1278 | json_object_end(params); |
| 1279 | } |
| 1280 | json_array_end(params); |
| 1281 | |
| 1282 | json_array_start(params, "rpcmethods"); |
| 1283 | for (size_t i = 0; i < p->num_commands; i++) { |
| 1284 | if (p->commands[i].dev_only && !p->developer) |
| 1285 | continue; |
| 1286 | json_object_start(params, NULL); |
| 1287 | json_add_string(params, "name", p->commands[i].name); |
| 1288 | json_add_string(params, "usage", |
| 1289 | strmap_get(&p->usagemap, p->commands[i].name)); |
| 1290 | json_add_deprecated(params, "deprecated", |
| 1291 | p->commands[i].depr_start, p->commands[i].depr_end); |
| 1292 | json_object_end(params); |
| 1293 | } |
| 1294 | json_array_end(params); |
| 1295 | |
| 1296 | json_array_start(params, "subscriptions"); |
| 1297 | has_shutdown_notif = false; |
| 1298 | for (size_t i = 0; i < p->num_notif_subs; i++) { |
| 1299 | json_add_string(params, NULL, p->notif_subs[i].name); |
| 1300 | if (streq(p->notif_subs[i].name, "shutdown")) |
| 1301 | has_shutdown_notif = true; |
| 1302 | } |
| 1303 | /* For memleak detection, always get notified of shutdown. */ |
| 1304 | if (!has_shutdown_notif && p->developer) |
| 1305 | json_add_string(params, NULL, "shutdown"); |
no test coverage detected