]> git.bitcoin.ninja Git - rust-lightning/blobdiff - lightning/src/ln/channel.rs
Fix panic on receiving `channel_ready` after 1st commitment update
[rust-lightning] / lightning / src / ln / channel.rs
index 76dc15065c05cd298b532247de377b757ce5491f..ec2810d14cbd8cce512956cb8f7d930f55a8d30f 100644 (file)
@@ -2426,6 +2426,11 @@ impl<Signer: Sign> Channel<Signer> {
                                        // If they haven't ever sent an updated point, the point they send should match
                                        // the current one.
                                        self.counterparty_cur_commitment_point
+                               } else if self.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 2 {
+                                       // If we've advanced the commitment number once, the second commitment point is
+                                       // at `counterparty_prev_commitment_point`, which is not yet revoked.
+                                       debug_assert!(self.counterparty_prev_commitment_point.is_some());
+                                       self.counterparty_prev_commitment_point
                                } else {
                                        // If they have sent updated points, channel_ready is always supposed to match
                                        // their "first" point, which we re-derive here.