Skip to content

Commit 3937a6a

Browse files
committed
Move PendingSpliceInfoPre to Channel (from ChannelContext)
1 parent b1ba24b commit 3937a6a

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lightning/src/ln/channel.rs

+17-17
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

@@ -4298,6 +4288,9 @@ pub(super) struct DualFundingChannelContext {
42984288
pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
42994289
pub context: ChannelContext<SP>,
43004290
pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
4291+
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
4292+
#[cfg(splicing)]
4293+
pending_splice_pre: Option<PendingSpliceInfoPre>,
43014294
}
43024295

43034296
#[cfg(any(test, fuzzing))]
@@ -7906,7 +7899,7 @@ impl<SP: Deref> Channel<SP> where
79067899
) -> Result<msgs::SpliceInit, ChannelError> {
79077900
// Check if a splice has been initiated already.
79087901
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
7909-
if let Some(splice_info) = &self.context.pending_splice_pre {
7902+
if let Some(splice_info) = &self.pending_splice_pre {
79107903
return Err(ChannelError::Warn(format!(
79117904
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution
79127905
)));
@@ -7935,7 +7928,7 @@ impl<SP: Deref> Channel<SP> where
79357928
// Note: post-splice channel value is not yet known at this point, counterpary contribution is not known
79367929
// (Cannot test for miminum required post-splice channel value)
79377930

7938-
self.context.pending_splice_pre = Some(PendingSpliceInfoPre {
7931+
self.pending_splice_pre = Some(PendingSpliceInfoPre {
79397932
our_funding_contribution: our_funding_contribution_satoshis,
79407933
});
79417934

@@ -7952,7 +7945,7 @@ impl<SP: Deref> Channel<SP> where
79527945

79537946
// Check if a splice has been initiated already.
79547947
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
7955-
if let Some(splice_info) = &self.context.pending_splice_pre {
7948+
if let Some(splice_info) = &self.pending_splice_pre {
79567949
return Err(ChannelError::Warn(format!(
79577950
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution,
79587951
)));
@@ -8001,7 +7994,7 @@ impl<SP: Deref> Channel<SP> where
80017994
let their_funding_contribution_satoshis = msg.funding_contribution_satoshis;
80027995

80037996
// check if splice is pending
8004-
let pending_splice = if let Some(pending_splice) = &self.context.pending_splice_pre {
7997+
let pending_splice = if let Some(pending_splice) = &self.pending_splice_pre {
80057998
pending_splice
80067999
} else {
80078000
return Err(ChannelError::Warn(format!("Channel is not in pending splice")));
@@ -8693,6 +8686,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
86938686
let mut channel = Channel {
86948687
context: self.context,
86958688
interactive_tx_signing_session: None,
8689+
#[cfg(splicing)]
8690+
pending_splice_pre: None,
86968691
};
86978692

86988693
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -8918,6 +8913,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
89188913
let mut channel = Channel {
89198914
context: self.context,
89208915
interactive_tx_signing_session: None,
8916+
#[cfg(splicing)]
8917+
pending_splice_pre: None,
89218918
};
89228919
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
89238920
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
@@ -9063,6 +9060,8 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
90639060
let channel = Channel {
90649061
context: self.context,
90659062
interactive_tx_signing_session: Some(signing_session),
9063+
#[cfg(splicing)]
9064+
pending_splice_pre: None,
90669065
};
90679066

90689067
Ok(channel)
@@ -9257,6 +9256,8 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
92579256
let channel = Channel {
92589257
context: self.context,
92599258
interactive_tx_signing_session: Some(signing_session),
9259+
#[cfg(splicing)]
9260+
pending_splice_pre: None,
92609261
};
92619262

92629263
Ok(channel)
@@ -10333,11 +10334,10 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1033310334
// during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
1033410335
// to the txid of that interactive transaction, else we MUST NOT set it.
1033510336
next_funding_txid,
10336-
10337-
#[cfg(splicing)]
10338-
pending_splice_pre: None,
1033910337
},
1034010338
interactive_tx_signing_session: None,
10339+
#[cfg(splicing)]
10340+
pending_splice_pre: None,
1034110341
})
1034210342
}
1034310343
}

0 commit comments

Comments
 (0)