@@ -1221,6 +1221,9 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1221
1221
/// [`msgs::FundingCreated`] or [`msgs::FundingSigned`] depending on if this channel is
1222
1222
/// outbound or inbound.
1223
1223
signer_pending_funding: bool,
1224
+ /// Similar to [`Self::signer_pending_commitment_update`] but we're waiting to send a
1225
+ /// [`msgs::ChannelReady`].
1226
+ signer_pending_channel_ready: bool,
1224
1227
1225
1228
// pending_update_fee is filled when sending and receiving update_fee.
1226
1229
//
@@ -1681,6 +1684,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1681
1684
1682
1685
signer_pending_commitment_update: false,
1683
1686
signer_pending_funding: false,
1687
+ signer_pending_channel_ready: false,
1684
1688
1685
1689
1686
1690
#[cfg(debug_assertions)]
@@ -1909,6 +1913,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1909
1913
1910
1914
signer_pending_commitment_update: false,
1911
1915
signer_pending_funding: false,
1916
+ signer_pending_channel_ready: false,
1912
1917
1913
1918
// We'll add our counterparty's `funding_satoshis` to these max commitment output assertions
1914
1919
// when we receive `accept_channel2`.
@@ -5135,7 +5140,7 @@ impl<SP: Deref> Channel<SP> where
5135
5140
assert!(!self.context.is_outbound() || self.context.minimum_depth == Some(0),
5136
5141
"Funding transaction broadcast by the local client before it should have - LDK didn't do it!");
5137
5142
self.context.monitor_pending_channel_ready = false;
5138
- Some( self.get_channel_ready() )
5143
+ self.get_channel_ready(logger )
5139
5144
} else { None };
5140
5145
5141
5146
let announcement_sigs = self.get_announcement_sigs(node_signer, chain_hash, user_config, best_block_height, logger);
@@ -5438,7 +5443,7 @@ impl<SP: Deref> Channel<SP> where
5438
5443
5439
5444
// We have OurChannelReady set!
5440
5445
return Ok(ReestablishResponses {
5441
- channel_ready: Some( self.get_channel_ready() ),
5446
+ channel_ready: self.get_channel_ready(logger ),
5442
5447
raa: None, commitment_update: None,
5443
5448
order: RAACommitmentOrder::CommitmentFirst,
5444
5449
shutdown_msg, announcement_sigs,
@@ -5477,7 +5482,7 @@ impl<SP: Deref> Channel<SP> where
5477
5482
5478
5483
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.context.holder_commitment_point.transaction_number() == 1 {
5479
5484
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
5480
- Some( self.get_channel_ready() )
5485
+ self.get_channel_ready(logger )
5481
5486
} else { None };
5482
5487
5483
5488
if msg.next_local_commitment_number == next_counterparty_commitment_number {
@@ -6368,24 +6373,27 @@ impl<SP: Deref> Channel<SP> where
6368
6373
}
6369
6374
6370
6375
if self.context.signer_pending_funding {
6371
- // TODO: set signer_pending_channel_ready
6372
6376
log_debug!(logger, "Can't produce channel_ready: the signer is pending funding.");
6377
+ self.context.signer_pending_channel_ready = true;
6373
6378
return None;
6374
6379
}
6375
6380
6376
- // TODO: when get_per_commiment_point becomes async, check if the point is
6377
- // available, if not, set signer_pending_channel_ready and return None
6378
-
6379
- Some(self.get_channel_ready())
6381
+ self.get_channel_ready(logger)
6380
6382
}
6381
6383
6382
- fn get_channel_ready(&self) -> msgs::ChannelReady {
6383
- debug_assert!(self.context.holder_commitment_point.is_available());
6384
- msgs::ChannelReady {
6385
- channel_id: self.context.channel_id(),
6386
- next_per_commitment_point: self.context.holder_commitment_point.current_point()
6387
- .expect("TODO"),
6388
- short_channel_id_alias: Some(self.context.outbound_scid_alias),
6384
+ fn get_channel_ready<L: Deref>(&mut self, logger: &L) -> Option<msgs::ChannelReady>
6385
+ where L::Target: Logger
6386
+ {
6387
+ if let HolderCommitmentPoint::Available { current, .. } = self.context.holder_commitment_point {
6388
+ Some(msgs::ChannelReady {
6389
+ channel_id: self.context.channel_id(),
6390
+ next_per_commitment_point: current,
6391
+ short_channel_id_alias: Some(self.context.outbound_scid_alias),
6392
+ })
6393
+ } else {
6394
+ log_debug!(logger, "Not producing channel_ready: the holder commitment point is not available.");
6395
+ self.context.signer_pending_channel_ready = true;
6396
+ None
6389
6397
}
6390
6398
}
6391
6399
@@ -9314,6 +9322,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
9314
9322
9315
9323
signer_pending_commitment_update: false,
9316
9324
signer_pending_funding: false,
9325
+ signer_pending_channel_ready: false,
9317
9326
9318
9327
pending_update_fee,
9319
9328
holding_cell_update_fee,
0 commit comments