Skip to content

Commit dbd23dc

Browse files
committed
Handle sending channel_ready when commitment point is unblocked
1 parent d1ab806 commit dbd23dc

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

lightning/src/ln/channel.rs

+23-10
Original file line numberDiff line numberDiff line change
@@ -5460,8 +5460,18 @@ impl<SP: Deref> Channel<SP> where
54605460
self.context.signer_pending_funding = false;
54615461
self.context.get_funding_signed_msg(logger).1
54625462
} else { None };
5463-
let channel_ready = if funding_signed.is_some() {
5464-
self.check_get_channel_ready(0, logger)
5463+
if !self.context.holder_commitment_point.is_available() {
5464+
log_trace!(logger, "Attempting to update holder per-commitment point...");
5465+
self.context.holder_commitment_point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
5466+
}
5467+
// Provide a `channel_ready` message if we need to, but only if we're _not_ still pending
5468+
// funding.
5469+
let channel_ready = if self.context.signer_pending_channel_ready && !self.context.signer_pending_funding {
5470+
log_trace!(logger, "Attempting to generate pending channel_ready...");
5471+
self.get_channel_ready(logger).map(|msg| {
5472+
self.context.signer_pending_channel_ready = false;
5473+
msg
5474+
})
54655475
} else { None };
54665476

54675477
let mut commitment_update = if self.context.signer_pending_commitment_update {
@@ -6602,14 +6612,6 @@ impl<SP: Deref> Channel<SP> where
66026612
return None;
66036613
}
66046614

6605-
// If we're still pending the signature on a funding transaction, then we're not ready to send a
6606-
// channel_ready yet.
6607-
if self.context.signer_pending_funding {
6608-
// TODO: set signer_pending_channel_ready
6609-
log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
6610-
return None;
6611-
}
6612-
66136615
// Note that we don't include ChannelState::WaitingForBatch as we don't want to send
66146616
// channel_ready until the entire batch is ready.
66156617
let need_commitment_update = if matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(f) if f.clone().clear(FundedStateFlags::ALL.into()).is_empty()) {
@@ -6655,6 +6657,17 @@ impl<SP: Deref> Channel<SP> where
66556657
return None;
66566658
}
66576659

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

0 commit comments

Comments
 (0)