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.
This commit is contained in:
Olaoluwa Osuntokun 2017-02-24 16:26:39 -08:00
parent 02b7b911fb
commit c1fbcae572
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 7 additions and 1 deletions

View File

@ -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",