@@ -1277,6 +1277,9 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1277
1277
/// If we attempted to sign a cooperative close transaction but the signer wasn't ready, then this
1278
1278
/// will be set to `true`.
1279
1279
signer_pending_closing: bool,
1280
+ /// Similar to [`Self::signer_pending_commitment_update`] but we're waiting to send a
1281
+ /// [`msgs::ChannelReady`].
1282
+ signer_pending_channel_ready: bool,
1280
1283
1281
1284
// pending_update_fee is filled when sending and receiving update_fee.
1282
1285
//
@@ -1744,6 +1747,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1744
1747
signer_pending_commitment_update: false,
1745
1748
signer_pending_funding: false,
1746
1749
signer_pending_closing: false,
1750
+ signer_pending_channel_ready: false,
1747
1751
1748
1752
1749
1753
#[cfg(debug_assertions)]
@@ -1974,6 +1978,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1974
1978
signer_pending_commitment_update: false,
1975
1979
signer_pending_funding: false,
1976
1980
signer_pending_closing: false,
1981
+ signer_pending_channel_ready: false,
1977
1982
1978
1983
// We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
1979
1984
// when we receive `accept_channel2`.
@@ -5350,7 +5355,7 @@ impl<SP: Deref> Channel<SP> where
5350
5355
assert!(!self.context.is_outbound() || self.context.minimum_depth == Some(0),
5351
5356
"Funding transaction broadcast by the local client before it should have - LDK didn't do it!");
5352
5357
self.context.monitor_pending_channel_ready = false;
5353
- Some( self.get_channel_ready() )
5358
+ self.get_channel_ready(logger )
5354
5359
} else { None };
5355
5360
5356
5361
let announcement_sigs = self.get_announcement_sigs(node_signer, chain_hash, user_config, best_block_height, logger);
@@ -5767,7 +5772,7 @@ impl<SP: Deref> Channel<SP> where
5767
5772
5768
5773
// We have OurChannelReady set!
5769
5774
return Ok(ReestablishResponses {
5770
- channel_ready: Some( self.get_channel_ready() ),
5775
+ channel_ready: self.get_channel_ready(logger ),
5771
5776
raa: None, commitment_update: None,
5772
5777
order: RAACommitmentOrder::CommitmentFirst,
5773
5778
shutdown_msg, announcement_sigs,
@@ -5806,7 +5811,7 @@ impl<SP: Deref> Channel<SP> where
5806
5811
5807
5812
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number() == 1 {
5808
5813
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
5809
- Some( self.get_channel_ready() )
5814
+ self.get_channel_ready(logger )
5810
5815
} else { None };
5811
5816
5812
5817
if msg.next_local_commitment_number == next_counterparty_commitment_number {
@@ -6713,18 +6718,23 @@ impl<SP: Deref> Channel<SP> where
6713
6718
return None;
6714
6719
}
6715
6720
6716
- // TODO: when get_per_commiment_point becomes async, check if the point is
6717
- // available, if not, set signer_pending_channel_ready and return None
6718
-
6719
- Some(self.get_channel_ready())
6721
+ self.get_channel_ready(logger)
6720
6722
}
6721
6723
6722
- fn get_channel_ready(&self) -> msgs::ChannelReady {
6723
- debug_assert!(self.holder_commitment_point.is_available());
6724
- msgs::ChannelReady {
6725
- channel_id: self.context.channel_id(),
6726
- next_per_commitment_point: self.holder_commitment_point.current_point(),
6727
- short_channel_id_alias: Some(self.context.outbound_scid_alias),
6724
+ fn get_channel_ready<L: Deref>(&mut self, logger: &L) -> Option<msgs::ChannelReady>
6725
+ where L::Target: Logger
6726
+ {
6727
+ if let HolderCommitmentPoint::Available { current, .. } = self.holder_commitment_point {
6728
+ self.context.signer_pending_channel_ready = false;
6729
+ Some(msgs::ChannelReady {
6730
+ channel_id: self.context.channel_id(),
6731
+ next_per_commitment_point: current,
6732
+ short_channel_id_alias: Some(self.context.outbound_scid_alias),
6733
+ })
6734
+ } else {
6735
+ log_debug!(logger, "Not producing channel_ready: the holder commitment point is not available.");
6736
+ self.context.signer_pending_channel_ready = true;
6737
+ None
6728
6738
}
6729
6739
}
6730
6740
@@ -9591,6 +9601,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
9591
9601
signer_pending_commitment_update: false,
9592
9602
signer_pending_funding: false,
9593
9603
signer_pending_closing: false,
9604
+ signer_pending_channel_ready: false,
9594
9605
9595
9606
pending_update_fee,
9596
9607
holding_cell_update_fee,
0 commit comments