@@ -1270,6 +1270,9 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1270
1270
/// [`msgs::FundingCreated`] or [`msgs::FundingSigned`] depending on if this channel is
1271
1271
/// outbound or inbound.
1272
1272
signer_pending_funding: bool,
1273
+ /// Similar to [`Self::signer_pending_commitment_update`] but we're waiting to send a
1274
+ /// [`msgs::ChannelReady`].
1275
+ signer_pending_channel_ready: bool,
1273
1276
1274
1277
// pending_update_fee is filled when sending and receiving update_fee.
1275
1278
//
@@ -1730,6 +1733,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1730
1733
1731
1734
signer_pending_commitment_update: false,
1732
1735
signer_pending_funding: false,
1736
+ signer_pending_channel_ready: false,
1733
1737
1734
1738
1735
1739
#[cfg(debug_assertions)]
@@ -1958,6 +1962,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1958
1962
1959
1963
signer_pending_commitment_update: false,
1960
1964
signer_pending_funding: false,
1965
+ signer_pending_channel_ready: false,
1961
1966
1962
1967
// We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
1963
1968
// when we receive `accept_channel2`.
@@ -5324,7 +5329,7 @@ impl<SP: Deref> Channel<SP> where
5324
5329
assert!(!self.context.is_outbound() || self.context.minimum_depth == Some(0),
5325
5330
"Funding transaction broadcast by the local client before it should have - LDK didn't do it!");
5326
5331
self.context.monitor_pending_channel_ready = false;
5327
- Some( self.get_channel_ready() )
5332
+ self.get_channel_ready(logger )
5328
5333
} else { None };
5329
5334
5330
5335
let announcement_sigs = self.get_announcement_sigs(node_signer, chain_hash, user_config, best_block_height, logger);
@@ -5647,7 +5652,7 @@ impl<SP: Deref> Channel<SP> where
5647
5652
5648
5653
// We have OurChannelReady set!
5649
5654
return Ok(ReestablishResponses {
5650
- channel_ready: Some( self.get_channel_ready() ),
5655
+ channel_ready: self.get_channel_ready(logger ),
5651
5656
raa: None, commitment_update: None,
5652
5657
order: RAACommitmentOrder::CommitmentFirst,
5653
5658
shutdown_msg, announcement_sigs,
@@ -5686,7 +5691,7 @@ impl<SP: Deref> Channel<SP> where
5686
5691
5687
5692
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.context.holder_commitment_point.transaction_number() == 1 {
5688
5693
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
5689
- Some( self.get_channel_ready() )
5694
+ self.get_channel_ready(logger )
5690
5695
} else { None };
5691
5696
5692
5697
if msg.next_local_commitment_number == next_counterparty_commitment_number {
@@ -6578,19 +6583,22 @@ impl<SP: Deref> Channel<SP> where
6578
6583
return None;
6579
6584
}
6580
6585
6581
- // TODO: when get_per_commiment_point becomes async, check if the point is
6582
- // available, if not, set signer_pending_channel_ready and return None
6583
-
6584
- Some(self.get_channel_ready())
6586
+ self.get_channel_ready(logger)
6585
6587
}
6586
6588
6587
- fn get_channel_ready(&self) -> msgs::ChannelReady {
6588
- debug_assert!(self.context.holder_commitment_point.is_available());
6589
- msgs::ChannelReady {
6590
- channel_id: self.context.channel_id(),
6591
- next_per_commitment_point: self.context.holder_commitment_point.current_point()
6592
- .expect("TODO"),
6593
- short_channel_id_alias: Some(self.context.outbound_scid_alias),
6589
+ fn get_channel_ready<L: Deref>(&mut self, logger: &L) -> Option<msgs::ChannelReady>
6590
+ where L::Target: Logger
6591
+ {
6592
+ if let HolderCommitmentPoint::Available { current, .. } = self.context.holder_commitment_point {
6593
+ Some(msgs::ChannelReady {
6594
+ channel_id: self.context.channel_id(),
6595
+ next_per_commitment_point: current,
6596
+ short_channel_id_alias: Some(self.context.outbound_scid_alias),
6597
+ })
6598
+ } else {
6599
+ log_debug!(logger, "Not producing channel_ready: the holder commitment point is not available.");
6600
+ self.context.signer_pending_channel_ready = true;
6601
+ None
6594
6602
}
6595
6603
}
6596
6604
@@ -9411,6 +9419,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
9411
9419
9412
9420
signer_pending_commitment_update: false,
9413
9421
signer_pending_funding: false,
9422
+ signer_pending_channel_ready: false,
9414
9423
9415
9424
pending_update_fee,
9416
9425
holding_cell_update_fee,
0 commit comments