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