lnwallet: account for de-sync'd channels within closeObserver
This commit adds an additional case of the closeObserver that will properly handle the case of a channel being closed by a de-sync’d commitment transaction from the PoV of the local node. In the case of a minor 1-state divergence, the commitment transaction broadcast by the remote node will be 1 state ahead of the commitment transaction we have locally. This should be seen as a regular unilateral close as they remote peer didn’t violate the channel contract in any way. We address this case by changing the `==` to a `>=`.
This commit is contained in:
parent
857c11c273
commit
f2e077c10c
@ -845,7 +845,7 @@ func (lc *LightningChannel) closeObserver(channelCloseNtfn *chainntnfs.SpendEven
|
|||||||
// caller/maintainer of this channel.
|
// caller/maintainer of this channel.
|
||||||
case <-lc.quit:
|
case <-lc.quit:
|
||||||
// As we're exiting before the spend notification has been
|
// As we're exiting before the spend notification has been
|
||||||
// triggered, we'll cancel the notificaiton intent so the
|
// triggered, we'll cancel the notification intent so the
|
||||||
// ChainNotiifer can free up the resources.
|
// ChainNotiifer can free up the resources.
|
||||||
channelCloseNtfn.Cancel()
|
channelCloseNtfn.Cancel()
|
||||||
return
|
return
|
||||||
@ -884,7 +884,13 @@ func (lc *LightningChannel) closeObserver(channelCloseNtfn *chainntnfs.SpendEven
|
|||||||
// state, then they've initiated a unilateral close. So we'll trigger
|
// state, then they've initiated a unilateral close. So we'll trigger
|
||||||
// the unilateral close signal so subscribers can clean up the state as
|
// the unilateral close signal so subscribers can clean up the state as
|
||||||
// necessary.
|
// necessary.
|
||||||
case broadcastStateNum == currentStateNum:
|
//
|
||||||
|
// We'll also handle the case of the remote party broadcasting their
|
||||||
|
// commitment transaction which is one height above ours. This case an
|
||||||
|
// arise when we initiate a state transition, but the remote party has
|
||||||
|
// a fail crash _after_ accepting the new state, but _before_ sending
|
||||||
|
// their signature to us.
|
||||||
|
case broadcastStateNum >= currentStateNum:
|
||||||
walletLog.Infof("Unilateral close of ChannelPoint(%v) "+
|
walletLog.Infof("Unilateral close of ChannelPoint(%v) "+
|
||||||
"detected", lc.channelState.ChanID)
|
"detected", lc.channelState.ChanID)
|
||||||
|
|
||||||
@ -927,7 +933,6 @@ func (lc *LightningChannel) closeObserver(channelCloseNtfn *chainntnfs.SpendEven
|
|||||||
// channel to allow the observer the use the breach retribution
|
// channel to allow the observer the use the breach retribution
|
||||||
// to sweep ALL funds.
|
// to sweep ALL funds.
|
||||||
lc.ContractBreach <- retribution
|
lc.ContractBreach <- retribution
|
||||||
case broadcastStateNum > currentStateNum:
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user