Since this is a dev-only option, we will crash if dev-routes is not * an array-of-arrays-of-correct-items. */
| 981 | /* Since this is a dev-only option, we will crash if dev-routes is not |
| 982 | * an array-of-arrays-of-correct-items. */ |
| 983 | static struct route_info *unpack_route(const tal_t *ctx, |
| 984 | const char *buffer, |
| 985 | const jsmntok_t *routetok) |
| 986 | { |
| 987 | const jsmntok_t *t; |
| 988 | size_t i; |
| 989 | struct route_info *route = tal_arr(ctx, struct route_info, routetok->size); |
| 990 | |
| 991 | json_for_each_arr(i, t, routetok) { |
| 992 | const jsmntok_t *pubkey, *fee_base, *fee_prop, *scid, *cltv; |
| 993 | struct route_info *r = &route[i]; |
| 994 | u32 cltv_u32; |
| 995 | |
| 996 | pubkey = json_get_member(buffer, t, "id"); |
| 997 | scid = json_get_member(buffer, t, "short_channel_id"); |
| 998 | fee_base = json_get_member(buffer, t, "fee_base_msat"); |
| 999 | fee_prop = json_get_member(buffer, t, |
| 1000 | "fee_proportional_millionths"); |
| 1001 | cltv = json_get_member(buffer, t, "cltv_expiry_delta"); |
| 1002 | |
| 1003 | if (!json_to_node_id(buffer, pubkey, &r->pubkey) |
| 1004 | || !json_to_short_channel_id(buffer, scid, |
| 1005 | &r->short_channel_id) |
| 1006 | || !json_to_number(buffer, fee_base, &r->fee_base_msat) |
| 1007 | || !json_to_number(buffer, fee_prop, |
| 1008 | &r->fee_proportional_millionths) |
| 1009 | || !json_to_number(buffer, cltv, &cltv_u32)) |
| 1010 | abort(); |
| 1011 | /* We don't have a json_to_u16 */ |
| 1012 | r->cltv_expiry_delta = cltv_u32; |
| 1013 | } |
| 1014 | return route; |
| 1015 | } |
| 1016 | |
| 1017 | static struct route_info **unpack_routes(const tal_t *ctx, |
| 1018 | const char *buffer, |
no test coverage detected