diff --git a/htlcswitch/link.go b/htlcswitch/link.go index bd3bdf69..516b8243 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -322,7 +322,26 @@ func (l *channelLink) htlcManager() { // TODO(roasbeef): fail chan in case of protocol violation - // TODO(roasbeef): resend funding locked if state zero + // If the number of updates on this channel has been zero, we should + // resend the fundingLocked message. This is because in this case we + // cannot be sure if the peer really received the last fundingLocked we + // sent, so resend now. + if l.channel.StateSnapshot().NumUpdates == 0 { + log.Debugf("Resending fundingLocked message to peer.") + + nextRevocation, err := l.channel.NextRevocationKey() + if err != nil { + log.Errorf("unable to create next revocation: %v", err) + } + + fundingLockedMsg := lnwire.NewFundingLocked(l.ChanID(), + nextRevocation) + err = l.cfg.Peer.SendMessage(fundingLockedMsg) + if err != nil { + log.Errorf("failed resending fundingLocked to peer: %v", + err) + } + } out: for { diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 47b3e24a..c437cc57 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -280,6 +280,9 @@ func (s *mockServer) readHandler(message lnwire.Message) error { targetChan = msg.ChanID case *lnwire.CommitSig: targetChan = msg.ChanID + case *lnwire.FundingLocked: + // Ignore + return nil default: return errors.New("unknown message type") }