| 884 | } |
| 885 | |
| 886 | static void rpc_command_hook_final(struct rpc_command_hook_payload *p STEALS) |
| 887 | { |
| 888 | const jsmntok_t *params; |
| 889 | |
| 890 | /* Free payload with cmd */ |
| 891 | tal_steal(p->cmd, p); |
| 892 | |
| 893 | if (p->custom_result != NULL) { |
| 894 | struct json_stream *s = json_start(p->cmd); |
| 895 | json_add_jsonstr(s, "result", |
| 896 | p->custom_result, strlen(p->custom_result)); |
| 897 | json_object_end(s); |
| 898 | return was_pending(command_raw_complete(p->cmd, s)); |
| 899 | } |
| 900 | if (p->custom_error != NULL) { |
| 901 | struct json_stream *s = json_start(p->cmd); |
| 902 | json_add_jsonstr(s, "error", |
| 903 | p->custom_error, strlen(p->custom_error)); |
| 904 | json_object_end(s); |
| 905 | return was_pending(command_raw_complete(p->cmd, s)); |
| 906 | } |
| 907 | if (p->custom_replace != NULL) |
| 908 | return replace_command(p, p->custom_buffer, p->custom_replace); |
| 909 | |
| 910 | /* If no plugin requested a change, just continue command execution. */ |
| 911 | params = json_get_member(p->buffer, p->request, "params"); |
| 912 | return was_pending(command_exec(p->cmd->jcon, |
| 913 | p->cmd, |
| 914 | p->buffer, |
| 915 | p->request, |
| 916 | params)); |
| 917 | } |
| 918 | |
| 919 | static bool |
| 920 | rpc_command_hook_callback(struct rpc_command_hook_payload *p, |
no test coverage detected