Skip to content

Commit 1b202cc

Browse files
author
Antoine Riard
committed
Split provide_secret into itself and provide_their_next_commitment_point to be able to track remote per_commitment_point at channel opening and funds locking
1 parent 0631852 commit 1b202cc

File tree

2 files changed

+94
-87
lines changed

2 files changed

+94
-87
lines changed

src/ln/channel.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ impl Channel {
629629
&chan_keys.htlc_base_key, BREAKDOWN_TIMEOUT,
630630
keys_provider.get_destination_script(), logger.clone());
631631
channel_monitor.set_their_base_keys(&msg.htlc_basepoint, &msg.delayed_payment_basepoint);
632+
channel_monitor.provide_their_next_revocation_point(Some((INITIAL_COMMITMENT_NUMBER, msg.first_per_commitment_point)));
632633
channel_monitor.set_their_to_self_delay(msg.to_self_delay);
633634

634635
let mut chan = Channel {
@@ -1349,6 +1350,7 @@ impl Channel {
13491350
}
13501351

13511352
self.channel_monitor.set_their_base_keys(&msg.htlc_basepoint, &msg.delayed_payment_basepoint);
1353+
self.channel_monitor.provide_their_next_revocation_point(Some((INITIAL_COMMITMENT_NUMBER, msg.first_per_commitment_point)));
13521354

13531355
self.their_dust_limit_satoshis = msg.dust_limit_satoshis;
13541356
self.their_max_htlc_value_in_flight_msat = cmp::min(msg.max_htlc_value_in_flight_msat, self.channel_value_satoshis * 1000);
@@ -1496,6 +1498,7 @@ impl Channel {
14961498
return Err(ChannelError::Close("Peer sent a funding_locked at a strange time"));
14971499
}
14981500

1501+
self.channel_monitor.provide_their_next_revocation_point(Some((INITIAL_COMMITMENT_NUMBER - 1 , msg.next_per_commitment_point)));
14991502
self.their_prev_commitment_point = self.their_cur_commitment_point;
15001503
self.their_cur_commitment_point = Some(msg.next_per_commitment_point);
15011504
Ok(())
@@ -1861,7 +1864,8 @@ impl Channel {
18611864
return Err(HandleError{err: "Got a revoke commitment secret which didn't correspond to their current pubkey", action: None});
18621865
}
18631866
}
1864-
self.channel_monitor.provide_secret(self.cur_remote_commitment_transaction_number + 1, msg.per_commitment_secret, Some((self.cur_remote_commitment_transaction_number - 1, msg.next_per_commitment_point)))?;
1867+
self.channel_monitor.provide_secret(self.cur_remote_commitment_transaction_number + 1, msg.per_commitment_secret)?;
1868+
self.channel_monitor.provide_their_next_revocation_point(Some((self.cur_remote_commitment_transaction_number - 1, msg.next_per_commitment_point)));
18651869

18661870
// Update state now that we've passed all the can-fail calls...
18671871
// (note that we may still fail to generate the new commitment_signed message, but that's

0 commit comments

Comments
 (0)