| 905 | } |
| 906 | |
| 907 | static struct command_result *param_routehint(struct command *cmd, |
| 908 | const char *name, |
| 909 | const char *buffer, |
| 910 | const jsmntok_t *tok, |
| 911 | struct route_info **ri) |
| 912 | { |
| 913 | size_t i; |
| 914 | const jsmntok_t *curr; |
| 915 | const char *err; |
| 916 | |
| 917 | if (tok->type != JSMN_ARRAY) { |
| 918 | return command_fail( |
| 919 | cmd, JSONRPC2_INVALID_PARAMS, |
| 920 | "Routehint %s (\"%s\") is not an array of hop objects", |
| 921 | name, json_strdup(tmpctx, buffer, tok)); |
| 922 | } |
| 923 | |
| 924 | *ri = tal_arr(cmd, struct route_info, tok->size); |
| 925 | json_for_each_arr(i, curr, tok) { |
| 926 | struct route_info *e = &(*ri)[i]; |
| 927 | struct amount_msat temp; |
| 928 | |
| 929 | err = json_scan(tmpctx, buffer, curr, |
| 930 | "{id:%,scid:%,feebase:%,feeprop:%,expirydelta:%}", |
| 931 | JSON_SCAN(json_to_node_id, &e->pubkey), |
| 932 | JSON_SCAN(json_to_short_channel_id, &e->short_channel_id), |
| 933 | JSON_SCAN(json_to_msat, &temp), |
| 934 | JSON_SCAN(json_to_u32, &e->fee_proportional_millionths), |
| 935 | JSON_SCAN(json_to_u16, &e->cltv_expiry_delta) |
| 936 | ); |
| 937 | e->fee_base_msat = |
| 938 | temp.millisatoshis; /* Raw: internal conversion. */ |
| 939 | if (err != NULL) { |
| 940 | return command_fail( |
| 941 | cmd, JSONRPC2_INVALID_PARAMS, |
| 942 | "Error parsing routehint %s[%zu]: %s", name, i, |
| 943 | err); |
| 944 | } |
| 945 | } |
| 946 | return NULL; |
| 947 | } |
| 948 | |
| 949 | struct command_result * |
| 950 | param_routehint_array(struct command *cmd, const char *name, const char *buffer, |
no test coverage detected