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