@@ -174,15 +174,14 @@ impl Default for AnchorChannelReserveContext {
174
174
pub fn get_reserve_per_channel ( context : & AnchorChannelReserveContext ) -> Amount {
175
175
let weight = Weight :: from_wu (
176
176
COMMITMENT_TRANSACTION_BASE_WEIGHT +
177
- // Reserves are calculated assuming each accepted HTLC is forwarded as the upper bound.
178
- // - Inbound payments would require less reserves, but confirmations are still required when
179
- // making the preimage public through the mempool.
180
- // - Outbound payments don't require reserves to avoid loss of funds .
177
+ // Reserves are calculated in terms of accepted HTLCs, as their timeout defines the urgency of
178
+ // on-chain resolution. Each accepted HTLC is assumed to be forwarded to calculate an upper
179
+ // bound for the reserve, resulting in `expected_accepted_htlcs` inbound HTLCs and
180
+ // `expected_accepted_htlcs` outbound HTLCs per channel in aggregate .
181
181
2 * ( context. expected_accepted_htlcs as u64 ) * COMMITMENT_TRANSACTION_PER_HTLC_WEIGHT +
182
182
anchor_output_spend_transaction_weight ( context) +
183
- // To calculate an upper bound on required reserves, it is assumed that each HTLC is resolved in a
184
- // separate transaction. However, they might be aggregated when possible depending on timelocks and
185
- // expiries.
183
+ // As an upper bound, it is assumed that each HTLC is resolved in a separate transaction.
184
+ // However, they might be aggregated when possible depending on timelocks and expiries.
186
185
htlc_success_transaction_weight ( context) * ( context. expected_accepted_htlcs as u64 ) +
187
186
htlc_timeout_transaction_weight ( context) * ( context. expected_accepted_htlcs as u64 ) ,
188
187
) ;
@@ -217,14 +216,10 @@ pub fn get_supportable_anchor_channels(
217
216
}
218
217
}
219
218
// We require disjoint sets of UTXOs for the reserve of each channel,
220
- // as claims are only aggregated per channel currently .
219
+ // as claims are currently only aggregated per channel.
221
220
//
222
- // UTXOs larger than the required reserve are a singleton disjoint set.
223
- // A disjoint set of fractional UTXOs could overcontribute by any amount less than the
224
- // required reserve, approaching double the reserve.
225
- //
226
- // Note that for the fractional UTXOs, this is an approximation as we can't efficiently calculate
227
- // a worst-case coin selection as an NP-complete problem.
221
+ // A worst-case coin selection is assumed for fractional UTXOs, selecting up to double the
222
+ // required amount.
228
223
num_whole_utxos + total_fractional_amount. to_sat ( ) / reserve_per_channel. to_sat ( ) / 2
229
224
}
230
225
0 commit comments