loopd: group and clarify swap server parameters

pull/230/head
Joost Jager 4 years ago
parent efcf5eee8f
commit b61b886c16
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -91,8 +91,8 @@ type ClientConfig struct {
// connection. // connection.
ProxyAddress string ProxyAddress string
// Insecure skips TLS when set. // SwapServerNoTLS skips TLS for the swap server connection when set.
Insecure bool SwapServerNoTLS bool
// TLSPathServer is the path to the TLS certificate that is required to // TLSPathServer is the path to the TLS certificate that is required to
// connect to the server. // connect to the server.

@ -26,17 +26,22 @@ type lndConfig struct {
TLSPath string `long:"tlspath" description:"Path to lnd tls certificate"` TLSPath string `long:"tlspath" description:"Path to lnd tls certificate"`
} }
type loopServerConfig struct {
Host string `long:"host" description:"Loop server address host:port"`
Proxy string `long:"proxy" description:"The host:port of a SOCKS proxy through which all connections to the loop server will be established over"`
NoTLS bool `long:"notls" description:"Disable tls for communication to the loop server [testing only]"`
TLSPath string `long:"tlspath" description:"Path to loop server tls certificate [testing only]"`
}
type viewParameters struct{} type viewParameters struct{}
type Config struct { type Config struct {
ShowVersion bool `long:"version" description:"Display version information and exit"` ShowVersion bool `long:"version" description:"Display version information and exit"`
Insecure bool `long:"insecure" description:"disable tls"` Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"`
Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"` RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
SwapServer string `long:"swapserver" description:"swap server address host:port"` RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
TLSPathSwapSrv string `long:"tlspathswapserver" description:"Path to swap server tls certificate. Only needed if the swap server uses a self-signed certificate."` CORSOrigin string `long:"corsorigin" description:"The value to send in the Access-Control-Allow-Origin header. Header will be omitted if empty."`
RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
CORSOrigin string `long:"corsorigin" description:"The value to send in the Access-Control-Allow-Origin header. Header will be omitted if empty."`
LogDir string `long:"logdir" description:"Directory to log output."` LogDir string `long:"logdir" description:"Directory to log output."`
MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"` MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
@ -48,8 +53,9 @@ type Config struct {
LoopOutMaxParts uint32 `long:"loopoutmaxparts" description:"The maximum number of payment parts that may be used for a loop out swap."` LoopOutMaxParts uint32 `long:"loopoutmaxparts" description:"The maximum number of payment parts that may be used for a loop out swap."`
Lnd *lndConfig `group:"lnd" namespace:"lnd"` Lnd *lndConfig `group:"lnd" namespace:"lnd"`
Proxy string `long:"proxy" description:"The host:port of a SOCKS proxy through which all connections to the swap server will be established over."`
Server *loopServerConfig `group:"server" namespace:"server"`
View viewParameters `command:"view" alias:"v" description:"View all swaps in the database. This command can only be executed when loopd is not running."` View viewParameters `command:"view" alias:"v" description:"View all swaps in the database. This command can only be executed when loopd is not running."`
} }
@ -62,10 +68,12 @@ const (
// DefaultConfig returns all default values for the Config struct. // DefaultConfig returns all default values for the Config struct.
func DefaultConfig() Config { func DefaultConfig() Config {
return Config{ return Config{
Network: "mainnet", Network: "mainnet",
RPCListen: "localhost:11010", RPCListen: "localhost:11010",
RESTListen: "localhost:8081", RESTListen: "localhost:8081",
Insecure: false, Server: &loopServerConfig{
NoTLS: false,
},
LogDir: defaultLogDir, LogDir: defaultLogDir,
MaxLogFiles: defaultMaxLogFiles, MaxLogFiles: defaultMaxLogFiles,
MaxLogFileSize: defaultMaxLogFileSize, MaxLogFileSize: defaultMaxLogFileSize,

@ -269,20 +269,20 @@ func (d *Daemon) startWebServers() error {
func (d *Daemon) initialize() error { func (d *Daemon) initialize() error {
// If no swap server is specified, use the default addresses for mainnet // If no swap server is specified, use the default addresses for mainnet
// and testnet. // and testnet.
if d.cfg.SwapServer == "" { if d.cfg.Server.Host == "" {
// TODO(wilmer): Use onion service addresses when proxy is // TODO(wilmer): Use onion service addresses when proxy is
// active. // active.
switch d.cfg.Network { switch d.cfg.Network {
case "mainnet": case "mainnet":
d.cfg.SwapServer = mainnetServer d.cfg.Server.Host = mainnetServer
case "testnet": case "testnet":
d.cfg.SwapServer = testnetServer d.cfg.Server.Host = testnetServer
default: default:
return errors.New("no swap server address specified") return errors.New("no swap server address specified")
} }
} }
log.Infof("Swap server address: %v", d.cfg.SwapServer) log.Infof("Swap server address: %v", d.cfg.Server.Host)
// Create an instance of the loop client library. // Create an instance of the loop client library.
swapclient, clientCleanup, err := getClient(d.cfg, &d.lnd.LndServices) swapclient, clientCleanup, err := getClient(d.cfg, &d.lnd.LndServices)

@ -19,10 +19,10 @@ func getClient(config *Config, lnd *lndclient.LndServices) (*loop.Client,
} }
clientConfig := &loop.ClientConfig{ clientConfig := &loop.ClientConfig{
ServerAddress: config.SwapServer, ServerAddress: config.Server.Host,
ProxyAddress: config.Proxy, ProxyAddress: config.Server.Proxy,
Insecure: config.Insecure, SwapServerNoTLS: config.Server.NoTLS,
TLSPathServer: config.TLSPathSwapSrv, TLSPathServer: config.Server.TLSPath,
Lnd: lnd, Lnd: lnd,
MaxLsatCost: btcutil.Amount(config.MaxLSATCost), MaxLsatCost: btcutil.Amount(config.MaxLSATCost),
MaxLsatFee: btcutil.Amount(config.MaxLSATFee), MaxLsatFee: btcutil.Amount(config.MaxLSATFee),

@ -70,7 +70,7 @@ func newSwapServerClient(cfg *ClientConfig, lsatStore lsat.Store) (
cfg.MaxLsatFee, cfg.MaxLsatFee,
) )
serverConn, err := getSwapServerConn( serverConn, err := getSwapServerConn(
cfg.ServerAddress, cfg.ProxyAddress, cfg.Insecure, cfg.ServerAddress, cfg.ProxyAddress, cfg.SwapServerNoTLS,
cfg.TLSPathServer, clientInterceptor, cfg.TLSPathServer, clientInterceptor,
) )
if err != nil { if err != nil {

Loading…
Cancel
Save