Inline promote_splice_funding macro
What changed, and why it matters
This commit simply moves the contents of a small helper macro directly into the one place it was used. There is no change to program logic, no bug fix, and no security improvement or regression visible in the diff.
No security action needed; treat as a routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The promote_splice_funding! macro is removed and its body is inlined at the single call site in Channel::funding_spliced. The sequence of operations—recording the previous SCID, swapping self.funding with the selected splice candidate, draining remaining negotiated candidates, clearing the signing session and pending splice state, and resetting announcement sigs—is identical before and after. The only differences are syntactic: the macro parameters become direct self/pending_splice/funding references, and the post-swap cleanup statements are moved outside the local discarded_funding block.
Changed components
lightning/src/ln/channel.rsInspect captured patch +31 / −39
diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs
index 0e38eec..312d1c8 100644
--- a/lightning/src/ln/channel.rs
+++ b/lightning/src/ln/channel.rs
@@ -6660,42 +6660,6 @@ where
quiescent_action: Option<QuiescentAction>,
}
-macro_rules! promote_splice_funding {
- ($self: expr, $pending_splice: expr, $funding: expr) => {{
- let prev_funding_txid = $self.funding.get_funding_txid();
- if let Some(scid) = $self.funding.short_channel_id {
- $self.context.historical_scids.push(scid);
- }
-
- core::mem::swap(&mut $self.funding, $funding);
-
- // The swap above places the previous `FundingScope` into `pending_funding`.
- let discarded_funding = $pending_splice
- .negotiated_candidates
- .drain(..)
- .filter(|funding| funding.get_funding_txid() != prev_funding_txid)
- .map(|mut funding| {
- funding
- .funding_transaction
- .take()
- .map(|tx| FundingInfo::Tx { transaction: tx })
- .unwrap_or_else(|| FundingInfo::OutPoint {
- outpoint: funding
- .get_funding_txo()
- .expect("Negotiated splices must have a known funding outpoint"),
- })
- })
- .collect::<Vec<_>>();
-
- $self.interactive_tx_signing_session = None;
- $self.pending_splice = None;
- $self.context.announcement_sigs = None;
- $self.context.announcement_sigs_state = AnnouncementSigsState::NotSent;
-
- discarded_funding
- }};
-}
-
#[cfg(any(test, fuzzing))]
#[derive(Clone, Copy, Default)]
struct PredictedNextFee {
@@ -10718,16 +10682,44 @@ where
);
let discarded_funding = {
- // Scope `funding` since it is swapped within `promote_splice_funding` and we don't want
- // to unintentionally use it.
+ // Scope `funding` to avoid unintentionally using it later since it is swapped below.
let funding = pending_splice
.negotiated_candidates
.iter_mut()
.find(|funding| funding.get_funding_txid() == Some(splice_txid))
.unwrap();
- promote_splice_funding!(self, pending_splice, funding)
+ let prev_funding_txid = self.funding.get_funding_txid();
+
+ if let Some(scid) = self.funding.short_channel_id {
+ self.context.historical_scids.push(scid);
+ }
+
+ core::mem::swap(&mut self.funding, funding);
+
+ // The swap above places the previous `FundingScope` into `pending_funding`.
+ pending_splice
+ .negotiated_candidates
+ .drain(..)
+ .filter(|funding| funding.get_funding_txid() != prev_funding_txid)
+ .map(|mut funding| {
+ funding
+ .funding_transaction
+ .take()
+ .map(|tx| FundingInfo::Tx { transaction: tx })
+ .unwrap_or_else(|| FundingInfo::OutPoint {
+ outpoint: funding
+ .get_funding_txo()
+ .expect("Negotiated splices must have a known funding outpoint"),
+ })
+ })
+ .collect::<Vec<_>>()
};
+ self.interactive_tx_signing_session = None;
+ self.pending_splice = None;
+ self.context.announcement_sigs = None;
+ self.context.announcement_sigs_state = AnnouncementSigsState::NotSent;
+
let funding_txo = self
.funding
.get_funding_txo()
Why this scored 12/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.