diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 6b1511387d6..a1bb0a813ba 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -1506,6 +1506,7 @@ impl Channel { self.their_prev_commitment_point = self.their_cur_commitment_point; self.their_cur_commitment_point = Some(msg.next_per_commitment_point); + self.channel_monitor.init_remote_per_commitment_point(self.cur_remote_commitment_transaction_number, msg.next_per_commitment_point); Ok(()) } diff --git a/src/ln/channelmonitor.rs b/src/ln/channelmonitor.rs index 60cb9c91583..581219dc8bd 100644 --- a/src/ln/channelmonitor.rs +++ b/src/ln/channelmonitor.rs @@ -378,6 +378,10 @@ impl ChannelMonitor { res } + pub(super) fn init_remote_per_commitment_point(&mut self, idx: u64, revocation_point: PublicKey) { + self.their_cur_revocation_points = Some((idx, revocation_point, None)); + } + /// Inserts a revocation secret into this channel monitor. Also optionally tracks the next /// revocation point which may be required to claim HTLC outputs which we know the preimage of /// in case the remote end force-closes using their latest state. Prunes old preimages if neither @@ -926,7 +930,7 @@ impl ChannelMonitor { let revocation_point_option = if revocation_points.0 == commitment_number { Some(&revocation_points.1) } else if let Some(point) = revocation_points.2.as_ref() { - if revocation_points.0 == commitment_number + 1 { Some(point) } else { None } + if revocation_points.0 == commitment_number + 1 { Some(point) } else if revocation_points.0 == commitment_number - 1 { Some(point) } else { None } } else { None }; if let Some(revocation_point) = revocation_point_option { let (revocation_pubkey, b_htlc_key) = match self.key_storage {