diff --git a/contractcourt/chain_watcher.go b/contractcourt/chain_watcher.go index 85eddf07..a79b7af9 100644 --- a/contractcourt/chain_watcher.go +++ b/contractcourt/chain_watcher.go @@ -320,22 +320,35 @@ func (c *chainWatcher) closeObserver(spendNtfn *chainntnfs.SpendEvent) { return } - // If this is our commitment transaction, then we can - // exit here as we don't have any further processing we - // need to do (we can't cheat ourselves :p). - commitmentHash := localCommit.CommitTx.TxHash() - isOurCommitment := commitSpend.SpenderTxHash.IsEqual( - &commitmentHash, + // If this channel has been recovered, then we'll modify our + // behavior as it isn't possible for us to close out the + // channel off-chain ourselves. It can only be the remote party + // force closing, or a cooperative closure we signed off on + // before losing data getting confirmed in the chain. + isRecoveredChan := c.cfg.chanState.HasChanStatus( + channeldb.ChanStatusRestored, ) - if isOurCommitment { - if err := c.dispatchLocalForceClose( - commitSpend, *localCommit, - ); err != nil { - log.Errorf("unable to handle local"+ - "close for chan_point=%v: %v", - c.cfg.chanState.FundingOutpoint, err) + + // If we're not recovering this channel, and this is our + // commitment transaction, then we can exit here as we don't + // have any further processing we need to do (we can't cheat + // ourselves :p). + if !isRecoveredChan { + commitmentHash := localCommit.CommitTx.TxHash() + isOurCommitment := commitSpend.SpenderTxHash.IsEqual( + &commitmentHash, + ) + + if isOurCommitment { + if err := c.dispatchLocalForceClose( + commitSpend, *localCommit, + ); err != nil { + log.Errorf("unable to handle local"+ + "close for chan_point=%v: %v", + c.cfg.chanState.FundingOutpoint, err) + } + return } - return } // Next, we'll check to see if this is a cooperative channel diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 9e620b94..02ca4160 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -3504,7 +3504,7 @@ func (lc *LightningChannel) ProcessChanSyncMsg( // Alternatively, if their height is two beyond what we know their best // height to be, then they're holding onto two commitments, and the - // highest unrevoked point it their next revocation. + // highest unrevoked point is their next revocation. // // TODO(roasbeef): verify this in the spec... case msg.NextLocalCommitHeight == remoteTailHeight+2: