Skip to content

Commit 52c76ab

Browse files
wpaulinoclaude
andcommitted
Account for missing balance in channel reserve assertions for splices
When we create the post-splice `FundingScope`, the monotonicity debug assertion trackers were initialized to the post-splice balance without accounting for pending HTLCs or anchor costs. Since splices can have in-flight HTLCs (unlike fresh channel opens), the first commitment transaction's actual balance was lower than the initialized max, causing the debug assertion in `ChannelContext::build_commitment_transaction` to fire. Note that we don't need to recompute the full post-splice balance here. We can rely on the pre-splice `FundingScope`'s `holder/counterparty_max_commitment_tx_output` instead since they're already accounted for there. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 153e57e commit 52c76ab

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,15 +2847,21 @@ impl FundingScope {
28472847
counterparty_selected_channel_reserve_satoshis,
28482848
holder_selected_channel_reserve_satoshis,
28492849
#[cfg(debug_assertions)]
2850-
holder_max_commitment_tx_output: Mutex::new((
2851-
post_value_to_self_msat,
2852-
(post_channel_value * 1000).saturating_sub(post_value_to_self_msat),
2853-
)),
2850+
holder_max_commitment_tx_output: {
2851+
let prev = *prev_funding.holder_max_commitment_tx_output.lock().unwrap();
2852+
Mutex::new((
2853+
prev.0.saturating_add_signed(our_funding_contribution.to_sat() * 1000),
2854+
prev.1.saturating_add_signed(their_funding_contribution.to_sat() * 1000),
2855+
))
2856+
},
28542857
#[cfg(debug_assertions)]
2855-
counterparty_max_commitment_tx_output: Mutex::new((
2856-
post_value_to_self_msat,
2857-
(post_channel_value * 1000).saturating_sub(post_value_to_self_msat),
2858-
)),
2858+
counterparty_max_commitment_tx_output: {
2859+
let prev = *prev_funding.counterparty_max_commitment_tx_output.lock().unwrap();
2860+
Mutex::new((
2861+
prev.0.saturating_add_signed(our_funding_contribution.to_sat() * 1000),
2862+
prev.1.saturating_add_signed(their_funding_contribution.to_sat() * 1000),
2863+
))
2864+
},
28592865
#[cfg(any(test, fuzzing))]
28602866
next_local_fee: Mutex::new(PredictedNextFee::default()),
28612867
#[cfg(any(test, fuzzing))]

0 commit comments

Comments
 (0)