config+lnd: create macaroons files under the network dir
Co-Authored-By: Karl Ranna <karl@karlranna.com>
This commit is contained in:
parent
6ddae25487
commit
9981fd8fa7
12
config.go
12
config.go
@ -768,24 +768,28 @@ func loadConfig() (*config, error) {
|
|||||||
// At this point, we'll save the base data directory in order to ensure
|
// At this point, we'll save the base data directory in order to ensure
|
||||||
// we don't store the macaroon database within any of the chain
|
// we don't store the macaroon database within any of the chain
|
||||||
// namespaced directories.
|
// namespaced directories.
|
||||||
macaroonDatabaseDir = cfg.DataDir
|
networkDir = filepath.Join(
|
||||||
|
cfg.DataDir, defaultChainSubDirname,
|
||||||
|
registeredChains.PrimaryChain().String(),
|
||||||
|
normalizeNetwork(activeNetParams.Name),
|
||||||
|
)
|
||||||
|
|
||||||
// If a custom macaroon directory wasn't specified and the data
|
// If a custom macaroon directory wasn't specified and the data
|
||||||
// directory has changed from the default path, then we'll also update
|
// directory has changed from the default path, then we'll also update
|
||||||
// the path for the macaroons to be generated.
|
// the path for the macaroons to be generated.
|
||||||
if cfg.DataDir != defaultDataDir && cfg.AdminMacPath == defaultAdminMacPath {
|
if cfg.DataDir != defaultDataDir && cfg.AdminMacPath == defaultAdminMacPath {
|
||||||
cfg.AdminMacPath = filepath.Join(
|
cfg.AdminMacPath = filepath.Join(
|
||||||
cfg.DataDir, defaultAdminMacFilename,
|
networkDir, defaultAdminMacFilename,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if cfg.DataDir != defaultDataDir && cfg.ReadMacPath == defaultReadMacPath {
|
if cfg.DataDir != defaultDataDir && cfg.ReadMacPath == defaultReadMacPath {
|
||||||
cfg.ReadMacPath = filepath.Join(
|
cfg.ReadMacPath = filepath.Join(
|
||||||
cfg.DataDir, defaultReadMacFilename,
|
networkDir, defaultReadMacFilename,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if cfg.DataDir != defaultDataDir && cfg.InvoiceMacPath == defaultInvoiceMacPath {
|
if cfg.DataDir != defaultDataDir && cfg.InvoiceMacPath == defaultInvoiceMacPath {
|
||||||
cfg.InvoiceMacPath = filepath.Join(
|
cfg.InvoiceMacPath = filepath.Join(
|
||||||
cfg.DataDir, defaultInvoiceMacFilename,
|
networkDir, defaultInvoiceMacFilename,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
lnd.go
16
lnd.go
@ -54,14 +54,17 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
//Commit stores the current commit hash of this build. This should be
|
// Commit stores the current commit hash of this build. This should be
|
||||||
//set using -ldflags during compilation.
|
// set using -ldflags during compilation.
|
||||||
Commit string
|
Commit string
|
||||||
|
|
||||||
cfg *config
|
cfg *config
|
||||||
registeredChains = newChainRegistry()
|
registeredChains = newChainRegistry()
|
||||||
|
|
||||||
macaroonDatabaseDir string
|
// networkDir is the path to the directory of the currently active
|
||||||
|
// network. This path will hold the files related to each different
|
||||||
|
// network.
|
||||||
|
networkDir string
|
||||||
|
|
||||||
// End of ASN.1 time.
|
// End of ASN.1 time.
|
||||||
endOfTime = time.Date(2049, 12, 31, 23, 59, 59, 0, time.UTC)
|
endOfTime = time.Date(2049, 12, 31, 23, 59, 59, 0, time.UTC)
|
||||||
@ -234,8 +237,9 @@ func lndMain() error {
|
|||||||
var macaroonService *macaroons.Service
|
var macaroonService *macaroons.Service
|
||||||
if !cfg.NoMacaroons {
|
if !cfg.NoMacaroons {
|
||||||
// Create the macaroon authentication/authorization service.
|
// Create the macaroon authentication/authorization service.
|
||||||
macaroonService, err = macaroons.NewService(macaroonDatabaseDir,
|
macaroonService, err = macaroons.NewService(
|
||||||
macaroons.IPLockChecker)
|
networkDir, macaroons.IPLockChecker,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
srvrLog.Errorf("unable to create macaroon service: %v", err)
|
srvrLog.Errorf("unable to create macaroon service: %v", err)
|
||||||
return err
|
return err
|
||||||
@ -708,7 +712,7 @@ func waitForWalletPassword(grpcEndpoints, restEndpoints []net.Addr,
|
|||||||
// deleted within it and recreated when successfully changing the
|
// deleted within it and recreated when successfully changing the
|
||||||
// wallet's password.
|
// wallet's password.
|
||||||
macaroonFiles := []string{
|
macaroonFiles := []string{
|
||||||
filepath.Join(macaroonDatabaseDir, macaroons.DBFilename),
|
filepath.Join(networkDir, macaroons.DBFilename),
|
||||||
cfg.AdminMacPath, cfg.ReadMacPath, cfg.InvoiceMacPath,
|
cfg.AdminMacPath, cfg.ReadMacPath, cfg.InvoiceMacPath,
|
||||||
}
|
}
|
||||||
pwService := walletunlocker.New(
|
pwService := walletunlocker.New(
|
||||||
|
Loading…
Reference in New Issue
Block a user