From c1fbcae5729e7a08ff8ab374fc94bc3d58ebd76a Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 24 Feb 2017 16:26:39 -0800 Subject: [PATCH] funding: fix bug that marks channel as open when ChainNotifier exist early This commit fixes a bug that resulted from properly failing to do a 2-value read from the confirmation notification channel. If the ChainNotifier was shutting down, then a nil read could be generated which may prematurely mark the channel as open, and also trigger a nil pointer panic exception below when the confDetails are accessed. We fix this issue, by ensuring that we check the second value to see if the channel has been closed or not. --- fundingmanager.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fundingmanager.go b/fundingmanager.go index 6105c5c3..47389591 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -882,7 +882,13 @@ func (f *fundingManager) waitForFundingConfirmation( // Wait until the specified number of confirmations has been reached, // or the wallet signals a shutdown. - confDetails := <-confNtfn.Confirmed + confDetails, ok := <-confNtfn.Confirmed + if !ok { + fndgLog.Infof("ChainNotifier shutting down, cannot complete "+ + "funding flow for ChannelPoint(%v)", + completeChan.FundingOutpoint) + return + } fundingPoint := *completeChan.FundingOutpoint fndgLog.Infof("ChannelPoint(%v) is now active",