From 71a837630a1a8c4a6812b79ad60268a6693b8074 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 3 Feb 2018 18:02:14 -0800 Subject: [PATCH] funding: on startup only re-create funding barriers if channel is pending MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit, we fix an existing bug within the funding manager. A channel barrier only needs to be create if upon startup the channel is still pending. Otherwise, we’ll re-create the funding barrier unnecessarily. This can lead to bugs when initiating payments between a channels’ lock in and when it’s announced to the together network. If during this period, a user attempts a payment, then the response won’t be archived, as the grouting will be blocked waiting on the channel barrier to close. To fix this, we only re-create the barrier if the channel hasn’t been confirmed. This eliminates one source of reported “stuck payments”. --- fundingmanager.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index d9ea77bd..91e34e22 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -467,14 +467,16 @@ func (f *fundingManager) Start() error { fndgLog.Debugf("channel (%v) with opening state %v found", chanID, channelState) - // Set up the channel barriers again, to make sure - // waitUntilChannelOpen correctly waits until the opening - // process is completely over. - f.barrierMtx.Lock() - fndgLog.Tracef("Loading pending ChannelPoint(%v), "+ - "creating chan barrier", channel.FundingOutpoint) - f.newChanBarriers[chanID] = make(chan struct{}) - f.barrierMtx.Unlock() + if channel.IsPending { + // Set up the channel barriers again, to make sure + // waitUntilChannelOpen correctly waits until the + // opening process is completely over. + f.barrierMtx.Lock() + fndgLog.Tracef("Loading pending ChannelPoint(%v), "+ + "creating chan barrier", channel.FundingOutpoint) + f.newChanBarriers[chanID] = make(chan struct{}) + f.barrierMtx.Unlock() + } // If we did find the channel in the opening state database, we // have seen the funding transaction being confirmed, but we