Skip to content

f - Provide channel_monitor with first per_commitment_point of channel #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down
6 changes: 5 additions & 1 deletion src/ln/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down