loop/cmd/loopd/utils.go
Oliver Gugger 49cbe9aa63
loopd: add swap server TLS cert path
We need the ability to connect to a swap server that uses
a self-signed certificate. The LSAT proxy cannot proxy insecure
gRPC requests since they don't conform to the HTTP 1.1 standard.
Therefore the LSAT proxy fill only serve TLS connections.
This means, we need the TLS path option to specify the certificate
the test environment LSAT proxy uses.
2019-11-26 09:32:08 +01:00

44 lines
1,016 B
Go

package main
import (
"os"
"path/filepath"
"github.com/lightninglabs/loop"
"github.com/lightninglabs/loop/lndclient"
)
// getLnd returns an instance of the lnd services proxy.
func getLnd(network string, cfg *lndConfig) (*lndclient.GrpcLndServices, error) {
return lndclient.NewLndServices(
cfg.Host, "client", network, cfg.MacaroonDir, cfg.TLSPath,
)
}
// getClient returns an instance of the swap client.
func getClient(network, swapServer string, insecure bool, tlsPathServer string,
lnd *lndclient.LndServices) (*loop.Client, func(), error) {
storeDir, err := getStoreDir(network)
if err != nil {
return nil, nil, err
}
swapClient, cleanUp, err := loop.NewClient(
storeDir, swapServer, insecure, tlsPathServer, lnd,
)
if err != nil {
return nil, nil, err
}
return swapClient, cleanUp, nil
}
func getStoreDir(network string) (string, error) {
dir := filepath.Join(loopDirBase, network)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return "", err
}
return dir, nil
}