Skip to content

Commit 6f8dbbd

Browse files
committed
fix Remove awaiting_splice_ack flag
Instead, rely on the presense of the funding_scope and interactive_tx_constructor optional fields.
1 parent 9d2802e commit 6f8dbbd

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

lightning/src/ln/channel.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,9 +1961,6 @@ impl FundingScope {
19611961
struct PendingSplice {
19621962
/// Intended contributions to the splice from our end
19631963
pub our_funding_contribution: i64,
1964-
/// Set when splice_ack has been processed (on the initiator side),
1965-
/// used to prevent processing of multiple splice_ack's.
1966-
awaiting_splice_ack: bool,
19671964
funding_scope: Option<FundingScope>,
19681965
funding_negotiation_context: FundingNegotiationContext,
19691966
/// The current interactive transaction construction session under negotiation.
@@ -9063,7 +9060,6 @@ impl<SP: Deref> FundedChannel<SP> where
90639060
};
90649061
self.pending_splice = Some(PendingSplice {
90659062
our_funding_contribution: our_funding_contribution_satoshis,
9066-
awaiting_splice_ack: true, // we await splice_ack
90679063
funding_scope: None,
90689064
funding_negotiation_context,
90699065
interactive_tx_constructor: None,
@@ -9099,6 +9095,8 @@ impl<SP: Deref> FundedChannel<SP> where
90999095
// TODO(splicing): Currently not possible to contribute on the splicing-acceptor side
91009096
let our_funding_contribution_satoshis = 0i64;
91019097

9098+
// TODO(splicing): Add check that we are the quiescence acceptor
9099+
91029100
// Check if a splice has been initiated already.
91039101
if let Some(pending_splice) = &self.pending_splice {
91049102
return Err(ChannelError::Warn(format!(
@@ -9224,7 +9222,6 @@ impl<SP: Deref> FundedChannel<SP> where
92249222

92259223
self.pending_splice = Some(PendingSplice {
92269224
our_funding_contribution,
9227-
awaiting_splice_ack: false, // we don't need any additional message for the handshake
92289225
funding_scope: Some(funding_scope),
92299226
funding_negotiation_context,
92309227
interactive_tx_constructor: None,
@@ -9283,8 +9280,10 @@ impl<SP: Deref> FundedChannel<SP> where
92839280
return Err(ChannelError::Warn(format!("Channel is not in pending splice")));
92849281
};
92859282

9286-
if !pending_splice.awaiting_splice_ack {
9287-
return Err(ChannelError::Warn(format!("Received unexpected splice_ack")));
9283+
// TODO(splicing): Add check that we are the splice (quiescence) initiator
9284+
9285+
if pending_splice.funding_scope.is_some() || pending_splice.interactive_tx_constructor.is_some() {
9286+
return Err(ChannelError::Warn(format!("Got unexpected splice_ack, splice already negotiating")));
92889287
}
92899288

92909289
let our_funding_contribution = pending_splice.our_funding_contribution;
@@ -9313,14 +9312,13 @@ impl<SP: Deref> FundedChannel<SP> where
93139312
// We need the current funding tx as an extra input
93149313
let prev_funding_input = Self::get_input_of_previous_funding(pre_funding_transaction, pre_funding_txo)?;
93159314
let pending_splice_mut = self.pending_splice.as_mut().unwrap(); // existence checked above
9315+
debug_assert!(pending_splice_mut.funding_scope.is_none());
93169316
pending_splice_mut.funding_scope = Some(funding_scope);
93179317
// update funding values
93189318
pending_splice_mut.funding_negotiation_context.our_funding_satoshis = our_funding_satoshis;
93199319
pending_splice_mut.funding_negotiation_context.their_funding_satoshis = Some(their_funding_satoshis);
93209320
pending_splice_mut.interactive_tx_constructor = None;
93219321
pending_splice_mut.interactive_tx_signing_session = None;
9322-
debug_assert!(pending_splice_mut.awaiting_splice_ack);
9323-
pending_splice_mut.awaiting_splice_ack = false;
93249322

93259323
log_info!(logger, "Splicing process started after splice_ack, new channel value {}, old {}, outgoing {}, channel_id {}",
93269324
post_channel_value, pre_channel_value, true, self.context.channel_id);

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8672,10 +8672,10 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
86728672
&self, counterparty_node_id: PublicKey, msg: &msgs::TxAddInput,
86738673
) -> Result<(), MsgHandleErrInternal> {
86748674
self.internal_tx_msg(&counterparty_node_id, msg.channel_id, |channel: &mut Channel<SP>| {
8675-
Ok(channel.as_negotiating_channel()?
8675+
Ok(channel
8676+
.as_negotiating_channel()?
86768677
.tx_add_input(msg)
8677-
.into_msg_send_event(counterparty_node_id)
8678-
)
8678+
.into_msg_send_event(counterparty_node_id))
86798679
})
86808680
}
86818681

0 commit comments

Comments
 (0)