mirror of
https://github.com/lightninglabs/loop
synced 2024-11-13 13:10:30 +00:00
5b732d9012
This allows Loop users to further improve their privacy by not revealing their source IP address. Note that the identity of the lnd node behind Loop can still be revealed when performing a Loop In due to the swap server extending an off-chain HTLC to the user. Onion addresses don't yet exist for the swap servers, but they will be added at a later time.
41 lines
877 B
Go
41 lines
877 B
Go
package loopd
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/btcsuite/btcutil"
|
|
"github.com/lightninglabs/loop"
|
|
"github.com/lightninglabs/loop/lndclient"
|
|
)
|
|
|
|
// getClient returns an instance of the swap client.
|
|
func getClient(config *config, lnd *lndclient.LndServices) (*loop.Client,
|
|
func(), error) {
|
|
|
|
storeDir, err := getStoreDir(config.Network)
|
|
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),
|
|
)
|
|
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
|
|
}
|