| 711 | } |
| 712 | |
| 713 | struct command_result *param_hops_array(struct command *cmd, const char *name, |
| 714 | const char *buffer, const jsmntok_t *tok, |
| 715 | struct sphinx_hop **hops) |
| 716 | { |
| 717 | const jsmntok_t *hop, *payloadtok, *pubkeytok; |
| 718 | struct sphinx_hop h; |
| 719 | size_t i; |
| 720 | if (tok->type != JSMN_ARRAY) { |
| 721 | return command_fail_badparam(cmd, name, buffer, tok, |
| 722 | "should be an array of hops"); |
| 723 | } |
| 724 | |
| 725 | *hops = tal_arr(cmd, struct sphinx_hop, 0); |
| 726 | |
| 727 | json_for_each_arr(i, hop, tok) { |
| 728 | payloadtok = json_get_member(buffer, hop, "payload"); |
| 729 | pubkeytok = json_get_member(buffer, hop, "pubkey"); |
| 730 | |
| 731 | if (!pubkeytok) |
| 732 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 733 | "Hop %zu does not have a pubkey", i); |
| 734 | |
| 735 | if (!payloadtok) |
| 736 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 737 | "Hop %zu does not have a payload", i); |
| 738 | |
| 739 | h.raw_payload = json_tok_bin_from_hex(*hops, buffer, payloadtok); |
| 740 | if (!json_to_pubkey(buffer, pubkeytok, &h.pubkey)) |
| 741 | return command_fail_badparam(cmd, name, buffer, pubkeytok, |
| 742 | "should be a pubkey"); |
| 743 | |
| 744 | if (!h.raw_payload) |
| 745 | return command_fail_badparam(cmd, name, buffer, |
| 746 | payloadtok, |
| 747 | "should be hex"); |
| 748 | |
| 749 | tal_arr_expand(hops, h); |
| 750 | } |
| 751 | |
| 752 | if (tal_count(*hops) == 0) { |
| 753 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 754 | "At least one hop must be specified."); |
| 755 | } |
| 756 | |
| 757 | return NULL; |
| 758 | } |
| 759 | |
| 760 | struct command_result *param_secrets_array(struct command *cmd, |
| 761 | const char *name, const char *buffer, |
nothing calls this directly
no test coverage detected