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