| 176 | }; |
| 177 | |
| 178 | static struct command_result *param_onion_hops(struct command *cmd, |
| 179 | const char *name, |
| 180 | const char *buffer, |
| 181 | const jsmntok_t *tok, |
| 182 | struct onion_hop **hops) |
| 183 | { |
| 184 | size_t i; |
| 185 | const jsmntok_t *t; |
| 186 | |
| 187 | if (tok->type != JSMN_ARRAY || tok->size == 0) |
| 188 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 189 | "%s must be an (non-empty) array", name); |
| 190 | |
| 191 | *hops = tal_arr(cmd, struct onion_hop, tok->size); |
| 192 | json_for_each_arr(i, t, tok) { |
| 193 | const char *err; |
| 194 | |
| 195 | err = json_scan(cmd, buffer, t, "{id:%,tlv:%}", |
| 196 | JSON_SCAN(json_to_pubkey, &(*hops)[i].node), |
| 197 | JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex, |
| 198 | &(*hops)[i].tlv)); |
| 199 | if (err) |
| 200 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 201 | "%s[%zu]: %s", name, i, err); |
| 202 | } |
| 203 | return NULL; |
| 204 | } |
| 205 | |
| 206 | static struct command_result *json_sendonionmessage(struct command *cmd, |
| 207 | const char *buffer, |
nothing calls this directly
no test coverage detected