@@ -1407,6 +1407,9 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
14071407 /// [`msgs::FundingCreated`] or [`msgs::FundingSigned`] depending on if this channel is
14081408 /// outbound or inbound.
14091409 signer_pending_funding: bool,
1410+ /// Similar to [`Self::signer_pending_commitment_update`] but we're waiting to send a
1411+ /// [`msgs::ChannelReady`].
1412+ signer_pending_channel_ready: bool,
14101413
14111414 // pending_update_fee is filled when sending and receiving update_fee.
14121415 //
@@ -1867,6 +1870,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
18671870
18681871 signer_pending_commitment_update: false,
18691872 signer_pending_funding: false,
1873+ signer_pending_channel_ready: false,
18701874
18711875
18721876 #[cfg(debug_assertions)]
@@ -2095,6 +2099,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
20952099
20962100 signer_pending_commitment_update: false,
20972101 signer_pending_funding: false,
2102+ signer_pending_channel_ready: false,
20982103
20992104 // We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
21002105 // when we receive `accept_channel2`.
@@ -5321,7 +5326,7 @@ impl<SP: Deref> Channel<SP> where
53215326 assert!(!self.context.is_outbound() || self.context.minimum_depth == Some(0),
53225327 "Funding transaction broadcast by the local client before it should have - LDK didn't do it!");
53235328 self.context.monitor_pending_channel_ready = false;
5324- Some( self.get_channel_ready() )
5329+ self.get_channel_ready(logger )
53255330 } else { None };
53265331
53275332 let announcement_sigs = self.get_announcement_sigs(node_signer, chain_hash, user_config, best_block_height, logger);
@@ -5624,7 +5629,7 @@ impl<SP: Deref> Channel<SP> where
56245629
56255630 // We have OurChannelReady set!
56265631 return Ok(ReestablishResponses {
5627- channel_ready: Some( self.get_channel_ready() ),
5632+ channel_ready: self.get_channel_ready(logger ),
56285633 raa: None, commitment_update: None,
56295634 order: RAACommitmentOrder::CommitmentFirst,
56305635 shutdown_msg, announcement_sigs,
@@ -5663,7 +5668,7 @@ impl<SP: Deref> Channel<SP> where
56635668
56645669 let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.context.holder_commitment_point.transaction_number() == 1 {
56655670 // We should never have to worry about MonitorUpdateInProgress resending ChannelReady
5666- Some( self.get_channel_ready() )
5671+ self.get_channel_ready(logger )
56675672 } else { None };
56685673
56695674 if msg.next_local_commitment_number == next_counterparty_commitment_number {
@@ -6554,24 +6559,27 @@ impl<SP: Deref> Channel<SP> where
65546559 }
65556560
65566561 if self.context.signer_pending_funding {
6557- // TODO: set signer_pending_channel_ready
65586562 log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
6563+ self.context.signer_pending_channel_ready = true;
65596564 return None;
65606565 }
65616566
6562- // TODO: when get_per_commiment_point becomes async, check if the point is
6563- // available, if not, set signer_pending_channel_ready and return None
6564-
6565- Some(self.get_channel_ready())
6567+ self.get_channel_ready(logger)
65666568 }
65676569
6568- fn get_channel_ready(&self) -> msgs::ChannelReady {
6569- debug_assert!(self.context.holder_commitment_point.is_available());
6570- msgs::ChannelReady {
6571- channel_id: self.context.channel_id(),
6572- next_per_commitment_point: self.context.holder_commitment_point.current_point()
6573- .expect("TODO"),
6574- short_channel_id_alias: Some(self.context.outbound_scid_alias),
6570+ fn get_channel_ready<L: Deref>(&mut self, logger: &L) -> Option<msgs::ChannelReady>
6571+ where L::Target: Logger
6572+ {
6573+ if let HolderCommitmentPoint::Available { current, .. } = self.context.holder_commitment_point {
6574+ Some(msgs::ChannelReady {
6575+ channel_id: self.context.channel_id(),
6576+ next_per_commitment_point: current,
6577+ short_channel_id_alias: Some(self.context.outbound_scid_alias),
6578+ })
6579+ } else {
6580+ log_debug!(logger, "Not producing channel_ready: the holder commitment point is not available.");
6581+ self.context.signer_pending_channel_ready = true;
6582+ None
65756583 }
65766584 }
65776585
@@ -9500,6 +9508,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
95009508
95019509 signer_pending_commitment_update: false,
95029510 signer_pending_funding: false,
9511+ signer_pending_channel_ready: false,
95039512
95049513 pending_update_fee,
95059514 holding_cell_update_fee,
0 commit comments