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:
Olaoluwa Osuntokun 2017-05-14 19:07:08 -07:00
parent 68dbbb046b
commit 459583ca04
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 11 additions and 10 deletions

View File

@ -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)