Make SpliceFundingFailed::contribution non-optional
What changed, and why it matters
This commit is a small internal cleanup in the Lightning Dev Kit code. It removes an unnecessary 'Option' wrapper from a data field called `contribution` inside `SpliceFundingFailed`, because that field is always created from a real value. The public `Event::SpliceNegotiationFailed::contribution` field remains optional for backward compatibility with older stored data. There is no security fix here.
No security action needed. Treat as normal code maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch changes SpliceFundingFailed::contribution from Option<FundingContribution> to FundingContribution and updates into_parts() to return (Option<FundingInfo>, FundingContribution). Call sites in channelmanager.rs now wrap the returned contribution in Some(...) when constructing Event::SpliceNegotiationFailed, preserving the optional public API. This is a type-refactoring change with no functional or security behavior change.
Changed components
lightning/src/ln/channel.rslightning/src/ln/channelmanager.rsInspect captured patch +14 / −16
diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs
index 6f50d52..fb5a7de 100644
--- a/lightning/src/ln/channel.rs
+++ b/lightning/src/ln/channel.rs
@@ -7205,14 +7205,14 @@ pub struct SpliceFundingFailed {
/// in prior rounds, which may be included in `contribution`.
contributed_outputs: Vec<ScriptBuf>,
- /// The funding contribution from the failed round, if available.
- contribution: Option<FundingContribution>,
+ /// The funding contribution from the failed round.
+ contribution: FundingContribution,
}
impl SpliceFundingFailed {
/// Splits into the funding info for `DiscardFunding` (if there are inputs or outputs to
/// discard) and the contribution for `SpliceNegotiationFailed`.
- pub(super) fn into_parts(self) -> (Option<FundingInfo>, Option<FundingContribution>) {
+ pub(super) fn into_parts(self) -> (Option<FundingInfo>, FundingContribution) {
let funding_info =
if !self.contributed_inputs.is_empty() || !self.contributed_outputs.is_empty() {
Some(FundingInfo::Contribution {
@@ -7239,12 +7239,10 @@ macro_rules! splice_funding_failed_for {
None => SpliceFundingFailed {
contributed_inputs: vec![],
contributed_outputs: vec![],
- contribution: Some(contribution),
+ contribution,
},
- Some((contributed_inputs, contributed_outputs)) => SpliceFundingFailed {
- contributed_inputs,
- contributed_outputs,
- contribution: Some(contribution),
+ Some((contributed_inputs, contributed_outputs)) => {
+ SpliceFundingFailed { contributed_inputs, contributed_outputs, contribution }
},
}
}};
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 88c9b7b..b159cd3 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -4233,7 +4233,7 @@ impl<
channel_id: *chan_id,
counterparty_node_id: *counterparty_node_id,
user_channel_id: chan.context().get_user_id(),
- contribution,
+ contribution: Some(contribution),
reason: events::NegotiationFailureReason::ChannelClosing,
},
None,
@@ -4539,7 +4539,7 @@ impl<
channel_id: shutdown_res.channel_id,
counterparty_node_id: shutdown_res.counterparty_node_id,
user_channel_id: shutdown_res.user_channel_id,
- contribution,
+ contribution: Some(contribution),
reason: events::NegotiationFailureReason::ChannelClosing,
},
None,
@@ -6729,7 +6729,7 @@ impl<
counterparty_node_id,
user_channel_id,
reason,
- contribution,
+ contribution: Some(contribution),
},
None,
));
@@ -12046,7 +12046,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
channel_id,
counterparty_node_id: *counterparty_node_id,
user_channel_id,
- contribution,
+ contribution: Some(contribution),
reason,
},
None,
@@ -12384,7 +12384,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
channel_id: msg.channel_id,
counterparty_node_id: *counterparty_node_id,
user_channel_id: chan_entry.get().context().get_user_id(),
- contribution,
+ contribution: Some(contribution),
reason: events::NegotiationFailureReason::CounterpartyAborted {
msg: UntrustedString(
String::from_utf8_lossy(&msg.data).to_string(),
@@ -12549,7 +12549,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
channel_id: msg.channel_id,
counterparty_node_id: *counterparty_node_id,
user_channel_id: chan.context().get_user_id(),
- contribution,
+ contribution: Some(contribution),
reason: events::NegotiationFailureReason::ChannelClosing,
},
None,
@@ -15794,7 +15794,7 @@ impl<
channel_id: chan.context().channel_id(),
counterparty_node_id,
user_channel_id: chan.context().get_user_id(),
- contribution,
+ contribution: Some(contribution),
reason: events::NegotiationFailureReason::PeerDisconnected,
});
}
@@ -18435,7 +18435,7 @@ impl<
counterparty_node_id: chan.context.get_counterparty_node_id(),
user_channel_id: chan.context.get_user_id(),
reason: events::NegotiationFailureReason::PeerDisconnected,
- contribution,
+ contribution: Some(contribution),
},
None,
));
Why this scored 13/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.