MCPcopy Create free account
hub / github.com/ElementsProject/lightning / unpack_route

Function unpack_route

lightningd/invoice.c:957–989  ·  view source on GitHub ↗

Since this is a dev-only option, we will crash if dev-routes is not * an array-of-arrays-of-correct-items. */

Source from the content-addressed store, hash-verified

955/* Since this is a dev-only option, we will crash if dev-routes is not
956 * an array-of-arrays-of-correct-items. */
957static struct route_info *unpack_route(const tal_t *ctx,
958 const char *buffer,
959 const jsmntok_t *routetok)
960{
961 const jsmntok_t *t;
962 size_t i;
963 struct route_info *route = tal_arr(ctx, struct route_info, routetok->size);
964
965 json_for_each_arr(i, t, routetok) {
966 const jsmntok_t *pubkey, *fee_base, *fee_prop, *scid, *cltv;
967 struct route_info *r = &route[i];
968 u32 cltv_u32;
969
970 pubkey = json_get_member(buffer, t, "id");
971 scid = json_get_member(buffer, t, "short_channel_id");
972 fee_base = json_get_member(buffer, t, "fee_base_msat");
973 fee_prop = json_get_member(buffer, t,
974 "fee_proportional_millionths");
975 cltv = json_get_member(buffer, t, "cltv_expiry_delta");
976
977 if (!json_to_node_id(buffer, pubkey, &r->pubkey)
978 || !json_to_short_channel_id(buffer, scid,
979 &r->short_channel_id)
980 || !json_to_number(buffer, fee_base, &r->fee_base_msat)
981 || !json_to_number(buffer, fee_prop,
982 &r->fee_proportional_millionths)
983 || !json_to_number(buffer, cltv, &cltv_u32))
984 abort();
985 /* We don't have a json_to_u16 */
986 r->cltv_expiry_delta = cltv_u32;
987 }
988 return route;
989}
990
991static struct route_info **unpack_routes(const tal_t *ctx,
992 const char *buffer,

Callers 1

unpack_routesFunction · 0.85

Calls 5

abortFunction · 0.85
json_get_memberFunction · 0.50
json_to_node_idFunction · 0.50
json_to_short_channel_idFunction · 0.50
json_to_numberFunction · 0.50

Tested by

no test coverage detected