Skip to content

Commit 26fdad1

Browse files
author
Antoine Riard
committed
Split provide_their_next_commitment_point from provide_secret
We needed it to be able to track remote_per_commitment_point after channel opening and funds locking
1 parent aa920b1 commit 26fdad1

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(())
@@ -1875,7 +1878,8 @@ impl Channel {
18751878
return Err(HandleError{err: "Got a revoke commitment secret which didn't correspond to their current pubkey", action: None});
18761879
}
18771880
}
1878-
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)))?;
1881+
self.channel_monitor.provide_secret(self.cur_remote_commitment_transaction_number + 1, msg.per_commitment_secret)?;
1882+
self.channel_monitor.provide_their_next_revocation_point(Some((self.cur_remote_commitment_transaction_number - 1, msg.next_per_commitment_point)));
18791883

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

0 commit comments

Comments
 (0)