Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
package lndmon

import (
"github.com/btcsuite/btcutil"
"github.com/lightninglabs/lndmon/collectors"
)

var (
// defaultMacaroonDir is the default path that we use to point lndmon
// to our macaroon. This default works for using lndmon in our docker
// compose setup.
defaultMacaroonDir = btcutil.AppDataDir("lnd", false)

// defaultMacaroon is the default macaroon that we use for lndmon.
defaultMacaroon = "readonly.macaroon"
)

type lndConfig struct {
// Host is the RPC address of the lnd instance that lndmon is connecting
// to.
Expand All @@ -15,6 +26,9 @@ type lndConfig struct {
// MacaroonDir is the path to lnd macaroons.
MacaroonDir string `long:"macaroondir" description:"Path to lnd macaroons"`

// MacaroonName is the name of the macaroon in macaroon dir to use.
MacaroonName string `long:"macaroonname" description:"The name of our macaroon in macaroon dir to use."`

// TLSPath is the path to the lnd TLS certificate.
TLSPath string `long:"tlspath" description:"Path to lnd tls certificate"`
}
Expand All @@ -34,8 +48,10 @@ type config struct {
var defaultConfig = config{
Prometheus: collectors.DefaultConfig(),
Lnd: &lndConfig{
Host: "localhost:10009",
Network: "mainnet",
Host: "localhost:10009",
Network: "mainnet",
MacaroonDir: defaultMacaroonDir,
MacaroonName: defaultMacaroon,
},
}

Expand Down
11 changes: 7 additions & 4 deletions lndmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package lndmon
import (
"fmt"
"os"
"path/filepath"

flags "github.com/jessevdk/go-flags"
"github.com/lightninglabs/lndclient"
Expand Down Expand Up @@ -37,10 +38,12 @@ func start() error {
// Initialize our lnd client, requiring at least lnd v0.11.
lnd, err := lndclient.NewLndServices(
&lndclient.LndServicesConfig{
LndAddress: cfg.Lnd.Host,
Network: lndclient.Network(cfg.Lnd.Network),
CustomMacaroonPath: "/root/.lnd/readonly.macaroon",
TLSPath: cfg.Lnd.TLSPath,
LndAddress: cfg.Lnd.Host,
Network: lndclient.Network(cfg.Lnd.Network),
CustomMacaroonPath: filepath.Join(
cfg.Lnd.MacaroonDir, cfg.Lnd.MacaroonName,
),
TLSPath: cfg.Lnd.TLSPath,
CheckVersion: &verrpc.Version{
AppMajor: 0,
AppMinor: 11,
Expand Down