Skip to content

Commit 1b33064

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 f053169 commit 1b33064

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
@@ -627,6 +627,7 @@ impl Channel {
627627
&chan_keys.htlc_base_key, BREAKDOWN_TIMEOUT,
628628
keys_provider.get_destination_script(), logger.clone());
629629
channel_monitor.set_their_base_keys(&msg.htlc_basepoint, &msg.delayed_payment_basepoint);
630+
channel_monitor.provide_their_next_revocation_point(Some((INITIAL_COMMITMENT_NUMBER, msg.first_per_commitment_point)));
630631
channel_monitor.set_their_to_self_delay(msg.to_self_delay);
631632

632633
let mut chan = Channel {
@@ -1347,6 +1348,7 @@ impl Channel {
13471348
}
13481349

13491350
self.channel_monitor.set_their_base_keys(&msg.htlc_basepoint, &msg.delayed_payment_basepoint);
1351+
self.channel_monitor.provide_their_next_revocation_point(Some((INITIAL_COMMITMENT_NUMBER, msg.first_per_commitment_point)));
13501352

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

1499+
self.channel_monitor.provide_their_next_revocation_point(Some((INITIAL_COMMITMENT_NUMBER - 1 , msg.next_per_commitment_point)));
14971500
self.their_prev_commitment_point = self.their_cur_commitment_point;
14981501
self.their_cur_commitment_point = Some(msg.next_per_commitment_point);
14991502
Ok(())
@@ -1873,7 +1876,8 @@ impl Channel {
18731876
return Err(HandleError{err: "Got a revoke commitment secret which didn't correspond to their current pubkey", action: None});
18741877
}
18751878
}
1876-
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)))?;
1879+
self.channel_monitor.provide_secret(self.cur_remote_commitment_transaction_number + 1, msg.per_commitment_secret)?;
1880+
self.channel_monitor.provide_their_next_revocation_point(Some((self.cur_remote_commitment_transaction_number - 1, msg.next_per_commitment_point)));
18771881

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

0 commit comments

Comments
 (0)