mirror of https://github.com/lightninglabs/loop
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
777 B
Go
38 lines
777 B
Go
5 years ago
|
package loopd
|
||
6 years ago
|
|
||
|
import (
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
|
||
6 years ago
|
"github.com/lightninglabs/loop"
|
||
6 years ago
|
"github.com/lightninglabs/loop/lndclient"
|
||
6 years ago
|
)
|
||
|
|
||
|
// getClient returns an instance of the swap client.
|
||
5 years ago
|
func getClient(network, swapServer string, insecure bool, tlsPathServer string,
|
||
6 years ago
|
lnd *lndclient.LndServices) (*loop.Client, func(), error) {
|
||
|
|
||
6 years ago
|
storeDir, err := getStoreDir(network)
|
||
|
if err != nil {
|
||
|
return nil, nil, err
|
||
|
}
|
||
|
|
||
6 years ago
|
swapClient, cleanUp, err := loop.NewClient(
|
||
5 years ago
|
storeDir, swapServer, insecure, tlsPathServer, lnd,
|
||
6 years ago
|
)
|
||
|
if err != nil {
|
||
|
return nil, nil, err
|
||
|
}
|
||
|
|
||
|
return swapClient, cleanUp, nil
|
||
|
}
|
||
|
|
||
|
func getStoreDir(network string) (string, error) {
|
||
6 years ago
|
dir := filepath.Join(loopDirBase, network)
|
||
6 years ago
|
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
|
||
|
return dir, nil
|
||
|
}
|