| 888 | } |
| 889 | |
| 890 | static struct command_result *json_decode(struct command *cmd, |
| 891 | const char *buffer, |
| 892 | const jsmntok_t *params) |
| 893 | { |
| 894 | struct decodable *decodable = talz(cmd, struct decodable); |
| 895 | struct json_stream *response; |
| 896 | |
| 897 | if (!param(cmd, buffer, params, |
| 898 | p_req("string", param_decodable, decodable), |
| 899 | NULL)) |
| 900 | return command_param_failed(); |
| 901 | |
| 902 | response = jsonrpc_stream_success(cmd); |
| 903 | json_add_string(response, "type", decodable->type); |
| 904 | if (decodable->offer) |
| 905 | json_add_offer(response, decodable->offer); |
| 906 | if (decodable->invreq) |
| 907 | json_add_invoice_request(response, decodable->invreq); |
| 908 | if (decodable->invoice) |
| 909 | json_add_b12_invoice(response, decodable->invoice); |
| 910 | if (decodable->b11) { |
| 911 | /* The bolt11 decoder simply refuses to decode bad invs. */ |
| 912 | json_add_bolt11(response, decodable->b11); |
| 913 | json_add_bool(response, "valid", true); |
| 914 | } |
| 915 | if (decodable->rune) |
| 916 | json_add_rune(cmd, response, decodable->rune); |
| 917 | return command_finished(cmd, response); |
| 918 | } |
| 919 | |
| 920 | static const char *init(struct plugin *p, |
| 921 | const char *buf UNUSED, |
nothing calls this directly
no test coverage detected