chancloser: move nil MarkCoopBroadcasted to BeginNegotiation

This commit is contained in:
Keagan McClelland 2023-12-14 19:03:59 -08:00
parent 1b0f97a483
commit 3aceeea4f3

View file

@ -345,16 +345,6 @@ func (c *ChanCloser) initChanShutdown() (*lnwire.Shutdown, error) {
c.chanPoint, err)
}
// Before continuing, mark the channel as cooperatively closed with a
// nil txn. Even though we haven't negotiated the final txn, this
// guarantees that our listchannels rpc will be externally consistent,
// and reflect that the channel is being shutdown by the time the
// closing request returns.
err := c.cfg.Channel.MarkCoopBroadcasted(nil, c.locallyInitiated)
if err != nil {
return nil, err
}
chancloserLog.Infof("ChannelPoint(%v): sending shutdown message",
c.chanPoint)
@ -627,6 +617,18 @@ func (c *ChanCloser) BeginNegotiation() (
// compute what our max/ideal fee will be.
c.initFeeBaseline()
// Before continuing, mark the channel as cooperatively closed
// with a nil txn. Even though we haven't negotiated the final
// txn, this guarantees that our listchannels rpc will be
// externally consistent, and reflect that the channel is being
// shutdown by the time the closing request returns.
err := c.cfg.Channel.MarkCoopBroadcasted(
nil, c.locallyInitiated,
)
if err != nil {
return noClosingSigned, err
}
// At this point, we can now start the fee negotiation state, by
// constructing and sending our initial signature for what we
// think the closing transaction should look like.