diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index c15d855e7..42593537d 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -821,6 +821,16 @@ func (c *ChannelArbitrator) stateStep( } closeTx = closeSummary.CloseTx + // Before publishing the transaction, we store it to the + // database, such that we can re-publish later in case it + // didn't propagate. + if err := c.cfg.MarkCommitmentBroadcasted(closeTx); err != nil { + log.Errorf("ChannelArbitrator(%v): unable to "+ + "mark commitment broadcasted: %v", + c.cfg.ChanPoint, err) + return StateError, closeTx, err + } + // With the close transaction in hand, broadcast the // transaction to the network, thereby entering the post // channel resolution state. @@ -840,12 +850,6 @@ func (c *ChannelArbitrator) stateStep( } } - if err := c.cfg.MarkCommitmentBroadcasted(closeTx); err != nil { - log.Errorf("ChannelArbitrator(%v): unable to "+ - "mark commitment broadcasted: %v", - c.cfg.ChanPoint, err) - } - // We go to the StateCommitmentBroadcasted state, where we'll // be waiting for the commitment to be confirmed. nextState = StateCommitmentBroadcasted