From 923cbe62a0806166b16ea159631552fc155d62c4 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 23 Nov 2017 13:41:42 -0600 Subject: [PATCH] breacharbiter: also cancel the channel's observer in case of close, or hand-off --- breacharbiter.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/breacharbiter.go b/breacharbiter.go index df941450..73f9a15c 100644 --- a/breacharbiter.go +++ b/breacharbiter.go @@ -228,10 +228,10 @@ func (b *breachArbiter) Start() error { // to be managed by the contractObserver. chanPoint := chanState.FundingOutpoint if closeSummary, ok := closeSummaries[chanPoint]; ok { - // Since this channel should not be open, we immediately - // notify the HTLC switch that this link should be - // closed, and that all activity on the link should - // cease. + // Since this channel should not be open, we + // immediately notify the HTLC switch that this link + // should be closed, and that all activity on the link + // should cease. b.cfg.CloseLink(&chanState.FundingOutpoint, htlcswitch.CloseBreach) @@ -649,6 +649,7 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel, // A read from this channel indicates that the contract has been // settled cooperatively so we exit as our duties are no longer needed. case <-settleSignal: + contract.CancelObserver() contract.Stop() return @@ -667,6 +668,10 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel, } }() + b.cfg.CloseLink(chanPoint, htlcswitch.CloseBreach) + contract.CancelObserver() + contract.Stop() + // Next, we'll launch a goroutine to wait until the closing // transaction has been confirmed so we can mark the contract // as resolved in the database. This go routine is _not_ tracked