From 425afd28eaec63bb249c06511b075ddb89f38611 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 6 Sep 2019 13:14:39 +0200 Subject: [PATCH] contractcourt/chain_arbitrator: republish closeTx for open channels --- contractcourt/chain_arbitrator.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index b3cd497d..44035b06 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -412,6 +412,36 @@ func (c *ChainArbitrator) Start() error { } c.activeChannels[chanPoint] = channelArb + + // If the channel has had its commitment broadcasted already, + // republish it in case it didn't propagate. + if !channel.HasChanStatus( + channeldb.ChanStatusCommitBroadcasted, + ) { + continue + } + + closeTx, err := channel.BroadcastedCommitment() + switch { + + // This can happen for channels that had their closing tx + // published before we started storing it to disk. + case err == channeldb.ErrNoCloseTx: + log.Warnf("Channel %v is in state CommitBroadcasted, "+ + "but no closing tx to re-publish...", chanPoint) + continue + + case err != nil: + return err + } + + log.Infof("Re-publishing closing tx(%v) for channel %v", + closeTx.TxHash(), chanPoint) + err = c.cfg.PublishTx(closeTx) + if err != nil && err != lnwallet.ErrDoubleSpend { + log.Warnf("Unable to broadcast close tx(%v): %v", + closeTx.TxHash(), err) + } } // In addition to the channels that we know to be open, we'll also