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

Function handle_getmanifest

plugins/libplugin.c:1258–1379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

ld_command_handleFunction · 0.85

Calls 15

json_array_startFunction · 0.85
json_object_startFunction · 0.85
json_add_deprecatedFunction · 0.85
json_add_boolFunction · 0.85
json_object_endFunction · 0.85
json_array_endFunction · 0.85
json_add_u64Function · 0.85
json_add_hexFunction · 0.85
tal_bytelenFunction · 0.85
jsonrpc_stream_successFunction · 0.70
plugin_errFunction · 0.70
command_finishedFunction · 0.70

Tested by

no test coverage detected