| 773 | } |
| 774 | |
| 775 | static struct command_result * |
| 776 | handle_getmanifest(struct command *getmanifest_cmd, |
| 777 | const char *buf, |
| 778 | const jsmntok_t *getmanifest_params) |
| 779 | { |
| 780 | struct json_stream *params = jsonrpc_stream_success(getmanifest_cmd); |
| 781 | struct plugin *p = getmanifest_cmd->plugin; |
| 782 | const jsmntok_t *dep; |
| 783 | bool has_shutdown_notif; |
| 784 | |
| 785 | /* This was added post 0.9.0 */ |
| 786 | dep = json_get_member(buf, getmanifest_params, "allow-deprecated-apis"); |
| 787 | if (!dep) |
| 788 | deprecated_apis = true; |
| 789 | else { |
| 790 | if (!json_to_bool(buf, dep, &deprecated_apis)) |
| 791 | plugin_err(p, "Invalid allow-deprecated-apis '%.*s'", |
| 792 | json_tok_full_len(dep), |
| 793 | json_tok_full(buf, dep)); |
| 794 | } |
| 795 | |
| 796 | json_array_start(params, "options"); |
| 797 | for (size_t i = 0; i < tal_count(p->opts); i++) { |
| 798 | json_object_start(params, NULL); |
| 799 | json_add_string(params, "name", p->opts[i].name); |
| 800 | json_add_string(params, "type", p->opts[i].type); |
| 801 | json_add_string(params, "description", p->opts[i].description); |
| 802 | json_add_bool(params, "deprecated", p->opts[i].deprecated); |
| 803 | json_object_end(params); |
| 804 | } |
| 805 | json_array_end(params); |
| 806 | |
| 807 | json_array_start(params, "rpcmethods"); |
| 808 | for (size_t i = 0; i < p->num_commands; i++) { |
| 809 | json_object_start(params, NULL); |
| 810 | json_add_string(params, "name", p->commands[i].name); |
| 811 | json_add_string(params, "usage", |
| 812 | strmap_get(&p->usagemap, p->commands[i].name)); |
| 813 | json_add_string(params, "description", p->commands[i].description); |
| 814 | if (p->commands[i].long_description) |
| 815 | json_add_string(params, "long_description", |
| 816 | p->commands[i].long_description); |
| 817 | json_add_bool(params, "deprecated", p->commands[i].deprecated); |
| 818 | json_object_end(params); |
| 819 | } |
| 820 | json_array_end(params); |
| 821 | |
| 822 | json_array_start(params, "subscriptions"); |
| 823 | has_shutdown_notif = false; |
| 824 | for (size_t i = 0; i < p->num_notif_subs; i++) { |
| 825 | json_add_string(params, NULL, p->notif_subs[i].name); |
| 826 | if (streq(p->notif_subs[i].name, "shutdown")) |
| 827 | has_shutdown_notif = true; |
| 828 | } |
| 829 | #if DEVELOPER |
| 830 | /* For memleak detection, always get notified of shutdown. */ |
| 831 | if (!has_shutdown_notif) |
| 832 | json_add_string(params, NULL, "shutdown"); |
no test coverage detected