Skip to content

Commit 1549b74

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 5c3575f commit 1549b74

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
@@ -7293,20 +7293,20 @@ where
72937293
into_contributed_inputs_and_outputs
72947294
);
72957295

7296-
// Pop the current round's contribution if it wasn't from a negotiated round. Each round
7297-
// pushes a new entry to `contributions`; if the round aborts, we undo the push so that
7298-
// `contributions.last()` reflects the most recent negotiated round's contribution. This
7299-
// must happen after `maybe_create_splice_funding_failed` so that
7300-
// `prior_contributed_inputs` still includes the prior rounds' entries for filtering.
7301-
if let Some(pending_splice) = self.pending_splice.as_mut() {
7302-
if let Some(last) = pending_splice.contributions.last() {
7303-
let was_negotiated = pending_splice
7296+
// Pop the current round's contribution, if any (acceptors may not have one). This
7297+
// must happen after `maybe_create_splice_funding_failed` for correct filtering.
7298+
let pending_splice = self
7299+
.pending_splice
7300+
.as_mut()
7301+
.expect("reset_pending_splice_state requires pending_splice");
7302+
if let Some(contribution) = pending_splice.contributions.pop() {
7303+
debug_assert!(
7304+
pending_splice
73047305
.last_funding_feerate_sat_per_1000_weight
7305-
.is_some_and(|f| last.feerate() == FeeRate::from_sat_per_kwu(f as u64));
7306-
if !was_negotiated {
7307-
pending_splice.contributions.pop();
7308-
}
7309-
}
7306+
.map(|f| contribution.feerate() > FeeRate::from_sat_per_kwu(f as u64))
7307+
.unwrap_or(true),
7308+
"current round's feerate should be greater than the last negotiated feerate",
7309+
);
73107310
}
73117311

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

0 commit comments

Comments
 (0)