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

Function new_plugin

plugins/libplugin.c:2346–2431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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