Skip to content

Commit c8d5251

Browse files
committed
Move PendingSpliceInfoPre to Channel (from ChannelContext)
1 parent db21aad commit c8d5251

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

lightning/src/ln/channel.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,8 @@ impl<SP: Deref> Channel<SP> where
15151515
interactive_tx_signing_session: chan.interactive_tx_signing_session,
15161516
holder_commitment_point,
15171517
is_v2_established: true,
1518+
#[cfg(splicing)]
1519+
pending_splice_pre: None,
15181520
};
15191521
let res = funded_channel.commitment_signed_initial_v2(msg, best_block, signer_provider, logger)
15201522
.map(|monitor| (Some(monitor), None))
@@ -1775,10 +1777,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
17751777

17761778
secp_ctx: Secp256k1<secp256k1::All>,
17771779

1778-
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
1779-
#[cfg(splicing)]
1780-
pending_splice_pre: Option<PendingSpliceInfoPre>,
1781-
17821780
latest_monitor_update_id: u64,
17831781

17841782
holder_signer: ChannelSignerType<SP>,
@@ -2843,9 +2841,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
28432841
next_funding_txid: None,
28442842

28452843
is_holder_quiescence_initiator: None,
2846-
2847-
#[cfg(splicing)]
2848-
pending_splice_pre: None,
28492844
};
28502845

28512846
Ok((funding, channel_context))
@@ -3078,9 +3073,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
30783073
next_funding_txid: None,
30793074

30803075
is_holder_quiescence_initiator: None,
3081-
3082-
#[cfg(splicing)]
3083-
pending_splice_pre: None,
30843076
};
30853077

30863078
Ok((funding, channel_context))
@@ -4892,6 +4884,9 @@ pub(super) struct FundedChannel<SP: Deref> where SP::Target: SignerProvider {
48924884
/// Indicates whether this funded channel had been established with V2 channel
48934885
/// establishment.
48944886
is_v2_established: bool,
4887+
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
4888+
#[cfg(splicing)]
4889+
pending_splice_pre: Option<PendingSpliceInfoPre>,
48954890
}
48964891

48974892
#[cfg(any(test, fuzzing))]
@@ -8526,7 +8521,7 @@ impl<SP: Deref> FundedChannel<SP> where
85268521
) -> Result<msgs::SpliceInit, ChannelError> {
85278522
// Check if a splice has been initiated already.
85288523
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
8529-
if let Some(splice_info) = &self.context.pending_splice_pre {
8524+
if let Some(splice_info) = &self.pending_splice_pre {
85308525
return Err(ChannelError::Warn(format!(
85318526
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution
85328527
)));
@@ -8555,7 +8550,7 @@ impl<SP: Deref> FundedChannel<SP> where
85558550
// Note: post-splice channel value is not yet known at this point, counterpary contribution is not known
85568551
// (Cannot test for miminum required post-splice channel value)
85578552

8558-
self.context.pending_splice_pre = Some(PendingSpliceInfoPre {
8553+
self.pending_splice_pre = Some(PendingSpliceInfoPre {
85598554
our_funding_contribution: our_funding_contribution_satoshis,
85608555
});
85618556

@@ -8572,7 +8567,7 @@ impl<SP: Deref> FundedChannel<SP> where
85728567

85738568
// Check if a splice has been initiated already.
85748569
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
8575-
if let Some(splice_info) = &self.context.pending_splice_pre {
8570+
if let Some(splice_info) = &self.pending_splice_pre {
85768571
return Err(ChannelError::Warn(format!(
85778572
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution,
85788573
)));
@@ -8621,7 +8616,7 @@ impl<SP: Deref> FundedChannel<SP> where
86218616
let their_funding_contribution_satoshis = msg.funding_contribution_satoshis;
86228617

86238618
// check if splice is pending
8624-
let pending_splice = if let Some(pending_splice) = &self.context.pending_splice_pre {
8619+
let pending_splice = if let Some(pending_splice) = &self.pending_splice_pre {
86258620
pending_splice
86268621
} else {
86278622
return Err(ChannelError::Warn(format!("Channel is not in pending splice")));
@@ -9557,6 +9552,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
95579552
interactive_tx_signing_session: None,
95589553
is_v2_established: false,
95599554
holder_commitment_point,
9555+
#[cfg(splicing)]
9556+
pending_splice_pre: None,
95609557
};
95619558

95629559
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
@@ -9824,6 +9821,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
98249821
interactive_tx_signing_session: None,
98259822
is_v2_established: false,
98269823
holder_commitment_point,
9824+
#[cfg(splicing)]
9825+
pending_splice_pre: None,
98279826
};
98289827
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
98299828
|| channel.context.signer_pending_channel_ready;
@@ -11182,13 +11181,12 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
1118211181
next_funding_txid: None,
1118311182

1118411183
is_holder_quiescence_initiator: None,
11185-
11186-
#[cfg(splicing)]
11187-
pending_splice_pre: None,
1118811184
},
1118911185
interactive_tx_signing_session: None,
1119011186
is_v2_established,
1119111187
holder_commitment_point,
11188+
#[cfg(splicing)]
11189+
pending_splice_pre: None,
1119211190
})
1119311191
}
1119411192
}

0 commit comments

Comments
 (0)