peer/lnwallet: persist shutdown info on send

In this commit, we start persisting shutdown info when we send the
Shutdown message. When starting up a link, we also first check if we
have previously persisted Shutdown info and if we have, we start the
link in shutdown mode meaning that it will not accept any new outgoing
HTLC additions and it will queue the shutdown message after any pending
CommitSig has been sent.
This commit is contained in:
Elle Mouton
2024-02-06 19:11:26 +02:00
parent 5de7792520
commit 785790abed
3 changed files with 114 additions and 38 deletions

View File

@@ -356,6 +356,17 @@ func (c *ChanCloser) initChanShutdown() (*lnwire.Shutdown, error) {
chancloserLog.Infof("ChannelPoint(%v): sending shutdown message",
c.chanPoint)
// At this point, we persist any relevant info regarding the Shutdown
// message we are about to send in order to ensure that if a
// re-establish occurs then we will re-send the same Shutdown message.
shutdownInfo := channeldb.NewShutdownInfo(
c.localDeliveryScript, c.locallyInitiated,
)
err := c.cfg.Channel.MarkShutdownSent(shutdownInfo)
if err != nil {
return nil, err
}
return shutdown, nil
}