Skip to content

Commit 4ba6452

Browse files
committed
Inline promote_splice_funding macro
1 parent d0780f7 commit 4ba6452

File tree

1 file changed

+31
-39
lines changed

1 file changed

+31
-39
lines changed

lightning/src/ln/channel.rs

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6660,42 +6660,6 @@ where
66606660
quiescent_action: Option<QuiescentAction>,
66616661
}
66626662

6663-
macro_rules! promote_splice_funding {
6664-
($self: expr, $pending_splice: expr, $funding: expr) => {{
6665-
let prev_funding_txid = $self.funding.get_funding_txid();
6666-
if let Some(scid) = $self.funding.short_channel_id {
6667-
$self.context.historical_scids.push(scid);
6668-
}
6669-
6670-
core::mem::swap(&mut $self.funding, $funding);
6671-
6672-
// The swap above places the previous `FundingScope` into `pending_funding`.
6673-
let discarded_funding = $pending_splice
6674-
.negotiated_candidates
6675-
.drain(..)
6676-
.filter(|funding| funding.get_funding_txid() != prev_funding_txid)
6677-
.map(|mut funding| {
6678-
funding
6679-
.funding_transaction
6680-
.take()
6681-
.map(|tx| FundingInfo::Tx { transaction: tx })
6682-
.unwrap_or_else(|| FundingInfo::OutPoint {
6683-
outpoint: funding
6684-
.get_funding_txo()
6685-
.expect("Negotiated splices must have a known funding outpoint"),
6686-
})
6687-
})
6688-
.collect::<Vec<_>>();
6689-
6690-
$self.interactive_tx_signing_session = None;
6691-
$self.pending_splice = None;
6692-
$self.context.announcement_sigs = None;
6693-
$self.context.announcement_sigs_state = AnnouncementSigsState::NotSent;
6694-
6695-
discarded_funding
6696-
}};
6697-
}
6698-
66996663
#[cfg(any(test, fuzzing))]
67006664
#[derive(Clone, Copy, Default)]
67016665
struct PredictedNextFee {
@@ -10718,16 +10682,44 @@ where
1071810682
);
1071910683

1072010684
let discarded_funding = {
10721-
// Scope `funding` since it is swapped within `promote_splice_funding` and we don't want
10722-
// to unintentionally use it.
10685+
// Scope `funding` to avoid unintentionally using it later since it is swapped below.
1072310686
let funding = pending_splice
1072410687
.negotiated_candidates
1072510688
.iter_mut()
1072610689
.find(|funding| funding.get_funding_txid() == Some(splice_txid))
1072710690
.unwrap();
10728-
promote_splice_funding!(self, pending_splice, funding)
10691+
let prev_funding_txid = self.funding.get_funding_txid();
10692+
10693+
if let Some(scid) = self.funding.short_channel_id {
10694+
self.context.historical_scids.push(scid);
10695+
}
10696+
10697+
core::mem::swap(&mut self.funding, funding);
10698+
10699+
// The swap above places the previous `FundingScope` into `pending_funding`.
10700+
pending_splice
10701+
.negotiated_candidates
10702+
.drain(..)
10703+
.filter(|funding| funding.get_funding_txid() != prev_funding_txid)
10704+
.map(|mut funding| {
10705+
funding
10706+
.funding_transaction
10707+
.take()
10708+
.map(|tx| FundingInfo::Tx { transaction: tx })
10709+
.unwrap_or_else(|| FundingInfo::OutPoint {
10710+
outpoint: funding
10711+
.get_funding_txo()
10712+
.expect("Negotiated splices must have a known funding outpoint"),
10713+
})
10714+
})
10715+
.collect::<Vec<_>>()
1072910716
};
1073010717

10718+
self.interactive_tx_signing_session = None;
10719+
self.pending_splice = None;
10720+
self.context.announcement_sigs = None;
10721+
self.context.announcement_sigs_state = AnnouncementSigsState::NotSent;
10722+
1073110723
let funding_txo = self
1073210724
.funding
1073310725
.get_funding_txo()

0 commit comments

Comments
 (0)