| 1631 | } |
| 1632 | |
| 1633 | static 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 | |
| 1679 | static const char *plugin_parse_getmanifest_response(const char *buffer, |
| 1680 | const jsmntok_t *toks, |
no test coverage detected