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

Function new_plugin

plugins/libplugin.c:2356–2441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2354}
2355
2356static struct plugin *new_plugin(const tal_t *ctx,
2357 const char *argv0,
2358 bool developer,
2359 const char *(*init)(struct command *init_cmd,
2360 const char *buf,
2361 const jsmntok_t *),
2362 const enum plugin_restartability restartability,
2363 bool init_rpc,
2364 struct feature_set *features STEALS,
2365 const struct plugin_command *commands TAKES,
2366 size_t num_commands,
2367 const struct plugin_notification *notif_subs TAKES,
2368 size_t num_notif_subs,
2369 const struct plugin_hook *hook_subs TAKES,
2370 size_t num_hook_subs,
2371 const char **notif_topics TAKES,
2372 size_t num_notif_topics,
2373 va_list ap)
2374{
2375 const char *optname;
2376 struct plugin *p = tal(ctx, struct plugin);
2377 char *name;
2378
2379 /* id is our name, without extension (not that we expect any, in C!) */
2380 name = path_basename(p, argv0);
2381 name[path_ext_off(name)] = '\0';
2382 p->id = name;
2383 p->developer = developer;
2384 p->deprecated_ok_override = NULL;
2385 p->lightningd_in = jsonrpc_io_new(p);
2386 list_head_init(&p->js_list);
2387 /* Async RPC */
2388 p->jsonrpc_in = jsonrpc_io_new(p);
2389 list_head_init(&p->rpc_js_list);
2390 p->io_rpc_conn = NULL;
2391 p->next_outreq_id = 0;
2392 strmap_init(&p->out_reqs);
2393 p->beglist = NULL;
2394
2395 p->desired_features = tal_steal(p, features);
2396 if (init_rpc)
2397 p->sync_io = jsonrpc_io_new(p);
2398 else
2399 p->sync_io = NULL;
2400 p->init = init;
2401 p->manifested = p->initialized = p->exiting = false;
2402 p->restartability = restartability;
2403 strmap_init(&p->usagemap);
2404
2405 p->commands = commands;
2406 if (taken(commands))
2407 tal_steal(p, commands);
2408 p->num_commands = num_commands;
2409 p->notif_topics = notif_topics;
2410 if (taken(notif_topics))
2411 tal_steal(p, notif_topics);
2412 p->num_notif_topics = num_notif_topics;
2413 p->notif_subs = notif_subs;

Callers 1

plugin_mainFunction · 0.85

Calls 5

path_basenameFunction · 0.85
path_ext_offFunction · 0.85
jsonrpc_io_newFunction · 0.85
list_head_initFunction · 0.85
takenFunction · 0.85

Tested by

no test coverage detected