Skip to content

Commit

Permalink
Handle sending channel_ready when commitment point is unblocked
Browse files Browse the repository at this point in the history
  • Loading branch information
alecchendev committed Sep 16, 2024
1 parent 25c3185 commit de37adf
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5472,8 +5472,11 @@ impl<SP: Deref> Channel<SP> where
let funding_signed = if self.context.signer_pending_funding && !self.context.is_outbound() {
self.context.get_funding_signed_msg(logger).1
} else { None };
let channel_ready = if funding_signed.is_some() {
self.check_get_channel_ready(0, logger)
// Provide a `channel_ready` message if we need to, but only if we're _not_ still pending
// funding.
let channel_ready = if self.context.signer_pending_channel_ready && !self.context.signer_pending_funding {
log_trace!(logger, "Attempting to generate pending channel_ready...");
self.get_channel_ready(logger)
} else { None };

let mut commitment_update = if self.context.signer_pending_commitment_update {
Expand Down Expand Up @@ -6665,14 +6668,6 @@ impl<SP: Deref> Channel<SP> where
return None;
}

// If we're still pending the signature on a funding transaction, then we're not ready to send a
// channel_ready yet.
if self.context.signer_pending_funding {
// TODO: set signer_pending_channel_ready
log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
return None;
}

// Note that we don't include ChannelState::WaitingForBatch as we don't want to send
// channel_ready until the entire batch is ready.
let need_commitment_update = if matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(f) if f.clone().clear(FundedStateFlags::ALL.into()).is_empty()) {
Expand Down Expand Up @@ -6718,6 +6713,17 @@ impl<SP: Deref> Channel<SP> where
return None;
}

// If we're still pending the signature on a funding transaction, then we're not ready to send a
// channel_ready yet.
if self.context.signer_pending_funding {
log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
// We make sure to set the channel ready flag here so that we try to
// generate a channel ready for 0conf channels once our signer unblocked
// for funding.
self.context.signer_pending_channel_ready = true;
return None;
}

self.get_channel_ready(logger)
}

Expand Down

0 comments on commit de37adf

Please sign in to comment.