config: use a single global macaroon database, scope macaroons in datadir
This commit modifies the way that we create the macaroon database, and also create the initial macaroons themselves. Rather than creating a new macaroon DB for each chain, we instead create a single instance for all chains. Additionally, if the datadir has been modified, and the macaroon paths haven’t been modified, the macaroons are now scoped to those paths.
This commit is contained in:
2 files changed
+23
-7
No files matched your search
@@ -38,6 +38,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// TODO(roasbeef): base off of datadir instead?
|
||||
lndHomeDir = btcutil.AppDataDir("lnd", false)
|
||||
defaultConfigFile = filepath.Join(lndHomeDir, defaultConfigFilename)
|
||||
defaultDataDir = filepath.Join(lndHomeDir, defaultDataDirname)
|
||||
@@ -310,6 +311,21 @@ func loadConfig() (*config, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
// namespaced directories.
|
||||
macaroonDatabaseDir = cfg.DataDir
|
||||
|
||||
// If a custom macaroon directory wasn't specified and the data
|
||||
// directory has changed from the default path, then we'll also update
|
||||
// the path for the macaroons to be generated.
|
||||
if cfg.DataDir != defaultDataDir && cfg.AdminMacPath == defaultAdminMacPath {
|
||||
cfg.AdminMacPath = filepath.Join(cfg.DataDir, defaultAdminMacFilename)
|
||||
}
|
||||
if cfg.DataDir != defaultDataDir && cfg.ReadMacPath == defaultReadMacPath {
|
||||
cfg.ReadMacPath = filepath.Join(cfg.DataDir, defaultReadMacFilename)
|
||||
}
|
||||
|
||||
// Append the network type to the data directory so it is "namespaced"
|
||||
// per network. In addition to the block database, there are other
|
||||
// pieces of data that are saved to disk such as address manager state.
|
||||
|
||||
Reference in new issue
Block a user