Skip to content

Commit cbc497d

Browse files
committed
f Adjust documentation
1 parent bf41b1f commit cbc497d

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

lightning/src/util/anchor_channel_reserves.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,14 @@ impl Default for AnchorChannelReserveContext {
174174
pub fn get_reserve_per_channel(context: &AnchorChannelReserveContext) -> Amount {
175175
let weight = Weight::from_wu(
176176
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.
181181
2 * (context.expected_accepted_htlcs as u64) * COMMITMENT_TRANSACTION_PER_HTLC_WEIGHT +
182182
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.
186185
htlc_success_transaction_weight(context) * (context.expected_accepted_htlcs as u64) +
187186
htlc_timeout_transaction_weight(context) * (context.expected_accepted_htlcs as u64),
188187
);
@@ -222,14 +221,10 @@ pub fn get_supportable_anchor_channels(
222221
}
223222
}
224223
// We require disjoint sets of UTXOs for the reserve of each channel,
225-
// as claims are only aggregated per channel currently.
224+
// as claims are currently only aggregated per channel.
226225
//
227-
// UTXOs larger than the required reserve are a singleton disjoint set.
228-
// A disjoint set of fractional UTXOs could overcontribute by any amount less than the
229-
// required reserve, approaching double the reserve.
230-
//
231-
// Note that for the fractional UTXOs, this is an approximation as we can't efficiently calculate
232-
// a worst-case coin selection as an NP-complete problem.
226+
// A worst-case coin selection is assumed for fractional UTXOs, selecting up to double the
227+
// required amount.
233228
num_whole_utxos + total_fractional_amount.to_sat() / reserve_per_channel.to_sat() / 2
234229
}
235230

0 commit comments

Comments
 (0)