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

Function splice_to_string

common/splice_script.c:2755–2831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2753}
2754
2755char *splice_to_string(const tal_t *ctx,
2756 struct splice_script_result *result)
2757{
2758 const char *into_prefix, *fee_str;
2759 char *str = tal_strdup(ctx, "");
2760
2761 into_prefix = "";
2762 fee_str = "";
2763 if (!amount_sat_is_zero(result->lease_sat)) {
2764 into_prefix = "and ";
2765 tal_append_fmt(&str, "lease %s ",
2766 fmt_amount_sat(ctx,
2767 result->lease_sat));
2768 if (result->lease_max_ppm)
2769 tal_append_fmt(&str, "(max fee %s) ",
2770 ppm_to_str(ctx, result->lease_max_ppm));
2771 }
2772
2773 if (result->pays_fee)
2774 fee_str = " less fee";
2775 if (result->feerate_per_kw)
2776 fee_str = tal_fmt(tmpctx, " less fee (%u/kw)",
2777 result->feerate_per_kw);
2778
2779 if (!amount_sat_is_zero(result->in_sat))
2780 tal_append_fmt(&str, "%sput %s%s %s ", into_prefix,
2781 fmt_amount_sat(ctx, result->in_sat),
2782 fee_str,
2783 result->in_ppm ? "and" : "into");
2784 if (result->in_ppm)
2785 tal_append_fmt(&str, "%s%s%s%s of rest into ", into_prefix,
2786 amount_sat_is_zero(result->in_sat) ? "put " : "",
2787 ppm_to_str(ctx, result->in_ppm),
2788 fee_str);
2789
2790 if (result->channel_id)
2791 tal_append_fmt(&str, "%s",
2792 tal_hexstr(tmpctx, result->channel_id, sizeof(struct channel_id)));
2793 if (result->bitcoin_address)
2794 tal_append_fmt(&str, "%s", result->bitcoin_address);
2795 if (result->onchain_wallet)
2796 tal_append_fmt(&str, "wallet");
2797
2798 fee_str = "";
2799 if (result->pays_fee)
2800 fee_str = " plus fee";
2801 if (result->feerate_per_kw)
2802 fee_str = tal_fmt(tmpctx, " plus fee (%u/kw, %.02f"
2803 " sat/vB) ",
2804 result->feerate_per_kw,
2805 4 * result->feerate_per_kw / 1000.0f);
2806
2807 if (!amount_sat_is_zero(result->out_sat))
2808 tal_append_fmt(&str, " withdraw %s%s",
2809 fmt_amount_sat(ctx, result->out_sat),
2810 fee_str);
2811 if (result->out_ppm)
2812 tal_append_fmt(&str, " %s %s%s",

Callers 2

splicearr_to_stringFunction · 0.85
add_to_debug_logFunction · 0.85

Calls 5

amount_sat_is_zeroFunction · 0.85
tal_append_fmtFunction · 0.85
ppm_to_strFunction · 0.85
tal_hexstrFunction · 0.85
fmt_amount_satFunction · 0.70

Tested by

no test coverage detected