mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
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 {
|
||||
// If this channel was force closed, and we have a non-zero
|
||||
// balance, then the utxoNursery is currently watching over it.
|
||||
// As a result we don't need to watch over it.
|
||||
// time-locked balance, then the utxoNursery is currently
|
||||
// watching over it. As a result we don't need to watch over
|
||||
// it.
|
||||
if pendingClose.CloseType == channeldb.ForceClose &&
|
||||
pendingClose.OurBalance != 0 {
|
||||
pendingClose.TimeLockedBalance != 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -482,13 +483,13 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,
|
||||
b.htlcSwitch.CloseLink(chanPoint, CloseBreach)
|
||||
chanInfo := contract.StateSnapshot()
|
||||
closeInfo := &channeldb.ChannelCloseSummary{
|
||||
ChanPoint: *chanPoint,
|
||||
ClosingTXID: breachInfo.BreachTransaction.TxHash(),
|
||||
RemotePub: &chanInfo.RemoteIdentity,
|
||||
Capacity: chanInfo.Capacity,
|
||||
OurBalance: chanInfo.LocalBalance,
|
||||
CloseType: channeldb.BreachClose,
|
||||
IsPending: true,
|
||||
ChanPoint: *chanPoint,
|
||||
ClosingTXID: breachInfo.BreachTransaction.TxHash(),
|
||||
RemotePub: &chanInfo.RemoteIdentity,
|
||||
Capacity: chanInfo.Capacity,
|
||||
SettledBalance: chanInfo.LocalBalance,
|
||||
CloseType: channeldb.BreachClose,
|
||||
IsPending: true,
|
||||
}
|
||||
if err := contract.DeleteState(closeInfo); err != nil {
|
||||
brarLog.Errorf("unable to delete channel state: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user