From 55c8741e423e3a24282e88d3ea452351ba818092 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 19 Jun 2018 12:48:11 +0100 Subject: [PATCH 1/2] peer: don't stop nil channel --- peer.go | 1 - 1 file changed, 1 deletion(-) diff --git a/peer.go b/peer.go index 63e83363..b13235f6 100644 --- a/peer.go +++ b/peer.go @@ -314,7 +314,6 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { p.server.cc.signer, p.server.witnessBeacon, dbChan, ) if err != nil { - lnChan.Stop() return err } From b56d922ce21f31cb6dce48506be825e55db80ab8 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 19 Jun 2018 12:48:38 +0100 Subject: [PATCH 2/2] fundingmanager: properly stop channel on error --- fundingmanager.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index df68f0fe..f9269f29 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -1616,9 +1616,7 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) { fndgLog.Errorf("failed creating lnChannel: %v", err) return } - defer func() { - lnChannel.Stop() - }() + defer lnChannel.Stop() err = f.sendFundingLocked(completeChan, lnChannel, shortChanID) if err != nil { @@ -1879,9 +1877,7 @@ func (f *fundingManager) handleFundingConfirmation(completeChan *channeldb.OpenC if err != nil { return err } - defer func() { - lnChannel.Stop() - }() + defer lnChannel.Stop() chanID := lnwire.NewChanIDFromOutPoint(&completeChan.FundingOutpoint) @@ -2224,6 +2220,7 @@ func (f *fundingManager) handleFundingLocked(fmsg *fundingLockedMsg) { err = channel.InitNextRevocation(fmsg.msg.NextPerCommitmentPoint) if err != nil { fndgLog.Errorf("unable to insert next commitment point: %v", err) + channel.Stop() return } @@ -2249,6 +2246,7 @@ func (f *fundingManager) handleFundingLocked(fmsg *fundingLockedMsg) { peer, err := f.cfg.FindPeer(fmsg.peerAddress.IdentityKey) if err != nil { fndgLog.Errorf("Unable to find peer: %v", err) + channel.Stop() return } newChanDone := make(chan struct{})