| 1023 | } |
| 1024 | |
| 1025 | static struct command_result *param_routehint(struct command *cmd, |
| 1026 | const char *name, |
| 1027 | const char *buffer, |
| 1028 | const jsmntok_t *tok, |
| 1029 | struct route_info **ri) |
| 1030 | { |
| 1031 | size_t i; |
| 1032 | const jsmntok_t *curr; |
| 1033 | const char *err; |
| 1034 | |
| 1035 | if (tok->type != JSMN_ARRAY) { |
| 1036 | return command_fail( |
| 1037 | cmd, JSONRPC2_INVALID_PARAMS, |
| 1038 | "Routehint %s (\"%s\") is not an array of hop objects", |
| 1039 | name, json_strdup(tmpctx, buffer, tok)); |
| 1040 | } |
| 1041 | |
| 1042 | *ri = tal_arr(cmd, struct route_info, tok->size); |
| 1043 | json_for_each_arr(i, curr, tok) { |
| 1044 | struct route_info *e = &(*ri)[i]; |
| 1045 | struct amount_msat temp; |
| 1046 | |
| 1047 | err = json_scan(tmpctx, buffer, curr, |
| 1048 | "{id:%,scid:%,feebase:%,feeprop:%,expirydelta:%}", |
| 1049 | JSON_SCAN(json_to_node_id, &e->pubkey), |
| 1050 | JSON_SCAN(json_to_short_channel_id, &e->short_channel_id), |
| 1051 | JSON_SCAN(json_to_msat, &temp), |
| 1052 | JSON_SCAN(json_to_u32, &e->fee_proportional_millionths), |
| 1053 | JSON_SCAN(json_to_u16, &e->cltv_expiry_delta) |
| 1054 | ); |
| 1055 | e->fee_base_msat = |
| 1056 | temp.millisatoshis; /* Raw: internal conversion. */ |
| 1057 | if (err != NULL) { |
| 1058 | return command_fail( |
| 1059 | cmd, JSONRPC2_INVALID_PARAMS, |
| 1060 | "Error parsing routehint %s[%zu]: %s", name, i, |
| 1061 | err); |
| 1062 | } |
| 1063 | } |
| 1064 | return NULL; |
| 1065 | } |
| 1066 | |
| 1067 | struct command_result * |
| 1068 | param_routehint_array(struct command *cmd, const char *name, const char *buffer, |
no test coverage detected