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

Function splice_to_json

common/splice_script.c:2570–2634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2568}
2569
2570void splice_to_json(const tal_t *ctx,
2571 struct splice_script_result **splice,
2572 struct json_stream *js)
2573{
2574 json_object_start(js, NULL);
2575 json_array_start(js, "splice");
2576 for (size_t i = 0; i < tal_count(splice); i++) {
2577 json_object_start(js, NULL);
2578
2579 if (!amount_sat_is_zero(splice[i]->lease_sat)) {
2580 json_object_start(js, "lease_request");
2581 json_add_amount_sat_msat(js, "amount_msat",
2582 splice[i]->lease_sat);
2583 json_add_u32(js, "max_ppm", splice[i]->lease_max_ppm);
2584 json_object_end(js);
2585 }
2586
2587 if (!amount_sat_is_zero(splice[i]->in_sat) || splice[i]->in_ppm) {
2588 json_object_start(js, "into_destination");
2589 if (!amount_sat_is_zero(splice[i]->in_sat))
2590 json_add_amount_sat_msat(js, "amount_msat",
2591 splice[i]->in_sat);
2592 if (splice[i]->in_ppm)
2593 json_add_u32(js, "ppm", splice[i]->in_ppm);
2594 json_object_end(js);
2595 }
2596
2597 json_object_start(js, "destination");
2598 if (splice[i]->channel_id)
2599 json_add_channel_id(js, "channel_id",
2600 splice[i]->channel_id);
2601 if (splice[i]->bitcoin_address)
2602 json_add_string(js, "bitcoin_address",
2603 splice[i]->bitcoin_address);
2604 if (splice[i]->onchain_wallet)
2605 json_add_bool(js, "onchain_wallet", true);
2606 json_object_end(js);
2607
2608 if (!amount_sat_is_zero(splice[i]->out_sat)
2609 || splice[i]->out_ppm) {
2610 json_object_start(js, "outof_destination");
2611 if (!amount_sat_is_zero(splice[i]->out_sat))
2612 json_add_amount_sat_msat(js, "amount_msat",
2613 splice[i]->out_sat);
2614 if (splice[i]->out_ppm)
2615 json_add_u32(js, "ppm", splice[i]->out_ppm);
2616 json_object_end(js);
2617 }
2618
2619 if (splice[i]->pays_fee || splice[i]->feerate_per_kw) {
2620 json_object_start(js, "fee");
2621 if (splice[i]->pays_fee)
2622 json_add_bool(js, "pays_fee",
2623 splice[i]->pays_fee);
2624 if (splice[i]->feerate_per_kw)
2625 json_add_u32(js, "feerate_per_kw",
2626 splice[i]->feerate_per_kw);
2627 json_object_end(js);

Callers 1

mainFunction · 0.85

Calls 10

json_object_startFunction · 0.85
json_array_startFunction · 0.85
amount_sat_is_zeroFunction · 0.85
json_add_amount_sat_msatFunction · 0.85
json_add_u32Function · 0.85
json_object_endFunction · 0.85
json_add_channel_idFunction · 0.85
json_add_boolFunction · 0.85
json_array_endFunction · 0.85
json_add_stringFunction · 0.70

Tested by 1

mainFunction · 0.68