Merge PR 'Give keyed-anchor commitments a chance to confirm when funding fails' (#5089)
What changed, and why it matters
This change improves how the Lightning node handles a failed funding attempt for a 'bump' transaction used to speed up a channel close. Previously, if funding the child transaction failed, the pre-signed commitment transaction might never be broadcast, potentially leaving funds stuck. Now, for certain modern channel types (keyed-anchor commitments), the node will still broadcast the pre-signed commitment transaction using its own existing fee, giving it a chance to confirm and recover funds. This is a robustness fix rather than a traditional vulnerability patch.
Review and merge if not already merged; this is a defensive robustness improvement. Users running nodes with keyed-anchor channels benefit from improved fund-recovery behavior when coin selection fails during a force-close. No immediate emergency action is indicated by the diff alone.
Security signals we found
Funds recovery / liveness improvement for failed coin-selection paths
Broadcast of pre-signed commitment on funding failure
Differentiated handling between keyed-anchor and zero-fee anchor commitments
No cryptographic, signature, or authorization changes
Evidence from the diff
In lightning/src/events/bump_transaction/mod.rs, the commit changes error handling when CoinSelectionSource::select_confirmed_utxos fails to fund an anchor child transaction. Previously, the failure propagated as (). Now, if the channel type supports anchors_zero_fee_htlc_tx (i.e., keyed-anchor/zero-fee HTLC commitments), the code logs a warning and broadcasts the pre-signed commitment transaction directly at its own feerate. This ensures that keyed-anchor commitments (which carry their own fee) can still confirm, whereas zero-fee commitments still require a funded child to be relayed. The change also caches commitment_txid earlier to avoid recomputing it.
Changed components
lightning/src/events/bump_transaction/mod.rsAnchor / bump transaction funding flowChannel close / unilateral close broadcast pathInspect captured patch +21 / −3
### lightning/src/events/bump_transaction/mod.rs
@@ -356,6 +356,7 @@ impl<B: BroadcasterInterface, C: CoinSelectionSource, SP: SignerProvider, L: Log
.channel_derivation_parameters
.transaction_parameters
.channel_type_features;
+ let commitment_txid = commitment_tx.compute_txid();
let anchor_input_witness_weight = if channel_type.supports_anchor_zero_fee_commitments() {
EMPTY_WITNESS_WEIGHT
} else {
@@ -375,7 +376,7 @@ impl<B: BroadcasterInterface, C: CoinSelectionSource, SP: SignerProvider, L: Log
);
if commitment_tx_feerate_sat_per_1000_weight >= package_target_feerate_sat_per_1000_weight {
log_debug!(self.logger, "Pre-signed commitment {} already has feerate {} sat/kW above required {} sat/kW, broadcasting.",
- commitment_tx.compute_txid(), commitment_tx_feerate_sat_per_1000_weight,
+ commitment_txid, commitment_tx_feerate_sat_per_1000_weight,
package_target_feerate_sat_per_1000_weight);
self.broadcaster.broadcast_transactions(&[(
&commitment_tx,
@@ -423,7 +424,24 @@ impl<B: BroadcasterInterface, C: CoinSelectionSource, SP: SignerProvider, L: Log
// increase the max_tx_weight by the same delta here.
+ commitment_tx_weight,
)
- .await?;
+ .await
+ .map_err(|()| {
+ // Keyed-anchor commitments may still confirm using their
+ // existing fees. Zero-fee commitments require a funded
+ // child to be relayed.
+ if channel_type.supports_anchors_zero_fee_htlc_tx() {
+ log_warn!(
+ self.logger,
+ "Funding the anchor child transaction failed; broadcasting pre-signed commitment {} at its own feerate of {} sat/kW",
+ commitment_txid,
+ commitment_tx_feerate_sat_per_1000_weight,
+ );
+ self.broadcaster.broadcast_transactions(&[(
+ &commitment_tx,
+ TransactionType::UnilateralClose { counterparty_node_id, channel_id },
+ )]);
+ }
+ })?;
let version = if channel_type.supports_anchor_zero_fee_commitments() {
Version::non_standard(3)
@@ -543,7 +561,7 @@ impl<B: BroadcasterInterface, C: CoinSelectionSource, SP: SignerProvider, L: Log
self.logger,
"Broadcasting anchor transaction {} to bump channel close with txid {}",
anchor_txid,
- commitment_tx.compute_txid()
+ commitment_txid,
);
self.broadcaster.broadcast_transactions(&[
(Why this scored 41/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.