Skip to content

Commit 9709b3e

Browse files
committed
Handle sending channel_ready when commitment point is unblocked
1 parent 21e6bfe commit 9709b3e

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

lightning/src/ln/channel.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -5471,8 +5471,15 @@ impl<SP: Deref> Channel<SP> where
54715471
let funding_signed = if self.context.signer_pending_funding && !self.context.is_outbound() {
54725472
self.context.get_funding_signed_msg(logger).1
54735473
} else { None };
5474-
let channel_ready = if funding_signed.is_some() {
5475-
self.check_get_channel_ready(0, logger)
5474+
if !self.context.holder_commitment_point.is_available() {
5475+
log_trace!(logger, "Attempting to update holder per-commitment point...");
5476+
self.context.holder_commitment_point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
5477+
}
5478+
// Provide a `channel_ready` message if we need to, but only if we're _not_ still pending
5479+
// funding.
5480+
let channel_ready = if self.context.signer_pending_channel_ready && !self.context.signer_pending_funding {
5481+
log_trace!(logger, "Attempting to generate pending channel_ready...");
5482+
self.get_channel_ready(logger)
54765483
} else { None };
54775484

54785485
let mut commitment_update = if self.context.signer_pending_commitment_update {
@@ -6634,14 +6641,6 @@ impl<SP: Deref> Channel<SP> where
66346641
return None;
66356642
}
66366643

6637-
// If we're still pending the signature on a funding transaction, then we're not ready to send a
6638-
// channel_ready yet.
6639-
if self.context.signer_pending_funding {
6640-
// TODO: set signer_pending_channel_ready
6641-
log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
6642-
return None;
6643-
}
6644-
66456644
// Note that we don't include ChannelState::WaitingForBatch as we don't want to send
66466645
// channel_ready until the entire batch is ready.
66476646
let need_commitment_update = if matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(f) if f.clone().clear(FundedStateFlags::ALL.into()).is_empty()) {
@@ -6687,6 +6686,17 @@ impl<SP: Deref> Channel<SP> where
66876686
return None;
66886687
}
66896688

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

0 commit comments

Comments
 (0)