| 1031 | } |
| 1032 | |
| 1033 | static 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 | |
| 1057 | void channel_update_reserve(struct channel *channel, |
| 1058 | struct channel_config *their_config, |
no test coverage detected