Skip to content

Commit 07d53ae

Browse files
committed
Move PendingSpliceInfoPre to Channel (from ChannelContext)
1 parent 411198f commit 07d53ae

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lightning/src/ln/channel.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,10 +1240,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
12401240
secp_ctx: Secp256k1<secp256k1::All>,
12411241
channel_value_satoshis: u64,
12421242

1243-
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
1244-
#[cfg(splicing)]
1245-
pending_splice_pre: Option<PendingSpliceInfoPre>,
1246-
12471243
latest_monitor_update_id: u64,
12481244

12491245
holder_signer: ChannelSignerType<SP>,
@@ -2234,9 +2230,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
22342230
is_manual_broadcast: false,
22352231

22362232
next_funding_txid: None,
2237-
2238-
#[cfg(splicing)]
2239-
pending_splice_pre: None,
22402233
};
22412234

22422235
Ok(channel_context)
@@ -2470,9 +2463,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
24702463
local_initiated_shutdown: None,
24712464
is_manual_broadcast: false,
24722465
next_funding_txid: None,
2473-
2474-
#[cfg(splicing)]
2475-
pending_splice_pre: None,
24762466
})
24772467
}
24782468

@@ -4306,6 +4296,9 @@ pub(super) struct DualFundingChannelContext {
43064296
pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
43074297
pub context: ChannelContext<SP>,
43084298
pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
4299+
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
4300+
#[cfg(splicing)]
4301+
pending_splice_pre: Option<PendingSpliceInfoPre>,
43094302
}
43104303

43114304
#[cfg(any(test, fuzzing))]
@@ -7914,7 +7907,7 @@ impl<SP: Deref> Channel<SP> where
79147907
) -> Result<msgs::SpliceInit, ChannelError> {
79157908
// Check if a splice has been initiated already.
79167909
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
7917-
if let Some(splice_info) = &self.context.pending_splice_pre {
7910+
if let Some(splice_info) = &self.pending_splice_pre {
79187911
return Err(ChannelError::Warn(format!(
79197912
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution
79207913
)));
@@ -7943,7 +7936,7 @@ impl<SP: Deref> Channel<SP> where
79437936
// Note: post-splice channel value is not yet known at this point, counterpary contribution is not known
79447937
// (Cannot test for miminum required post-splice channel value)
79457938

7946-
self.context.pending_splice_pre = Some(PendingSpliceInfoPre {
7939+
self.pending_splice_pre = Some(PendingSpliceInfoPre {
79477940
our_funding_contribution: our_funding_contribution_satoshis,
79487941
});
79497942

@@ -7960,7 +7953,7 @@ impl<SP: Deref> Channel<SP> where
79607953

79617954
// Check if a splice has been initiated already.
79627955
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
7963-
if let Some(splice_info) = &self.context.pending_splice_pre {
7956+
if let Some(splice_info) = &self.pending_splice_pre {
79647957
return Err(ChannelError::Warn(format!(
79657958
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution,
79667959
)));
@@ -8009,7 +8002,7 @@ impl<SP: Deref> Channel<SP> where
80098002
let their_funding_contribution_satoshis = msg.funding_contribution_satoshis;
80108003

80118004
// check if splice is pending
8012-
let pending_splice = if let Some(pending_splice) = &self.context.pending_splice_pre {
8005+
let pending_splice = if let Some(pending_splice) = &self.pending_splice_pre {
80138006
pending_splice
80148007
} else {
80158008
return Err(ChannelError::Warn(format!("Channel is not in pending splice")));
@@ -8701,6 +8694,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
87018694
let mut channel = Channel {
87028695
context: self.context,
87038696
interactive_tx_signing_session: None,
8697+
#[cfg(splicing)]
8698+
pending_splice_pre: None,
87048699
};
87058700

87068701
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -8926,6 +8921,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
89268921
let mut channel = Channel {
89278922
context: self.context,
89288923
interactive_tx_signing_session: None,
8924+
#[cfg(splicing)]
8925+
pending_splice_pre: None,
89298926
};
89308927
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
89318928
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
@@ -9071,6 +9068,8 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
90719068
let channel = Channel {
90729069
context: self.context,
90739070
interactive_tx_signing_session: Some(signing_session),
9071+
#[cfg(splicing)]
9072+
pending_splice_pre: None,
90749073
};
90759074

90769075
Ok(channel)
@@ -9265,6 +9264,8 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
92659264
let channel = Channel {
92669265
context: self.context,
92679266
interactive_tx_signing_session: Some(signing_session),
9267+
#[cfg(splicing)]
9268+
pending_splice_pre: None,
92689269
};
92699270

92709271
Ok(channel)
@@ -10341,11 +10342,10 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1034110342
// during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
1034210343
// to the txid of that interactive transaction, else we MUST NOT set it.
1034310344
next_funding_txid: None,
10344-
10345-
#[cfg(splicing)]
10346-
pending_splice_pre: None,
1034710345
},
1034810346
interactive_tx_signing_session: None,
10347+
#[cfg(splicing)]
10348+
pending_splice_pre: None,
1034910349
})
1035010350
}
1035110351
}

0 commit comments

Comments
 (0)