| 535 | } |
| 536 | |
| 537 | static const char *plugin_notify_handle(struct plugin *plugin, |
| 538 | const char *buffer, |
| 539 | const jsmntok_t *methodtok, |
| 540 | const jsmntok_t *paramstok) |
| 541 | { |
| 542 | const jsmntok_t *idtok; |
| 543 | struct jsonrpc_request *request; |
| 544 | |
| 545 | /* id inside params tells us which id to redirect to. */ |
| 546 | idtok = json_get_member(buffer, paramstok, "id"); |
| 547 | if (!idtok) { |
| 548 | return tal_fmt(plugin, |
| 549 | "JSON-RPC notify \"id\"-field is not present"); |
| 550 | } |
| 551 | |
| 552 | /* Include any "" in id */ |
| 553 | request = strmap_getn(&plugin->pending_requests, |
| 554 | json_tok_full(buffer, idtok), |
| 555 | json_tok_full_len(idtok)); |
| 556 | if (!request) { |
| 557 | return NULL; |
| 558 | } |
| 559 | |
| 560 | /* Ignore if they don't have a callback */ |
| 561 | if (request->notify_cb) |
| 562 | request->notify_cb(buffer, methodtok, paramstok, idtok, |
| 563 | request->response_cb_arg); |
| 564 | return NULL; |
| 565 | } |
| 566 | |
| 567 | /* Check if the plugin is allowed to send a notification of the |
| 568 | * specified topic, i.e., whether the plugin has announced the topic |
no test coverage detected