@@ -1280,6 +1280,9 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1280
1280
/// [`msgs::FundingCreated`] or [`msgs::FundingSigned`] depending on if this channel is
1281
1281
/// outbound or inbound.
1282
1282
signer_pending_funding: bool,
1283
+ /// Similar to [`Self::signer_pending_commitment_update`] but we're waiting to send a
1284
+ /// [`msgs::ChannelReady`].
1285
+ signer_pending_channel_ready: bool,
1283
1286
1284
1287
// pending_update_fee is filled when sending and receiving update_fee.
1285
1288
//
@@ -1741,6 +1744,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1741
1744
signer_pending_revoke_and_ack: false,
1742
1745
signer_pending_commitment_update: false,
1743
1746
signer_pending_funding: false,
1747
+ signer_pending_channel_ready: false,
1744
1748
1745
1749
1746
1750
#[cfg(debug_assertions)]
@@ -1970,6 +1974,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1970
1974
signer_pending_revoke_and_ack: false,
1971
1975
signer_pending_commitment_update: false,
1972
1976
signer_pending_funding: false,
1977
+ signer_pending_channel_ready: false,
1973
1978
1974
1979
// We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
1975
1980
// when we receive `accept_channel2`.
@@ -5336,7 +5341,7 @@ impl<SP: Deref> Channel<SP> where
5336
5341
assert!(!self.context.is_outbound() || self.context.minimum_depth == Some(0),
5337
5342
"Funding transaction broadcast by the local client before it should have - LDK didn't do it!");
5338
5343
self.context.monitor_pending_channel_ready = false;
5339
- Some( self.get_channel_ready() )
5344
+ self.get_channel_ready(logger )
5340
5345
} else { None };
5341
5346
5342
5347
let announcement_sigs = self.get_announcement_sigs(node_signer, chain_hash, user_config, best_block_height, logger);
@@ -5704,7 +5709,7 @@ impl<SP: Deref> Channel<SP> where
5704
5709
5705
5710
// We have OurChannelReady set!
5706
5711
return Ok(ReestablishResponses {
5707
- channel_ready: Some( self.get_channel_ready() ),
5712
+ channel_ready: self.get_channel_ready(logger ),
5708
5713
raa: None, commitment_update: None,
5709
5714
order: RAACommitmentOrder::CommitmentFirst,
5710
5715
shutdown_msg, announcement_sigs,
@@ -5743,7 +5748,7 @@ impl<SP: Deref> Channel<SP> where
5743
5748
5744
5749
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.context.holder_commitment_point.transaction_number() == 1 {
5745
5750
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
5746
- Some( self.get_channel_ready() )
5751
+ self.get_channel_ready(logger )
5747
5752
} else { None };
5748
5753
5749
5754
if msg.next_local_commitment_number == next_counterparty_commitment_number {
@@ -6650,19 +6655,22 @@ impl<SP: Deref> Channel<SP> where
6650
6655
return None;
6651
6656
}
6652
6657
6653
- // TODO: when get_per_commiment_point becomes async, check if the point is
6654
- // available, if not, set signer_pending_channel_ready and return None
6655
-
6656
- Some(self.get_channel_ready())
6658
+ self.get_channel_ready(logger)
6657
6659
}
6658
6660
6659
- fn get_channel_ready(&self) -> msgs::ChannelReady {
6660
- debug_assert!(self.context.holder_commitment_point.is_available());
6661
- msgs::ChannelReady {
6662
- channel_id: self.context.channel_id(),
6663
- next_per_commitment_point: self.context.holder_commitment_point.current_point()
6664
- .expect("TODO"),
6665
- short_channel_id_alias: Some(self.context.outbound_scid_alias),
6661
+ fn get_channel_ready<L: Deref>(&mut self, logger: &L) -> Option<msgs::ChannelReady>
6662
+ where L::Target: Logger
6663
+ {
6664
+ if let HolderCommitmentPoint::Available { current, .. } = self.context.holder_commitment_point {
6665
+ Some(msgs::ChannelReady {
6666
+ channel_id: self.context.channel_id(),
6667
+ next_per_commitment_point: current,
6668
+ short_channel_id_alias: Some(self.context.outbound_scid_alias),
6669
+ })
6670
+ } else {
6671
+ log_debug!(logger, "Not producing channel_ready: the holder commitment point is not available.");
6672
+ self.context.signer_pending_channel_ready = true;
6673
+ None
6666
6674
}
6667
6675
}
6668
6676
@@ -9478,6 +9486,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
9478
9486
signer_pending_revoke_and_ack: false,
9479
9487
signer_pending_commitment_update: false,
9480
9488
signer_pending_funding: false,
9489
+ signer_pending_channel_ready: false,
9481
9490
9482
9491
pending_update_fee,
9483
9492
holding_cell_update_fee,
0 commit comments