contractcourt: only look for local force close for non-recovered channel
In this commit, we modify the main `closeObserver` dispatch loop to only look for the local force close if we didn't recover the channel. We do this, as for a recovered channel, it isn't possible for us to force close from a recovered channel.
This commit is contained in:
parent
b491488c6f
commit
c722f2c064
@ -320,13 +320,25 @@ func (c *chainWatcher) closeObserver(spendNtfn *chainntnfs.SpendEvent) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is our commitment transaction, then we can
|
// If this channel has been recovered, then we'll modify our
|
||||||
// exit here as we don't have any further processing we
|
// behavior as it isn't possible for us to close out the
|
||||||
// need to do (we can't cheat ourselves :p).
|
// 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 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()
|
commitmentHash := localCommit.CommitTx.TxHash()
|
||||||
isOurCommitment := commitSpend.SpenderTxHash.IsEqual(
|
isOurCommitment := commitSpend.SpenderTxHash.IsEqual(
|
||||||
&commitmentHash,
|
&commitmentHash,
|
||||||
)
|
)
|
||||||
|
|
||||||
if isOurCommitment {
|
if isOurCommitment {
|
||||||
if err := c.dispatchLocalForceClose(
|
if err := c.dispatchLocalForceClose(
|
||||||
commitSpend, *localCommit,
|
commitSpend, *localCommit,
|
||||||
@ -337,6 +349,7 @@ func (c *chainWatcher) closeObserver(spendNtfn *chainntnfs.SpendEvent) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Next, we'll check to see if this is a cooperative channel
|
// Next, we'll check to see if this is a cooperative channel
|
||||||
// closure or not. This is characterized by having an input
|
// closure or not. This is characterized by having an input
|
||||||
|
@ -3504,7 +3504,7 @@ func (lc *LightningChannel) ProcessChanSyncMsg(
|
|||||||
|
|
||||||
// Alternatively, if their height is two beyond what we know their best
|
// Alternatively, if their height is two beyond what we know their best
|
||||||
// height to be, then they're holding onto two commitments, and the
|
// 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...
|
// TODO(roasbeef): verify this in the spec...
|
||||||
case msg.NextLocalCommitHeight == remoteTailHeight+2:
|
case msg.NextLocalCommitHeight == remoteTailHeight+2:
|
||||||
|
Loading…
Reference in New Issue
Block a user