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

Function json_to_splice

common/splice_script.c:2646–2742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2644}
2645
2646bool json_to_splice(const tal_t *ctx, const char *buffer, const jsmntok_t *tok,
2647 struct splice_script_result ***result)
2648{
2649 const jsmntok_t *splice;
2650 const jsmntok_t *itr;
2651 size_t i;
2652
2653 splice = json_get_member(buffer, tok, "splice");
2654 if (!splice || splice->type != JSMN_ARRAY)
2655 return false;
2656
2657 *result = tal_arr(ctx, struct splice_script_result*, 0);
2658 json_for_each_arr(i, itr, splice) {
2659 const jsmntok_t *lease, *in, *dest, *out, *fee, *obj;
2660 struct splice_script_result *ele = talz(*result, struct splice_script_result);
2661
2662 if ((lease = json_get_member(buffer, itr, "lease_request"))) {
2663 if ((obj = json_get_member(buffer, lease,
2664 "amount_msat"))) {
2665 if (!json_to_msat_to_sat(buffer, obj,
2666 &ele->lease_sat))
2667 return false;
2668 }
2669 if ((obj = json_get_member(buffer, lease, "max_ppm"))) {
2670 if (!json_to_u32(buffer, obj,
2671 &ele->lease_max_ppm))
2672 return false;
2673 }
2674 }
2675
2676 if ((in = json_get_member(buffer, itr, "into_destination"))) {
2677 if ((obj = json_get_member(buffer, in,
2678 "amount_msat"))) {
2679 if (!json_to_msat_to_sat(buffer, obj,
2680 &ele->in_sat))
2681 return false;
2682 }
2683 if ((obj = json_get_member(buffer, in, "ppm"))) {
2684 if (!json_to_u32(buffer, obj, &ele->in_ppm))
2685 return false;
2686 }
2687 }
2688
2689 if ((dest = json_get_member(buffer, itr, "destination"))) {
2690 if ((obj = json_get_member(buffer, dest,
2691 "channel_id"))) {
2692 ele->channel_id = tal(ele, struct channel_id);
2693 if (!json_to_channel_id(buffer, obj,
2694 ele->channel_id))
2695 return false;
2696 }
2697 if ((obj = json_get_member(buffer, dest,
2698 "bitcoin_address"))) {
2699 ele->bitcoin_address = json_strdup(ele, buffer,
2700 obj);
2701 if (!ele->bitcoin_address)
2702 return false;
2703 }

Callers 2

mainFunction · 0.85
json_spliceFunction · 0.85

Calls 6

json_get_memberFunction · 0.85
json_to_msat_to_satFunction · 0.70
json_to_channel_idFunction · 0.70
json_to_u32Function · 0.50
json_strdupFunction · 0.50
json_to_boolFunction · 0.50

Tested by 1

mainFunction · 0.68