loopd: use proper default swap server address

This commit fixes the bug that caused running loopd on testnet to
connect to the mainnet swap server.
pull/51/head
Joost Jager 5 years ago
parent 56ab811f62
commit ca3cfc1431
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -28,7 +28,6 @@ const (
var defaultConfig = config{
Network: "mainnet",
SwapServer: mainnetServer,
RPCListen: "localhost:11010",
RESTListen: "localhost:8081",
Insecure: false,

@ -2,6 +2,7 @@ package main
import (
"context"
"errors"
"fmt"
"net"
"net/http"
@ -26,13 +27,21 @@ func daemon(config *config) error {
}
defer lnd.Close()
// If the user is targeting the testnet network, and they haven't
// specified new swap server, then we'll point towards the testnet swap
// server rather than the mainnet endpoint.
if config.Network == "testnet" && config.SwapServer == "" {
config.SwapServer = testnetServer
// If no swap server is specified, use the default addresses for mainnet
// and testnet.
if config.SwapServer == "" {
switch config.Network {
case "mainnet":
config.SwapServer = mainnetServer
case "testnet":
config.SwapServer = testnetServer
default:
return errors.New("no swap server address specified")
}
}
logger.Infof("Swap server address: %v", config.SwapServer)
// Create an instance of the loop client library.
swapClient, cleanup, err := getClient(
config.Network, config.SwapServer, config.Insecure,

Loading…
Cancel
Save