@@ -1407,6 +1407,9 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1407
1407
/// [`msgs::FundingCreated`] or [`msgs::FundingSigned`] depending on if this channel is
1408
1408
/// outbound or inbound.
1409
1409
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,
1410
1413
1411
1414
// pending_update_fee is filled when sending and receiving update_fee.
1412
1415
//
@@ -1867,6 +1870,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1867
1870
1868
1871
signer_pending_commitment_update: false,
1869
1872
signer_pending_funding: false,
1873
+ signer_pending_channel_ready: false,
1870
1874
1871
1875
1872
1876
#[cfg(debug_assertions)]
@@ -2095,6 +2099,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2095
2099
2096
2100
signer_pending_commitment_update: false,
2097
2101
signer_pending_funding: false,
2102
+ signer_pending_channel_ready: false,
2098
2103
2099
2104
// We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
2100
2105
// when we receive `accept_channel2`.
@@ -5321,7 +5326,7 @@ impl<SP: Deref> Channel<SP> where
5321
5326
assert!(!self.context.is_outbound() || self.context.minimum_depth == Some(0),
5322
5327
"Funding transaction broadcast by the local client before it should have - LDK didn't do it!");
5323
5328
self.context.monitor_pending_channel_ready = false;
5324
- Some( self.get_channel_ready() )
5329
+ self.get_channel_ready(logger )
5325
5330
} else { None };
5326
5331
5327
5332
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
5624
5629
5625
5630
// We have OurChannelReady set!
5626
5631
return Ok(ReestablishResponses {
5627
- channel_ready: Some( self.get_channel_ready() ),
5632
+ channel_ready: self.get_channel_ready(logger ),
5628
5633
raa: None, commitment_update: None,
5629
5634
order: RAACommitmentOrder::CommitmentFirst,
5630
5635
shutdown_msg, announcement_sigs,
@@ -5663,7 +5668,7 @@ impl<SP: Deref> Channel<SP> where
5663
5668
5664
5669
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.context.holder_commitment_point.transaction_number() == 1 {
5665
5670
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
5666
- Some( self.get_channel_ready() )
5671
+ self.get_channel_ready(logger )
5667
5672
} else { None };
5668
5673
5669
5674
if msg.next_local_commitment_number == next_counterparty_commitment_number {
@@ -6554,24 +6559,27 @@ impl<SP: Deref> Channel<SP> where
6554
6559
}
6555
6560
6556
6561
if self.context.signer_pending_funding {
6557
- // TODO: set signer_pending_channel_ready
6558
6562
log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
6563
+ self.context.signer_pending_channel_ready = true;
6559
6564
return None;
6560
6565
}
6561
6566
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)
6566
6568
}
6567
6569
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
6575
6583
}
6576
6584
}
6577
6585
@@ -9500,6 +9508,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
9500
9508
9501
9509
signer_pending_commitment_update: false,
9502
9510
signer_pending_funding: false,
9511
+ signer_pending_channel_ready: false,
9503
9512
9504
9513
pending_update_fee,
9505
9514
holding_cell_update_fee,
0 commit comments