Skip to content

Commit cf7d48a

Browse files
committed
Handle sending channel_ready when commitment point is unblocked
1 parent e8663c2 commit cf7d48a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lightning/src/ln/channel.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -5472,8 +5472,11 @@ impl<SP: Deref> Channel<SP> where
54725472
let funding_signed = if self.context.signer_pending_funding && !self.context.is_outbound() {
54735473
self.context.get_funding_signed_msg(logger).1
54745474
} else { None };
5475-
let channel_ready = if funding_signed.is_some() {
5476-
self.check_get_channel_ready(0, logger)
5475+
// Provide a `channel_ready` message if we need to, but only if we're _not_ still pending
5476+
// funding.
5477+
let channel_ready = if self.context.signer_pending_channel_ready && !self.context.signer_pending_funding {
5478+
log_trace!(logger, "Attempting to generate pending channel_ready...");
5479+
self.get_channel_ready(logger)
54775480
} else { None };
54785481

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

6668-
// If we're still pending the signature on a funding transaction, then we're not ready to send a
6669-
// channel_ready yet.
6670-
if self.context.signer_pending_funding {
6671-
// TODO: set signer_pending_channel_ready
6672-
log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
6673-
return None;
6674-
}
6675-
66766671
// Note that we don't include ChannelState::WaitingForBatch as we don't want to send
66776672
// channel_ready until the entire batch is ready.
66786673
let need_commitment_update = if matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(f) if f.clone().clear(FundedStateFlags::ALL.into()).is_empty()) {
@@ -6718,6 +6713,17 @@ impl<SP: Deref> Channel<SP> where
67186713
return None;
67196714
}
67206715

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

0 commit comments

Comments
 (0)