mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 02:00:54 +02:00
htlcswith/link: resend fundingLocked from channelLink when numUpdates == 0.
In the case where the channelLink get started and the number of updates on this channel is zero, this means no paymenys has been done using this channel. This might mean that the fundingLocked never was sent successfully, so we resend to make sure this channel gets opened correctly.
This commit is contained in:
@ -322,7 +322,26 @@ func (l *channelLink) htlcManager() {
|
|||||||
|
|
||||||
// TODO(roasbeef): fail chan in case of protocol violation
|
// 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:
|
out:
|
||||||
for {
|
for {
|
||||||
|
@ -280,6 +280,9 @@ func (s *mockServer) readHandler(message lnwire.Message) error {
|
|||||||
targetChan = msg.ChanID
|
targetChan = msg.ChanID
|
||||||
case *lnwire.CommitSig:
|
case *lnwire.CommitSig:
|
||||||
targetChan = msg.ChanID
|
targetChan = msg.ChanID
|
||||||
|
case *lnwire.FundingLocked:
|
||||||
|
// Ignore
|
||||||
|
return nil
|
||||||
default:
|
default:
|
||||||
return errors.New("unknown message type")
|
return errors.New("unknown message type")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user