Skip to content

Commit bdfedc4

Browse files
committed
f: add comments to the trimming loops
1 parent c1a7b0a commit bdfedc4

File tree

1 file changed

+6
-0
lines changed
  • lightning/src/events/bump_transaction

1 file changed

+6
-0
lines changed

lightning/src/events/bump_transaction/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@ where
507507
{
508508
break;
509509
}
510+
// If adding this UTXO to `selected_utxos` would push us over the
511+
// `max_coin_selection_weight`, remove UTXOs from the front to make room
512+
// for this new UTXO.
510513
while selected_utxos_weight + BASE_INPUT_WEIGHT + utxo.satisfaction_weight
511514
> max_coin_selection_weight
512515
&& !selected_utxos.is_empty()
@@ -534,6 +537,9 @@ where
534537
);
535538
return Err(());
536539
}
540+
// Once we've selected enough UTXOs to cover `target_amount_sat + total_fees`,
541+
// we may be able to remove some small-value ones while still covering
542+
// `target_amount_sat + total_fees`.
537543
while !selected_utxos.is_empty()
538544
&& selected_amount - selected_utxos.front().unwrap().0.output.value
539545
>= target_amount_sat + total_fees - selected_utxos.front().unwrap().1

0 commit comments

Comments
 (0)