- /// Handles a [`BumpTransactionEvent::ChannelClose`] event variant by producing a fully-signed
- /// transaction spending an anchor output of the commitment transaction to bump its fee and
- /// broadcasts them to the network as a package.
- fn handle_channel_close(
- &self, claim_id: ClaimId, package_target_feerate_sat_per_1000_weight: u32,
- commitment_tx: &Transaction, commitment_tx_fee_sat: u64, anchor_descriptor: &AnchorDescriptor,
- ) -> Result<(), ()> {
- // Our commitment transaction already has fees allocated to it, so we should take them into
- // account. We compute its feerate and subtract it from the package target, using the result
- // as the target feerate for our anchor transaction. Unfortunately, this results in users
- // overpaying by a small margin since we don't yet know the anchor transaction size, and
- // avoiding the small overpayment only makes our API even more complex.
- let commitment_tx_sat_per_1000_weight: u32 = compute_feerate_sat_per_1000_weight(
- commitment_tx_fee_sat, commitment_tx.weight() as u64,
- );
- let anchor_target_feerate_sat_per_1000_weight = core::cmp::max(
- package_target_feerate_sat_per_1000_weight - commitment_tx_sat_per_1000_weight,
- FEERATE_FLOOR_SATS_PER_KW,
- );
+ #[cfg(debug_assertions)]
+ let total_satisfaction_weight = ANCHOR_INPUT_WITNESS_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT +
+ coin_selection.confirmed_utxos.iter().map(|utxo| utxo.satisfaction_weight).sum::<u64>();
+ #[cfg(debug_assertions)]
+ let total_input_amount = must_spend_amount +
+ coin_selection.confirmed_utxos.iter().map(|utxo| utxo.output.value).sum::<u64>();
+
+ self.process_coin_selection(&mut anchor_tx, coin_selection);
+ let anchor_txid = anchor_tx.txid();