Skip to content

Commit 3fb41b4

Browse files
committed
config+shushtar: check config after loading lnd.conf
1 parent dee402f commit 3fb41b4

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
faradayDefaultConfig = faraday.DefaultConfig()
3434
loopDefaultConfig = loopd.DefaultConfig()
3535

36-
defaultLetsEncryptDir = filepath.Join(lnd.DefaultLndDir, "letsencrypt")
36+
defaultLetsEncryptDir = "letsencrypt"
3737
)
3838

3939
// Config is the main configuration struct of shushtar. It contains all config
@@ -58,7 +58,6 @@ type Config struct {
5858
func defaultConfig() *Config {
5959
return &Config{
6060
HTTPSListen: defaultHTTPSListen,
61-
LetsEncryptDir: defaultLetsEncryptDir,
6261
Lnd: &lndDefaultConfig,
6362
Faraday: &faradayDefaultConfig,
6463
Loop: &loopDefaultConfig,

shushtar.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/base64"
77
"errors"
88
"fmt"
9+
"github.com/lightningnetwork/lnd/lncfg"
910
"io/ioutil"
1011
"net"
1112
"net/http"
@@ -22,7 +23,6 @@ import (
2223
"github.com/lightninglabs/loop/loopd"
2324
"github.com/lightninglabs/loop/looprpc"
2425
"github.com/lightningnetwork/lnd"
25-
"github.com/lightningnetwork/lnd/lncfg"
2626
"github.com/lightningnetwork/lnd/lnrpc"
2727
"github.com/lightningnetwork/lnd/lntest/wait"
2828
"github.com/lightningnetwork/lnd/macaroons"
@@ -100,7 +100,19 @@ func (g *Shushtar) Run() error {
100100
return err
101101
}
102102

103+
// Load the configuration, and parse any command line options. This
104+
// function will also set up logging properly.
105+
g.cfg.Lnd, err = loadLndConfig(g.cfg)
106+
if err != nil {
107+
return err
108+
}
109+
103110
// Validate the shushtar config options.
111+
if g.cfg.LetsEncryptDir == "" {
112+
g.cfg.LetsEncryptDir = filepath.Join(
113+
g.cfg.Lnd.LndDir, defaultLetsEncryptDir,
114+
)
115+
}
104116
g.cfg.LetsEncryptDir = lncfg.CleanAndExpandPath(g.cfg.LetsEncryptDir)
105117
if g.cfg.LetsEncrypt && g.cfg.LetsEncryptHost == "" {
106118
return fmt.Errorf("host must be set when using let's encrypt")
@@ -113,14 +125,7 @@ func (g *Shushtar) Run() error {
113125
return fmt.Errorf("please set a strong password for the UI, "+
114126
"at least %d characters long", uiPasswordMinLength)
115127
}
116-
117-
// Load the configuration, and parse any command line options. This
118-
// function will also set up logging properly.
119-
g.cfg.Lnd, err = loadLndConfig(g.cfg)
120-
if err != nil {
121-
return err
122-
}
123-
128+
124129
// Initiate our listeners. For now, we only support listening on one
125130
// port at a time because we can only pass in one pre-configured RPC
126131
// listener into lnd.

0 commit comments

Comments
 (0)