peer: fix panic bug in watiForChanToClose

This commit fixes a panic bug in the watiForChanToClose method caused
by a logic error leading to the return value of the function at times
being a nil pointer in the case that an error occurred. We now avoid
such an error by _always_ returning from the function if there’s an
error, but conditionally (in a diff if-clause) sending an error over
the error channel.
This commit is contained in:
Olaoluwa Osuntokun 2017-05-15 17:53:22 -07:00
parent 40a7523b8f
commit 620695542c
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 4 additions and 2 deletions

View File

@ -1069,8 +1069,10 @@ func waitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier,
// TODO(roasbeef): add param for num needed confs
confNtfn, err := notifier.RegisterConfirmationsNtfn(closingTxID, 1,
bestHeight)
if err != nil && errChan != nil {
errChan <- err
if err != nil {
if errChan != nil {
errChan <- err
}
return
}