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

Function calculate_reserve

lightningd/dual_open_control.c:1033–1055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1031}
1032
1033static struct amount_sat calculate_reserve(struct channel_config *their_config,
1034 struct amount_sat funding_total,
1035 enum side opener)
1036{
1037 struct amount_sat reserve, dust_limit;
1038
1039 /* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2
1040 *
1041 * The channel reserve is fixed at 1% of the total channel balance
1042 * rounded down (sum of `funding_satoshis` from `open_channel2`
1043 * and `accept_channel2`) or the `dust_limit_satoshis` from
1044 * `open_channel2`, whichever is greater.
1045 */
1046 reserve = amount_sat_div(funding_total, 100);
1047 dust_limit = opener == LOCAL ?
1048 chainparams->dust_limit :
1049 their_config->dust_limit;
1050
1051 if (amount_sat_greater(dust_limit, reserve))
1052 return dust_limit;
1053
1054 return reserve;
1055}
1056
1057void channel_update_reserve(struct channel *channel,
1058 struct channel_config *their_config,

Callers 1

channel_update_reserveFunction · 0.85

Calls 2

amount_sat_divFunction · 0.85
amount_sat_greaterFunction · 0.85

Tested by

no test coverage detected