Skip to content

Commit df7f53a

Browse files
committed
Move PendingSpliceInfoPre to Channel (from ChannelContext)
1 parent 4b36976 commit df7f53a

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
@@ -1241,10 +1241,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
12411241
secp_ctx: Secp256k1<secp256k1::All>,
12421242
channel_value_satoshis: u64,
12431243

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

12501246
holder_signer: ChannelSignerType<SP>,
@@ -2355,9 +2351,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
23552351
is_manual_broadcast: false,
23562352

23572353
next_funding_txid: None,
2358-
2359-
#[cfg(splicing)]
2360-
pending_splice_pre: None,
23612354
};
23622355

23632356
Ok(channel_context)
@@ -2591,9 +2584,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
25912584
local_initiated_shutdown: None,
25922585
is_manual_broadcast: false,
25932586
next_funding_txid: None,
2594-
2595-
#[cfg(splicing)]
2596-
pending_splice_pre: None,
25972587
})
25982588
}
25992589

@@ -4432,6 +4422,9 @@ pub(super) struct DualFundingChannelContext {
44324422
pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
44334423
pub context: ChannelContext<SP>,
44344424
pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
4425+
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
4426+
#[cfg(splicing)]
4427+
pending_splice_pre: Option<PendingSpliceInfoPre>,
44354428
}
44364429

44374430
#[cfg(any(test, fuzzing))]
@@ -8040,7 +8033,7 @@ impl<SP: Deref> Channel<SP> where
80408033
) -> Result<msgs::SpliceInit, ChannelError> {
80418034
// Check if a splice has been initiated already.
80428035
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
8043-
if let Some(splice_info) = &self.context.pending_splice_pre {
8036+
if let Some(splice_info) = &self.pending_splice_pre {
80448037
return Err(ChannelError::Warn(format!(
80458038
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution
80468039
)));
@@ -8069,7 +8062,7 @@ impl<SP: Deref> Channel<SP> where
80698062
// Note: post-splice channel value is not yet known at this point, counterpary contribution is not known
80708063
// (Cannot test for miminum required post-splice channel value)
80718064

8072-
self.context.pending_splice_pre = Some(PendingSpliceInfoPre {
8065+
self.pending_splice_pre = Some(PendingSpliceInfoPre {
80738066
our_funding_contribution: our_funding_contribution_satoshis,
80748067
});
80758068

@@ -8086,7 +8079,7 @@ impl<SP: Deref> Channel<SP> where
80868079

80878080
// Check if a splice has been initiated already.
80888081
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
8089-
if let Some(splice_info) = &self.context.pending_splice_pre {
8082+
if let Some(splice_info) = &self.pending_splice_pre {
80908083
return Err(ChannelError::Warn(format!(
80918084
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution,
80928085
)));
@@ -8135,7 +8128,7 @@ impl<SP: Deref> Channel<SP> where
81358128
let their_funding_contribution_satoshis = msg.funding_contribution_satoshis;
81368129

81378130
// check if splice is pending
8138-
let pending_splice = if let Some(pending_splice) = &self.context.pending_splice_pre {
8131+
let pending_splice = if let Some(pending_splice) = &self.pending_splice_pre {
81398132
pending_splice
81408133
} else {
81418134
return Err(ChannelError::Warn(format!("Channel is not in pending splice")));
@@ -8827,6 +8820,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
88278820
let mut channel = Channel {
88288821
context: self.context,
88298822
interactive_tx_signing_session: None,
8823+
#[cfg(splicing)]
8824+
pending_splice_pre: None,
88308825
};
88318826

88328827
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -9052,6 +9047,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
90529047
let mut channel = Channel {
90539048
context: self.context,
90549049
interactive_tx_signing_session: None,
9050+
#[cfg(splicing)]
9051+
pending_splice_pre: None,
90559052
};
90569053
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
90579054
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
@@ -9198,6 +9195,8 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
91989195
let channel = Channel {
91999196
context: self.context,
92009197
interactive_tx_signing_session: Some(signing_session),
9198+
#[cfg(splicing)]
9199+
pending_splice_pre: None,
92019200
};
92029201

92039202
Ok(channel)
@@ -9393,6 +9392,8 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
93939392
let channel = Channel {
93949393
context: self.context,
93959394
interactive_tx_signing_session: Some(signing_session),
9395+
#[cfg(splicing)]
9396+
pending_splice_pre: None,
93969397
};
93979398

93989399
Ok(channel)
@@ -10469,11 +10470,10 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1046910470
// during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
1047010471
// to the txid of that interactive transaction, else we MUST NOT set it.
1047110472
next_funding_txid: None,
10472-
10473-
#[cfg(splicing)]
10474-
pending_splice_pre: None,
1047510473
},
1047610474
interactive_tx_signing_session: None,
10475+
#[cfg(splicing)]
10476+
pending_splice_pre: None,
1047710477
})
1047810478
}
1047910479
}

0 commit comments

Comments
 (0)