Skip to content

Commit 4791b39

Browse files
committed
Move PendingSpliceInfoPre to Channel (from ChannelContext)
1 parent 18b95d9 commit 4791b39

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

lightning/src/ln/channel.rs

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

1488-
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
1489-
#[cfg(splicing)]
1490-
pending_splice_pre: Option<PendingSpliceInfoPre>,
1491-
14921488
latest_monitor_update_id: u64,
14931489

14941490
holder_signer: ChannelSignerType<SP>,
@@ -2543,9 +2539,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
25432539
is_manual_broadcast: false,
25442540

25452541
next_funding_txid: None,
2546-
2547-
#[cfg(splicing)]
2548-
pending_splice_pre: None,
25492542
};
25502543

25512544
Ok(channel_context)
@@ -2776,9 +2769,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
27762769
local_initiated_shutdown: None,
27772770
is_manual_broadcast: false,
27782771
next_funding_txid: None,
2779-
2780-
#[cfg(splicing)]
2781-
pending_splice_pre: None,
27822772
})
27832773
}
27842774

@@ -4610,6 +4600,9 @@ pub(super) struct FundedChannel<SP: Deref> where SP::Target: SignerProvider {
46104600
pub context: ChannelContext<SP>,
46114601
pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
46124602
holder_commitment_point: HolderCommitmentPoint,
4603+
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
4604+
#[cfg(splicing)]
4605+
pending_splice_pre: Option<PendingSpliceInfoPre>,
46134606
}
46144607

46154608
#[cfg(any(test, fuzzing))]
@@ -8231,7 +8224,7 @@ impl<SP: Deref> FundedChannel<SP> where
82318224
) -> Result<msgs::SpliceInit, ChannelError> {
82328225
// Check if a splice has been initiated already.
82338226
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
8234-
if let Some(splice_info) = &self.context.pending_splice_pre {
8227+
if let Some(splice_info) = &self.pending_splice_pre {
82358228
return Err(ChannelError::Warn(format!(
82368229
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution
82378230
)));
@@ -8260,7 +8253,7 @@ impl<SP: Deref> FundedChannel<SP> where
82608253
// Note: post-splice channel value is not yet known at this point, counterpary contribution is not known
82618254
// (Cannot test for miminum required post-splice channel value)
82628255

8263-
self.context.pending_splice_pre = Some(PendingSpliceInfoPre {
8256+
self.pending_splice_pre = Some(PendingSpliceInfoPre {
82648257
our_funding_contribution: our_funding_contribution_satoshis,
82658258
});
82668259

@@ -8277,7 +8270,7 @@ impl<SP: Deref> FundedChannel<SP> where
82778270

82788271
// Check if a splice has been initiated already.
82798272
// Note: this could be handled more nicely, and support multiple outstanding splice's, the incoming splice_ack matters anyways.
8280-
if let Some(splice_info) = &self.context.pending_splice_pre {
8273+
if let Some(splice_info) = &self.pending_splice_pre {
82818274
return Err(ChannelError::Warn(format!(
82828275
"Channel has already a splice pending, contribution {}", splice_info.our_funding_contribution,
82838276
)));
@@ -8326,7 +8319,7 @@ impl<SP: Deref> FundedChannel<SP> where
83268319
let their_funding_contribution_satoshis = msg.funding_contribution_satoshis;
83278320

83288321
// check if splice is pending
8329-
let pending_splice = if let Some(pending_splice) = &self.context.pending_splice_pre {
8322+
let pending_splice = if let Some(pending_splice) = &self.pending_splice_pre {
83308323
pending_splice
83318324
} else {
83328325
return Err(ChannelError::Warn(format!("Channel is not in pending splice")));
@@ -9036,6 +9029,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
90369029
context: self.context,
90379030
interactive_tx_signing_session: None,
90389031
holder_commitment_point,
9032+
#[cfg(splicing)]
9033+
pending_splice_pre: None,
90399034
};
90409035

90419036
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
@@ -9301,6 +9296,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
93019296
context: self.context,
93029297
interactive_tx_signing_session: None,
93039298
holder_commitment_point,
9299+
#[cfg(splicing)]
9300+
pending_splice_pre: None,
93049301
};
93059302
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
93069303
|| channel.context.signer_pending_channel_ready;
@@ -9664,6 +9661,8 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
96649661
context: self.context,
96659662
interactive_tx_signing_session: Some(signing_session),
96669663
holder_commitment_point,
9664+
#[cfg(splicing)]
9665+
pending_splice_pre: None,
96679666
};
96689667

96699668
Ok(channel)
@@ -10741,12 +10740,11 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1074110740
// during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
1074210741
// to the txid of that interactive transaction, else we MUST NOT set it.
1074310742
next_funding_txid: None,
10744-
10745-
#[cfg(splicing)]
10746-
pending_splice_pre: None,
1074710743
},
1074810744
interactive_tx_signing_session: None,
1074910745
holder_commitment_point,
10746+
#[cfg(splicing)]
10747+
pending_splice_pre: None,
1075010748
})
1075110749
}
1075210750
}

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4226,7 +4226,7 @@ where
42264226
// Look for the channel
42274227
match peer_state.channel_by_id.entry(*channel_id) {
42284228
hash_map::Entry::Occupied(mut chan_phase_entry) => {
4229-
if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
4229+
if let Some(chan) = chan_phase_entry.get_mut().as_funded_mut() {
42304230
let msg = match chan.splice_channel(our_funding_contribution_satoshis, funding_feerate_perkw, locktime) {
42314231
Ok(msg) => msg,
42324232
Err(err) => return Err(APIError::APIMisuseError {
@@ -9380,7 +9380,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
93809380
counterparty_node_id, msg.channel_id,
93819381
), msg.channel_id)),
93829382
hash_map::Entry::Occupied(mut chan_entry) => {
9383-
if let ChannelPhase::Funded(chan) = chan_entry.get_mut() {
9383+
if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
93849384
match chan.splice_init(msg) {
93859385
Ok(splice_ack_msg) => {
93869386
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceAck {
@@ -9425,7 +9425,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
94259425
counterparty_node_id
94269426
), msg.channel_id)),
94279427
hash_map::Entry::Occupied(mut chan) => {
9428-
if let ChannelPhase::Funded(chan) = chan.get_mut() {
9428+
if let Some(chan) = chan.get_mut().as_funded_mut() {
94299429
match chan.splice_ack(msg) {
94309430
Ok(_) => {}
94319431
Err(err) => {

0 commit comments

Comments
 (0)