| 396 | }; |
| 397 | |
| 398 | static struct command_result *param_paths(struct command *cmd, const char *name, |
| 399 | const char *buffer, const jsmntok_t *tok, |
| 400 | struct path ***paths) |
| 401 | { |
| 402 | size_t i; |
| 403 | const jsmntok_t *t; |
| 404 | const struct offers_data *od = get_offers_data(cmd->plugin); |
| 405 | |
| 406 | if (tok->type != JSMN_ARRAY) |
| 407 | return command_fail_badparam(cmd, name, buffer, tok, "Must be array"); |
| 408 | |
| 409 | *paths = tal_arr(cmd, struct path *, tok->size); |
| 410 | json_for_each_arr(i, t, tok) { |
| 411 | size_t j; |
| 412 | const jsmntok_t *p; |
| 413 | |
| 414 | if (t->type != JSMN_ARRAY || t->size == 0) { |
| 415 | return command_fail_badparam(cmd, name, buffer, t, |
| 416 | "Must be array of non-empty arrays"); |
| 417 | } |
| 418 | |
| 419 | (*paths)[i] = tal(*paths, struct path); |
| 420 | (*paths)[i]->path = tal_arr((*paths)[i], struct pubkey, t->size); |
| 421 | json_for_each_arr(j, p, t) { |
| 422 | struct pubkey pk; |
| 423 | if (j == 0) { |
| 424 | struct sciddir_or_pubkey init; |
| 425 | if (!json_to_sciddir_or_pubkey(buffer, p, &init)) { |
| 426 | return command_fail_badparam(cmd, name, buffer, p, |
| 427 | "invalid pubkey/sciddir"); |
| 428 | } |
| 429 | if (!init.is_pubkey) { |
| 430 | (*paths)[i]->first_scidd = tal_dup((*paths)[i], |
| 431 | struct short_channel_id_dir, |
| 432 | &init.scidd); |
| 433 | if (!gossmap_scidd_pubkey(get_gossmap(cmd->plugin), &init)) { |
| 434 | return command_fail_badparam(cmd, name, buffer, p, |
| 435 | "unknown sciddir"); |
| 436 | } |
| 437 | } else { |
| 438 | (*paths)[i]->first_scidd = NULL; |
| 439 | } |
| 440 | pk = init.pubkey; |
| 441 | } else { |
| 442 | if (!json_to_pubkey(buffer, p, &pk)) { |
| 443 | return command_fail_badparam(cmd, name, buffer, p, |
| 444 | "invalid pubkey"); |
| 445 | } |
| 446 | } |
| 447 | if (j == t->size - 1 && !pubkey_eq(&pk, &od->id)) |
| 448 | return command_fail_badparam(cmd, name, buffer, p, |
| 449 | "final pubkey must be this node"); |
| 450 | (*paths)[i]->path[j] = pk; |
| 451 | } |
| 452 | } |
| 453 | return NULL; |
| 454 | } |
| 455 |
nothing calls this directly
no test coverage detected