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

Function plugin_subscriptions_add

lightningd/plugin.c:1270–1304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1268}
1269
1270static const char *plugin_subscriptions_add(struct plugin *plugin,
1271 const char *buffer,
1272 const jsmntok_t *resulttok)
1273{
1274 const jsmntok_t *subscriptions =
1275 json_get_member(buffer, resulttok, "subscriptions");
1276
1277 if (!subscriptions) {
1278 plugin->subscriptions = NULL;
1279 return NULL;
1280 }
1281 plugin->subscriptions = tal_arr(plugin, char *, 0);
1282 if (subscriptions->type != JSMN_ARRAY) {
1283 return tal_fmt(plugin, "\"result.subscriptions\" is not an array");
1284 }
1285
1286 for (int i = 0; i < subscriptions->size; i++) {
1287 char *topic;
1288 const jsmntok_t *s = json_get_arr(subscriptions, i);
1289 if (s->type != JSMN_STRING) {
1290 return tal_fmt(plugin,
1291 "result.subscriptions[%d] is not a string: '%.*s'", i,
1292 json_tok_full_len(s),
1293 json_tok_full(buffer, s));
1294 }
1295
1296 /* We add all subscriptions while parsing the
1297 * manifest, without checking that they exist, since
1298 * later plugins may also emit notifications of custom
1299 * types that we don't know about yet. */
1300 topic = json_strdup(plugin, plugin->buffer, s);
1301 tal_arr_expand(&plugin->subscriptions, topic);
1302 }
1303 return NULL;
1304}
1305
1306static const char *plugin_hooks_add(struct plugin *plugin, const char *buffer,
1307 const jsmntok_t *resulttok)

Callers 1

Calls 5

json_get_arrFunction · 0.85
json_get_memberFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_strdupFunction · 0.50

Tested by

no test coverage detected