Fix debug_assert on our_funding_contribution
What changed, and why it matters
This commit fixes a sanity check (debug_assert) used during a new experimental feature called splicing in the Lightning Dev Kit. The check previously only accepted positive funding contributions, but splicing can also involve negative contributions (splice-out). The fix makes the check use the absolute value. This is a debug-only assertion, so it only affects test/debug builds and cannot be exploited in production release builds.
No urgent action. Treat as a normal bug fix. If running debug builds with splicing enabled, update to include this commit to avoid spurious assertion failures.
Security signals we found
Fixes an overly restrictive debug-only assertion
Relates to experimental splicing funding negotiation
No runtime production impact because debug_assert is elided in release builds
Evidence from the diff
In lightning/src/ln/channel.rs, the splice_ack handler had a debug_assert!(our_funding_contribution <= SignedAmount::MAX_MONEY). Because our_funding_contribution can be negative for splice-out, the assertion could incorrectly fire on valid negative values. The patch changes it to debug_assert!(our_funding_contribution.abs() <= SignedAmount::MAX_MONEY), matching the intended range check. debug_assert is compiled out in release builds, so this is a correctness fix for debug/test builds only, not a runtime security boundary.
Changed components
lightning/src/ln/channel.rsSplice acknowledgment handlingDebug assertion for our_funding_contributionInspect captured patch +1 / −1
diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs
index a04b603..59062b8 100644
--- a/lightning/src/ln/channel.rs
+++ b/lightning/src/ln/channel.rs
@@ -11019,7 +11019,7 @@ where
};
let our_funding_contribution = funding_negotiation_context.our_funding_contribution;
- debug_assert!(our_funding_contribution <= SignedAmount::MAX_MONEY);
+ debug_assert!(our_funding_contribution.abs() <= SignedAmount::MAX_MONEY);
let their_funding_contribution = SignedAmount::from_sat(msg.funding_contribution_satoshis);
self.validate_splice_contribution(their_funding_contribution)?;
Why this scored 16/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.