breacharbiter: don't watch for channel closes if time locked balance is non-zero
This commit fixes a slight logic error in the breachArbiter. Previously we wouldn’t watch a pending channel for closure if the regular (settled) balance was non-zero. However, this was incorrect, as it’s possible for us to be on the receiving side of a channel force closure. This error would leave certain channels as “pending close zombies” forever until a user manually deleted the entry (or promoted it to be fully closed). To fix this, we now utilize the new `TimeLockedBalance` field to make a better judgment as to if the utxoNursery is watching over a channel or not.
This commit is contained in:
parent
68dbbb046b
commit
459583ca04
@ -139,10 +139,11 @@ func (b *breachArbiter) Start() error {
|
|||||||
}
|
}
|
||||||
for _, pendingClose := range pendingCloseChans {
|
for _, pendingClose := range pendingCloseChans {
|
||||||
// If this channel was force closed, and we have a non-zero
|
// If this channel was force closed, and we have a non-zero
|
||||||
// balance, then the utxoNursery is currently watching over it.
|
// time-locked balance, then the utxoNursery is currently
|
||||||
// As a result we don't need to watch over it.
|
// watching over it. As a result we don't need to watch over
|
||||||
|
// it.
|
||||||
if pendingClose.CloseType == channeldb.ForceClose &&
|
if pendingClose.CloseType == channeldb.ForceClose &&
|
||||||
pendingClose.OurBalance != 0 {
|
pendingClose.TimeLockedBalance != 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,13 +483,13 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,
|
|||||||
b.htlcSwitch.CloseLink(chanPoint, CloseBreach)
|
b.htlcSwitch.CloseLink(chanPoint, CloseBreach)
|
||||||
chanInfo := contract.StateSnapshot()
|
chanInfo := contract.StateSnapshot()
|
||||||
closeInfo := &channeldb.ChannelCloseSummary{
|
closeInfo := &channeldb.ChannelCloseSummary{
|
||||||
ChanPoint: *chanPoint,
|
ChanPoint: *chanPoint,
|
||||||
ClosingTXID: breachInfo.BreachTransaction.TxHash(),
|
ClosingTXID: breachInfo.BreachTransaction.TxHash(),
|
||||||
RemotePub: &chanInfo.RemoteIdentity,
|
RemotePub: &chanInfo.RemoteIdentity,
|
||||||
Capacity: chanInfo.Capacity,
|
Capacity: chanInfo.Capacity,
|
||||||
OurBalance: chanInfo.LocalBalance,
|
SettledBalance: chanInfo.LocalBalance,
|
||||||
CloseType: channeldb.BreachClose,
|
CloseType: channeldb.BreachClose,
|
||||||
IsPending: true,
|
IsPending: true,
|
||||||
}
|
}
|
||||||
if err := contract.DeleteState(closeInfo); err != nil {
|
if err := contract.DeleteState(closeInfo); err != nil {
|
||||||
brarLog.Errorf("unable to delete channel state: %v", err)
|
brarLog.Errorf("unable to delete channel state: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user