]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Update pre-HTLC DataLossProtect to match new spec changes 2020-03-data-loss-spec-550
authorMatt Corallo <git@bluematt.me>
Sat, 15 Feb 2020 03:32:30 +0000 (22:32 -0500)
committerMatt Corallo <git@bluematt.me>
Fri, 6 Mar 2020 02:16:47 +0000 (21:16 -0500)
This was the way DataLossProtect was originally written, however it
didn't match other implementations at the time during testing. It
turns out, other implementations didn't agree with each other
anyway (depending on the exact timeline), so the spec was clarified
somewhat in https://github.com/lightningnetwork/lightning-rfc/pull/550
. This updates us to be in line with the new guidance and appears
to solve out-of-sync issues in testing.

lightning/src/ln/channel.rs

index f155a0bd295051f87c8b69a308774e4e13e53eb0..64f7e4f0b682d78db36cecd00d3cdaa0251cf387 100644 (file)
@@ -3444,10 +3444,10 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                                my_current_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &self.build_local_commitment_secret(self.cur_local_commitment_transaction_number + 1))
                        })
                } else {
-                       log_debug!(self, "We don't seen yet any revoked secret, if this channnel has already been updated it means we are fallen-behind, you should wait for other peer closing");
+                       log_info!(self, "Sending a data_loss_protect with no previous remote per_commitment_secret");
                        OptionalField::Present(DataLossProtect {
                                your_last_per_commitment_secret: [0;32],
-                               my_current_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &self.build_local_commitment_secret(self.cur_local_commitment_transaction_number))
+                               my_current_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &self.build_local_commitment_secret(self.cur_local_commitment_transaction_number + 1))
                        })
                };
                msgs::ChannelReestablish {