| 1403 | } |
| 1404 | |
| 1405 | static const char *plugin_notifications_add(const char *buffer, |
| 1406 | const jsmntok_t *result, |
| 1407 | struct plugin *plugin) |
| 1408 | { |
| 1409 | char *name; |
| 1410 | size_t i; |
| 1411 | const jsmntok_t *method, *obj; |
| 1412 | const jsmntok_t *notifications = |
| 1413 | json_get_member(buffer, result, "notifications"); |
| 1414 | |
| 1415 | if (!notifications) |
| 1416 | return NULL; |
| 1417 | |
| 1418 | if (notifications->type != JSMN_ARRAY) |
| 1419 | return tal_fmt(plugin, |
| 1420 | "\"result.notifications\" is not an array"); |
| 1421 | |
| 1422 | json_for_each_arr(i, obj, notifications) { |
| 1423 | if (obj->type != JSMN_OBJECT) |
| 1424 | return tal_fmt( |
| 1425 | plugin, |
| 1426 | "\"result.notifications[%zu]\" is not an object", |
| 1427 | i); |
| 1428 | |
| 1429 | method = json_get_member(buffer, obj, "method"); |
| 1430 | if (method == NULL || method->type != JSMN_STRING) |
| 1431 | return tal_fmt(plugin, |
| 1432 | "\"result.notifications[%zu].name\" " |
| 1433 | "missing or not a string.", |
| 1434 | i); |
| 1435 | |
| 1436 | name = json_strdup(plugin, buffer, method); |
| 1437 | |
| 1438 | if (notifications_topic_is_native(name)) |
| 1439 | return tal_fmt(plugin, |
| 1440 | "plugin attempted to register a native " |
| 1441 | "notification topic \"%s\", these may " |
| 1442 | "however only be sent by lightningd", |
| 1443 | name); |
| 1444 | |
| 1445 | tal_arr_expand(&plugin->notification_topics, name); |
| 1446 | } |
| 1447 | |
| 1448 | return NULL; |
| 1449 | } |
| 1450 | |
| 1451 | static const char *plugin_parse_getmanifest_response(const char *buffer, |
| 1452 | const jsmntok_t *toks, |
no test coverage detected