@@ -5500,32 +5500,42 @@ impl<SP: Deref> Channel<SP> where
5500
5500
fn get_last_revoke_and_ack<L: Deref>(&mut self, logger: &L) -> Option<msgs::RevokeAndACK> where L::Target: Logger {
5501
5501
debug_assert!(self.context.holder_commitment_point.transaction_number() <= INITIAL_COMMITMENT_NUMBER - 2);
5502
5502
self.context.holder_commitment_point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
5503
- let per_commitment_secret = self.context.holder_signer.as_ref().release_commitment_secret(self.context.holder_commitment_point.transaction_number() + 2);
5504
- if let HolderCommitmentPoint::Available { transaction_number: _, current, next: _ } = self.context.holder_commitment_point {
5503
+ let per_commitment_secret = self.context.holder_signer.as_ref()
5504
+ .release_commitment_secret(self.context.holder_commitment_point.transaction_number() + 2).ok();
5505
+ if let (HolderCommitmentPoint::Available { current, .. }, Some(per_commitment_secret)) =
5506
+ (self.context.holder_commitment_point, per_commitment_secret) {
5505
5507
self.context.signer_pending_revoke_and_ack = false;
5506
- Some(msgs::RevokeAndACK {
5508
+ return Some(msgs::RevokeAndACK {
5507
5509
channel_id: self.context.channel_id,
5508
5510
per_commitment_secret,
5509
5511
next_per_commitment_point: current,
5510
5512
#[cfg(taproot)]
5511
5513
next_local_nonce: None,
5512
5514
})
5513
- } else {
5514
- #[cfg(not(async_signing))] {
5515
- panic!("Holder commitment point must be Available when generating revoke_and_ack");
5516
- }
5517
- #[cfg(async_signing)] {
5518
- // Technically if we're at HolderCommitmentPoint::PendingNext,
5519
- // we have a commitment point ready to send in an RAA, however we
5520
- // choose to wait since if we send RAA now, we could get another
5521
- // CS before we have any commitment point available. Blocking our
5522
- // RAA here is a convenient way to make sure that post-funding
5523
- // we're only ever waiting on one commitment point at a time.
5524
- log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available",
5525
- &self.context.channel_id(), self.context.holder_commitment_point.transaction_number());
5526
- self.context.signer_pending_revoke_and_ack = true;
5527
- None
5528
- }
5515
+ }
5516
+ if !self.context.holder_commitment_point.is_available() {
5517
+ log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available",
5518
+ &self.context.channel_id(), self.context.holder_commitment_point.transaction_number());
5519
+ }
5520
+ if per_commitment_secret.is_none() {
5521
+ log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment secret for {} is not available",
5522
+ &self.context.channel_id(), self.context.holder_commitment_point.transaction_number(),
5523
+ self.context.holder_commitment_point.transaction_number() + 2);
5524
+ }
5525
+ #[cfg(not(async_signing))] {
5526
+ panic!("Holder commitment point and per commitment secret must be available when generating revoke_and_ack");
5527
+ }
5528
+ #[cfg(async_signing)] {
5529
+ // Technically if we're at HolderCommitmentPoint::PendingNext,
5530
+ // we have a commitment point ready to send in an RAA, however we
5531
+ // choose to wait since if we send RAA now, we could get another
5532
+ // CS before we have any commitment point available. Blocking our
5533
+ // RAA here is a convenient way to make sure that post-funding
5534
+ // we're only ever waiting on one commitment point at a time.
5535
+ log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available",
5536
+ &self.context.channel_id(), self.context.holder_commitment_point.transaction_number());
5537
+ self.context.signer_pending_revoke_and_ack = true;
5538
+ None
5529
5539
}
5530
5540
}
5531
5541
0 commit comments