Skip to content

Commit ca3cfc1

Browse files
committed
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.
1 parent 56ab811 commit ca3cfc1

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

cmd/loopd/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const (
2828

2929
var defaultConfig = config{
3030
Network: "mainnet",
31-
SwapServer: mainnetServer,
3231
RPCListen: "localhost:11010",
3332
RESTListen: "localhost:8081",
3433
Insecure: false,

cmd/loopd/daemon.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"net"
78
"net/http"
@@ -26,13 +27,21 @@ func daemon(config *config) error {
2627
}
2728
defer lnd.Close()
2829

29-
// If the user is targeting the testnet network, and they haven't
30-
// specified new swap server, then we'll point towards the testnet swap
31-
// server rather than the mainnet endpoint.
32-
if config.Network == "testnet" && config.SwapServer == "" {
33-
config.SwapServer = testnetServer
30+
// If no swap server is specified, use the default addresses for mainnet
31+
// and testnet.
32+
if config.SwapServer == "" {
33+
switch config.Network {
34+
case "mainnet":
35+
config.SwapServer = mainnetServer
36+
case "testnet":
37+
config.SwapServer = testnetServer
38+
default:
39+
return errors.New("no swap server address specified")
40+
}
3441
}
3542

43+
logger.Infof("Swap server address: %v", config.SwapServer)
44+
3645
// Create an instance of the loop client library.
3746
swapClient, cleanup, err := getClient(
3847
config.Network, config.SwapServer, config.Insecure,

0 commit comments

Comments
 (0)