diff --git a/lndc/conn.go b/lndc/conn.go index 061329f5..06868f50 100644 --- a/lndc/conn.go +++ b/lndc/conn.go @@ -55,8 +55,17 @@ func NewConn(conn net.Conn) *LNDConn { func (c *LNDConn) Dial( myId *btcec.PrivateKey, address string, remoteId []byte) error { var err error - if c.Conn != nil { - return fmt.Errorf("connection already established") + + if !c.ViaPbx { + if c.Conn != nil { + return fmt.Errorf("connection already established") + } + + // First, open the TCP connection itself. + c.Conn, err = net.Dial("tcp", address) + if err != nil { + return err + } } // Before dialing out to the remote host, verify that `remoteId` is either @@ -66,12 +75,6 @@ func (c *LNDConn) Dial( "pubkey hash") } - // First, open the TCP connection itself. - c.Conn, err = net.Dial("tcp", address) - if err != nil { - return err - } - // Calc remote LNId; need this for creating pbx connections just because // LNid is in the struct does not mean it's authed! if len(remoteId) == 20 {