Skip to content

Commit f62e260

Browse files
committed
Handle sending channel_ready when commitment point is unblocked
1 parent 6d723ad commit f62e260

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

lightning/src/ln/channel.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5438,8 +5438,18 @@ impl<SP: Deref> Channel<SP> where
54385438
self.context.signer_pending_funding = false;
54395439
self.context.get_funding_signed_msg(logger).1
54405440
} else { None };
5441-
let channel_ready = if funding_signed.is_some() {
5442-
self.check_get_channel_ready(0, logger)
5441+
if !self.context.holder_commitment_point.is_available() {
5442+
log_trace!(logger, "Attempting to update holder per-commitment point...");
5443+
self.context.holder_commitment_point.advance(&self.context.holder_signer, &self.context.secp_ctx, logger);
5444+
}
5445+
// Provide a `channel_ready` message if we need to, but only if we're _not_ still pending
5446+
// funding.
5447+
let channel_ready = if self.context.signer_pending_channel_ready && !self.context.signer_pending_funding {
5448+
log_trace!(logger, "Attempting to generate pending channel_ready...");
5449+
self.get_channel_ready(logger).map(|msg| {
5450+
self.context.signer_pending_channel_ready = false;
5451+
msg
5452+
})
54435453
} else { None };
54445454

54455455
log_trace!(logger, "Signer unblocked with {} commitment_update, {} funding_signed and {} channel_ready",
@@ -6530,14 +6540,6 @@ impl<SP: Deref> Channel<SP> where
65306540
return None;
65316541
}
65326542

6533-
// If we're still pending the signature on a funding transaction, then we're not ready to send a
6534-
// channel_ready yet.
6535-
if self.context.signer_pending_funding {
6536-
// TODO: set signer_pending_channel_ready
6537-
log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
6538-
return None;
6539-
}
6540-
65416543
// Note that we don't include ChannelState::WaitingForBatch as we don't want to send
65426544
// channel_ready until the entire batch is ready.
65436545
let need_commitment_update = if matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(f) if f.clone().clear(FundedStateFlags::ALL.into()).is_empty()) {
@@ -6583,6 +6585,17 @@ impl<SP: Deref> Channel<SP> where
65836585
return None;
65846586
}
65856587

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

0 commit comments

Comments
 (0)