From f70a59cf2d238b5dd7848bb82de5fab0c3650bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Mon, 29 Nov 2021 08:11:43 +0200 Subject: [PATCH] Ability to read initial config from environment. --- config/default.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/config/default.go b/config/default.go index 5284a5c..9b48361 100644 --- a/config/default.go +++ b/config/default.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "os" "os/user" "path" ) @@ -94,6 +95,18 @@ columns = [ func NewDefault() *Config { usr, _ := user.Current() + lndAddress, present := os.LookupEnv("LND_ADDRESS") + if !present { + lndAddress = "//127.0.0.1:10009" + } + certPath, present := os.LookupEnv("CERT_PATH") + if !present { + certPath = path.Join(usr.HomeDir, ".lnd/tls.cert") + } + macaroonPath, present := os.LookupEnv("MACAROON_PATH") + if !present { + macaroonPath = path.Join(usr.HomeDir, ".lnd/data/chain/bitcoin/mainnet/readonly.macaroon") + } return &Config{ Logger: Logger{ Type: "production", @@ -102,9 +115,9 @@ func NewDefault() *Config { Network: Network{ Name: "lnd", Type: "lnd", - Address: "//127.0.0.1:10009", - Cert: path.Join(usr.HomeDir, ".lnd/tls.cert"), - Macaroon: path.Join(usr.HomeDir, ".lnd/data/chain/bitcoin/mainnet/readonly.macaroon"), + Address: lndAddress, + Cert: certPath, + Macaroon: macaroonPath, MacaroonTimeOut: 60, MaxMsgRecvSize: 52428800, ConnTimeout: 1000000,