+ if self.channel_state & (ChannelState::FundingSent as u32 | ChannelState::OurFundingLocked as u32) == ChannelState::FundingSent as u32 {
+ // Short circuit the whole handler as there is nothing we can resend them
+ return Ok((None, None, None, None, RAACommitmentOrder::CommitmentFirst));
+ }
+
+ if msg.next_local_commitment_number == 0 || msg.next_remote_commitment_number == 0 {
+ if self.channel_state & (ChannelState::FundingSent as u32) != ChannelState::FundingSent as u32 {
+ return Err(ChannelError::Close("Peer sent a pre-funding channel_reestablish after we exchanged funding_locked"));
+ }
+ // We have OurFundingLocked set!
+ let next_per_commitment_secret = self.build_local_commitment_secret(self.cur_local_commitment_transaction_number);
+ let next_per_commitment_point = PublicKey::from_secret_key(&self.secp_ctx, &next_per_commitment_secret);
+ return Ok((Some(msgs::FundingLocked {
+ channel_id: self.channel_id(),
+ next_per_commitment_point: next_per_commitment_point,
+ }), None, None, None, RAACommitmentOrder::CommitmentFirst));
+ }
+