Remove useless use of format! throughout splicing errors
What changed, and why it matters
This commit is a minor code cleanup. It replaces `format!("...")` with `"...".to_owned()` in a few error messages related to splicing in a Lightning network implementation. There is no functional change and no security impact.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff changes six occurrences in lightning/src/ln/channel.rs where format!("literal string") was used to create a String for ChannelError variants. These are replaced with "literal string".to_owned(), which is equivalent but avoids an unnecessary macro invocation. The behavior, error variants, and returned messages are identical. No logic, state handling, or security boundary changes.
Changed components
lightning/src/ln/channel.rsInspect captured patch +11 / −11
diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs
index 5e8545c..326ebf6 100644
--- a/lightning/src/ln/channel.rs
+++ b/lightning/src/ln/channel.rs
@@ -11487,9 +11487,9 @@ where
// MUST send a warning and close the connection or send an error
// and fail the channel.
if !self.context.is_live() {
- return Err(ChannelError::WarnAndDisconnect(format!(
- "Splicing requested on a channel that is not live"
- )));
+ return Err(ChannelError::WarnAndDisconnect(
+ "Splicing requested on a channel that is not live".to_owned(),
+ ));
}
// TODO(splicing): Once splice acceptor can contribute, check that inputs are sufficient,
@@ -11737,20 +11737,20 @@ where
let funding_negotiation_context = match &self
.pending_splice
.as_ref()
- .ok_or(ChannelError::Ignore(format!("Channel is not in pending splice")))?
+ .ok_or(ChannelError::Ignore("Channel is not in pending splice".to_owned()))?
.funding_negotiation
{
Some(FundingNegotiation::AwaitingAck(context)) => context,
Some(FundingNegotiation::ConstructingTransaction(_, _))
| Some(FundingNegotiation::AwaitingSignatures(_)) => {
- return Err(ChannelError::WarnAndDisconnect(format!(
- "Got unexpected splice_ack; splice negotiation already in progress"
- )));
+ return Err(ChannelError::WarnAndDisconnect(
+ "Got unexpected splice_ack; splice negotiation already in progress".to_owned(),
+ ));
},
None => {
- return Err(ChannelError::Ignore(format!(
- "Got unexpected splice_ack; no splice negotiation in progress"
- )));
+ return Err(ChannelError::Ignore(
+ "Got unexpected splice_ack; no splice negotiation in progress".to_owned(),
+ ));
},
};
@@ -11847,7 +11847,7 @@ where
let pending_splice = match self.pending_splice.as_mut() {
Some(pending_splice) => pending_splice,
None => {
- return Err(ChannelError::Ignore(format!("Channel is not in pending splice")));
+ return Err(ChannelError::Ignore("Channel is not in pending splice".to_owned()));
},
};
Why this scored 15/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.