Skip to content

Commit 1fcf4f1

Browse files
committed
Handle sending channel_ready when commitment point is unblocked
1 parent 239ed54 commit 1fcf4f1

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

lightning/src/ln/channel.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5461,8 +5461,15 @@ impl<SP: Deref> Channel<SP> where
54615461
let funding_signed = if self.context.signer_pending_funding && !self.context.is_outbound() {
54625462
self.context.get_funding_signed_msg(logger).1
54635463
} else { None };
5464-
let channel_ready = if funding_signed.is_some() {
5465-
self.check_get_channel_ready(0, logger)
5464+
if !self.context.holder_commitment_point.is_available() {
5465+
log_trace!(logger, "Attempting to update holder per-commitment point...");
5466+
self.context.holder_commitment_point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
5467+
}
5468+
// Provide a `channel_ready` message if we need to, but only if we're _not_ still pending
5469+
// funding.
5470+
let channel_ready = if self.context.signer_pending_channel_ready && !self.context.signer_pending_funding {
5471+
log_trace!(logger, "Attempting to generate pending channel_ready...");
5472+
self.get_channel_ready(logger)
54665473
} else { None };
54675474

54685475
let mut commitment_update = if self.context.signer_pending_commitment_update {
@@ -6606,14 +6613,6 @@ impl<SP: Deref> Channel<SP> where
66066613
return None;
66076614
}
66086615

6609-
// If we're still pending the signature on a funding transaction, then we're not ready to send a
6610-
// channel_ready yet.
6611-
if self.context.signer_pending_funding {
6612-
// TODO: set signer_pending_channel_ready
6613-
log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
6614-
return None;
6615-
}
6616-
66176616
// Note that we don't include ChannelState::WaitingForBatch as we don't want to send
66186617
// channel_ready until the entire batch is ready.
66196618
let need_commitment_update = if matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(f) if f.clone().clear(FundedStateFlags::ALL.into()).is_empty()) {
@@ -6659,6 +6658,17 @@ impl<SP: Deref> Channel<SP> where
66596658
return None;
66606659
}
66616660

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

0 commit comments

Comments
 (0)