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