Skip to content

Commit e8d1bca

Browse files
authored
Merge pull request #62 from guggero/config-fix
config+shushtar: check config after loading lnd.conf
2 parents dee402f + d2b10d6 commit e8d1bca

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ $ ./shushtar \
9696
--faraday.min_monitored=48h
9797
```
9898

99-
You can also store the configuration in a persistent `lnd.conf` file so you do not need to type in the command line arguments every time you start the server. Just remember to use the appropriate prefixes as necessary.
99+
You can also store the configuration in a persistent `lnd.conf` file so you do
100+
not need to type in the command line arguments every time you start the server.
101+
Just remember to use the appropriate prefixes as necessary.
102+
103+
Also. make sure to include the `lnd` general options in the `[Application Options]`
104+
section because the section name `[Lnd]` is not unique anymore because of how we
105+
combine the configurations of all daemons. This will hopefully be fixed in a
106+
future release.
100107

101108
Example `lnd.conf`:
102109

@@ -106,7 +113,6 @@ httpslisten=0.0.0.0:443
106113
letsencrypt=1
107114
letsencrypthost=loop.merchant.com
108115
109-
[Lnd]
110116
lnd.lnddir=~/.lnd
111117
lnd.alias=merchant
112118
lnd.externalip=loop.merchant.com

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)