@@ -174,15 +174,14 @@ impl Default for AnchorChannelReserveContext {
174174pub  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	) ; 
@@ -217,14 +216,10 @@ pub fn get_supportable_anchor_channels(
217216		} 
218217	} 
219218	// 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. 
221220	// 
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. 
228223	num_whole_utxos + total_fractional_amount. to_sat ( )  / reserve_per_channel. to_sat ( )  / 2 
229224} 
230225
0 commit comments