2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-13 13:10:30 +00:00
loop/loopd/utils.go

41 lines
877 B
Go
Raw Normal View History

package loopd
2019-03-06 20:13:50 +00:00
import (
"os"
"path/filepath"
"github.com/btcsuite/btcutil"
"github.com/lightninglabs/loop"
"github.com/lightninglabs/loop/lndclient"
2019-03-06 20:13:50 +00:00
)
// getClient returns an instance of the swap client.
func getClient(config *config, lnd *lndclient.LndServices) (*loop.Client,
func(), error) {
storeDir, err := getStoreDir(config.Network)
2019-03-06 20:13:50 +00:00
if err != nil {
return nil, nil, err
}
swapClient, cleanUp, err := loop.NewClient(
storeDir, config.SwapServer, config.Proxy, config.Insecure,
config.TLSPathSwapSrv, lnd, btcutil.Amount(config.MaxLSATCost),
btcutil.Amount(config.MaxLSATFee),
2019-03-06 20:13:50 +00:00
)
if err != nil {
return nil, nil, err
}
return swapClient, cleanUp, nil
}
func getStoreDir(network string) (string, error) {
2019-03-07 10:37:28 +00:00
dir := filepath.Join(loopDirBase, network)
2019-03-06 20:13:50 +00:00
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return "", err
}
return dir, nil
}