Skip to content

Commit 8ba5e9b

Browse files
jkczyzclaude
andcommitted
Simplify contribution pop in reset_pending_splice_state
The was_negotiated check is unnecessary because reset_pending_splice_state only runs when funding_negotiation is present, meaning on_tx_signatures_exchange hasn't been called yet. Since the feerate is only recorded in last_funding_feerate_sat_per_1000_weight during on_tx_signatures_exchange, the current round's feerate can never match it. So the contribution can always be unconditionally popped. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3d04483 commit 8ba5e9b

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6977,20 +6977,20 @@ where
69776977
into_contributed_inputs_and_outputs
69786978
);
69796979

6980-
// Pop the current round's contribution if it wasn't from a negotiated round. Each round
6981-
// pushes a new entry to `contributions`; if the round aborts, we undo the push so that
6982-
// `contributions.last()` reflects the most recent negotiated round's contribution. This
6983-
// must happen after `maybe_create_splice_funding_failed` so that
6984-
// `prior_contributed_inputs` still includes the prior rounds' entries for filtering.
6985-
if let Some(pending_splice) = self.pending_splice.as_mut() {
6986-
if let Some(last) = pending_splice.contributions.last() {
6987-
let was_negotiated = pending_splice
6980+
// Pop the current round's contribution, if any (acceptors may not have one). This
6981+
// must happen after `maybe_create_splice_funding_failed` for correct filtering.
6982+
let pending_splice = self
6983+
.pending_splice
6984+
.as_mut()
6985+
.expect("reset_pending_splice_state requires pending_splice");
6986+
if let Some(contribution) = pending_splice.contributions.pop() {
6987+
debug_assert!(
6988+
pending_splice
69886989
.last_funding_feerate_sat_per_1000_weight
6989-
.is_some_and(|f| last.feerate() == FeeRate::from_sat_per_kwu(f as u64));
6990-
if !was_negotiated {
6991-
pending_splice.contributions.pop();
6992-
}
6993-
}
6990+
.map(|f| contribution.feerate() > FeeRate::from_sat_per_kwu(f as u64))
6991+
.unwrap_or(true),
6992+
"current round's feerate should be greater than the last negotiated feerate",
6993+
);
69946994
}
69956995

69966996
if self.pending_funding().is_empty() {

0 commit comments

Comments
 (0)