peer+server: wait until peer is active to begin channel opening process

Without waiting, we would proceed to retrieve the remote peer's
supported features, which may have not been set due to not yet receiving
their Init message.
This commit is contained in:
Wilmer Paulino
2019-10-01 17:35:23 -04:00
parent 43b02d3035
commit cf5dc90d04
2 changed files with 21 additions and 0 deletions

View File

@ -3207,6 +3207,18 @@ func (s *server) OpenChannel(
}
s.mu.RUnlock()
// We'll wait until the peer is active before beginning the channel
// opening process.
select {
case <-peer.activeSignal:
case <-peer.quit:
req.err <- fmt.Errorf("peer %x disconnected", pubKeyBytes)
return req.updates, req.err
case <-s.quit:
req.err <- ErrServerShuttingDown
return req.updates, req.err
}
// If the fee rate wasn't specified, then we'll use a default
// confirmation target.
if req.fundingFeePerKw == 0 {