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

Function plugin_notifications_add

lightningd/plugin.c:1633–1677  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1631}
1632
1633static const char *plugin_notifications_add(const char *buffer,
1634 const jsmntok_t *result,
1635 struct plugin *plugin)
1636{
1637 char *name;
1638 size_t i;
1639 const jsmntok_t *method, *obj;
1640 const jsmntok_t *notifications =
1641 json_get_member(buffer, result, "notifications");
1642
1643 if (!notifications)
1644 return NULL;
1645
1646 if (notifications->type != JSMN_ARRAY)
1647 return tal_fmt(plugin,
1648 "\"result.notifications\" is not an array");
1649
1650 json_for_each_arr(i, obj, notifications) {
1651 if (obj->type != JSMN_OBJECT)
1652 return tal_fmt(
1653 plugin,
1654 "\"result.notifications[%zu]\" is not an object",
1655 i);
1656
1657 method = json_get_member(buffer, obj, "method");
1658 if (method == NULL || method->type != JSMN_STRING)
1659 return tal_fmt(plugin,
1660 "\"result.notifications[%zu].name\" "
1661 "missing or not a string.",
1662 i);
1663
1664 name = json_strdup(plugin, buffer, method);
1665
1666 if (notifications_topic_is_native(name))
1667 return tal_fmt(plugin,
1668 "plugin attempted to register a native "
1669 "notification topic \"%s\", these may "
1670 "however only be sent by lightningd",
1671 name);
1672
1673 tal_arr_expand(&plugin->notification_topics, name);
1674 }
1675
1676 return NULL;
1677}
1678
1679static const char *plugin_parse_getmanifest_response(const char *buffer,
1680 const jsmntok_t *toks,

Callers 1

Calls 3

json_get_memberFunction · 0.85
json_strdupFunction · 0.50

Tested by

no test coverage detected