mirror of
https://github.com/LBRYFoundation/lbcwallet.git
synced 2025-08-23 17:47:29 +00:00
Rename datadir/-b options to appdata/-A.
This removes an inconsistency with the datadir option from btcd, which only set the directory containing the blockchain data and indexes.
This commit is contained in:
parent
3d7b8c6f40
commit
29f31725ee
4 changed files with 36 additions and 24 deletions
|
@ -61,7 +61,7 @@ func walletMain() error {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
dbDir := networkDir(cfg.DataDir, activeNet.Params)
|
dbDir := networkDir(cfg.AppDataDir, activeNet.Params)
|
||||||
loader := wallet.NewLoader(activeNet.Params, dbDir)
|
loader := wallet.NewLoader(activeNet.Params, dbDir)
|
||||||
|
|
||||||
// Create and start HTTP server to serve wallet client connections.
|
// Create and start HTTP server to serve wallet client connections.
|
||||||
|
|
50
config.go
50
config.go
|
@ -33,14 +33,12 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
btcdHomeDir = btcutil.AppDataDir("btcd", false)
|
btcdDefaultCAFile = filepath.Join(btcutil.AppDataDir("btcd", false), "rpc.cert")
|
||||||
btcwalletHomeDir = btcutil.AppDataDir("btcwallet", false)
|
defaultAppDataDir = btcutil.AppDataDir("btcwallet", false)
|
||||||
btcdHomedirCAFile = filepath.Join(btcdHomeDir, "rpc.cert")
|
defaultConfigFile = filepath.Join(defaultAppDataDir, defaultConfigFilename)
|
||||||
defaultConfigFile = filepath.Join(btcwalletHomeDir, defaultConfigFilename)
|
defaultRPCKeyFile = filepath.Join(defaultAppDataDir, "rpc.key")
|
||||||
defaultDataDir = btcwalletHomeDir
|
defaultRPCCertFile = filepath.Join(defaultAppDataDir, "rpc.cert")
|
||||||
defaultRPCKeyFile = filepath.Join(btcwalletHomeDir, "rpc.key")
|
defaultLogDir = filepath.Join(defaultAppDataDir, defaultLogDirname)
|
||||||
defaultRPCCertFile = filepath.Join(btcwalletHomeDir, "rpc.cert")
|
|
||||||
defaultLogDir = filepath.Join(btcwalletHomeDir, defaultLogDirname)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
|
@ -49,7 +47,7 @@ type config struct {
|
||||||
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
|
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
|
||||||
Create bool `long:"create" description:"Create the wallet if it does not exist"`
|
Create bool `long:"create" description:"Create the wallet if it does not exist"`
|
||||||
CreateTemp bool `long:"createtemp" description:"Create a temporary simulation wallet (pass=password) in the data directory indicated; must call with --datadir"`
|
CreateTemp bool `long:"createtemp" description:"Create a temporary simulation wallet (pass=password) in the data directory indicated; must call with --datadir"`
|
||||||
DataDir string `short:"b" long:"datadir" description:"Directory to store wallets and transactions"`
|
AppDataDir string `short:"A" long:"appdata" description:"Application data directory to save wallet database and logs"`
|
||||||
TestNet3 bool `long:"testnet" description:"Use the test Bitcoin network (version 3) (default mainnet)"`
|
TestNet3 bool `long:"testnet" description:"Use the test Bitcoin network (version 3) (default mainnet)"`
|
||||||
SimNet bool `long:"simnet" description:"Use the simulation test network (default mainnet)"`
|
SimNet bool `long:"simnet" description:"Use the simulation test network (default mainnet)"`
|
||||||
NoInitialLoad bool `long:"noinitialload" description:"Defer wallet creation/opening on startup and enable loading wallets over RPC"`
|
NoInitialLoad bool `long:"noinitialload" description:"Defer wallet creation/opening on startup and enable loading wallets over RPC"`
|
||||||
|
@ -93,6 +91,9 @@ type config struct {
|
||||||
// These options will change (and require changes to config files, etc.)
|
// These options will change (and require changes to config files, etc.)
|
||||||
// when the new gRPC server is enabled.
|
// when the new gRPC server is enabled.
|
||||||
ExperimentalRPCListeners []string `long:"experimentalrpclisten" description:"Listen for RPC connections on this interface/port"`
|
ExperimentalRPCListeners []string `long:"experimentalrpclisten" description:"Listen for RPC connections on this interface/port"`
|
||||||
|
|
||||||
|
// Deprecated options
|
||||||
|
DataDir string `short:"D" long:"datadir" default-mask:"-" description:"DEPRECATED -- use appdata instead"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanAndExpandPath expands environement variables and leading ~ in the
|
// cleanAndExpandPath expands environement variables and leading ~ in the
|
||||||
|
@ -100,7 +101,7 @@ type config struct {
|
||||||
func cleanAndExpandPath(path string) string {
|
func cleanAndExpandPath(path string) string {
|
||||||
// Expand initial ~ to OS specific home directory.
|
// Expand initial ~ to OS specific home directory.
|
||||||
if strings.HasPrefix(path, "~") {
|
if strings.HasPrefix(path, "~") {
|
||||||
homeDir := filepath.Dir(btcwalletHomeDir)
|
homeDir := filepath.Dir(defaultAppDataDir)
|
||||||
path = strings.Replace(path, "~", homeDir, 1)
|
path = strings.Replace(path, "~", homeDir, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,13 +212,14 @@ func loadConfig() (*config, []string, error) {
|
||||||
cfg := config{
|
cfg := config{
|
||||||
DebugLevel: defaultLogLevel,
|
DebugLevel: defaultLogLevel,
|
||||||
ConfigFile: defaultConfigFile,
|
ConfigFile: defaultConfigFile,
|
||||||
DataDir: defaultDataDir,
|
AppDataDir: defaultAppDataDir,
|
||||||
LogDir: defaultLogDir,
|
LogDir: defaultLogDir,
|
||||||
WalletPass: wallet.InsecurePubPassphrase,
|
WalletPass: wallet.InsecurePubPassphrase,
|
||||||
RPCKey: defaultRPCKeyFile,
|
RPCKey: defaultRPCKeyFile,
|
||||||
RPCCert: defaultRPCCertFile,
|
RPCCert: defaultRPCCertFile,
|
||||||
LegacyRPCMaxClients: defaultRPCMaxClients,
|
LegacyRPCMaxClients: defaultRPCMaxClients,
|
||||||
LegacyRPCMaxWebsockets: defaultRPCMaxWebsockets,
|
LegacyRPCMaxWebsockets: defaultRPCMaxWebsockets,
|
||||||
|
DataDir: defaultAppDataDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
// A config file in the current directory takes precedence.
|
// A config file in the current directory takes precedence.
|
||||||
|
@ -281,15 +283,25 @@ func loadConfig() (*config, []string, error) {
|
||||||
log.Warnf("%v", configFileError)
|
log.Warnf("%v", configFileError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check deprecated aliases. The new options receive priority when both
|
||||||
|
// are changed from the default.
|
||||||
|
if cfg.DataDir != defaultAppDataDir {
|
||||||
|
fmt.Fprintln(os.Stderr, "datadir option has been replaced by "+
|
||||||
|
"appdata -- please update your config")
|
||||||
|
if cfg.AppDataDir == defaultAppDataDir {
|
||||||
|
cfg.AppDataDir = cfg.DataDir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If an alternate data directory was specified, and paths with defaults
|
// If an alternate data directory was specified, and paths with defaults
|
||||||
// relative to the data dir are unchanged, modify each path to be
|
// relative to the data dir are unchanged, modify each path to be
|
||||||
// relative to the new data dir.
|
// relative to the new data dir.
|
||||||
if cfg.DataDir != defaultDataDir {
|
if cfg.AppDataDir != defaultAppDataDir {
|
||||||
if cfg.RPCKey == defaultRPCKeyFile {
|
if cfg.RPCKey == defaultRPCKeyFile {
|
||||||
cfg.RPCKey = filepath.Join(cfg.DataDir, "rpc.key")
|
cfg.RPCKey = filepath.Join(cfg.AppDataDir, "rpc.key")
|
||||||
}
|
}
|
||||||
if cfg.RPCCert == defaultRPCCertFile {
|
if cfg.RPCCert == defaultRPCCertFile {
|
||||||
cfg.RPCCert = filepath.Join(cfg.DataDir, "rpc.cert")
|
cfg.RPCCert = filepath.Join(cfg.AppDataDir, "rpc.cert")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +350,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
|
|
||||||
// Exit if you try to use a simulation wallet with a standard
|
// Exit if you try to use a simulation wallet with a standard
|
||||||
// data directory.
|
// data directory.
|
||||||
if cfg.DataDir == defaultDataDir && cfg.CreateTemp {
|
if cfg.AppDataDir == defaultAppDataDir && cfg.CreateTemp {
|
||||||
fmt.Fprintln(os.Stderr, "Tried to create a temporary simulation "+
|
fmt.Fprintln(os.Stderr, "Tried to create a temporary simulation "+
|
||||||
"wallet, but failed to specify data directory!")
|
"wallet, but failed to specify data directory!")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -353,7 +365,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the wallet exists or create it when the create flag is set.
|
// Ensure the wallet exists or create it when the create flag is set.
|
||||||
netDir := networkDir(cfg.DataDir, activeNet.Params)
|
netDir := networkDir(cfg.AppDataDir, activeNet.Params)
|
||||||
dbPath := filepath.Join(netDir, walletDbName)
|
dbPath := filepath.Join(netDir, walletDbName)
|
||||||
|
|
||||||
if cfg.CreateTemp && cfg.Create {
|
if cfg.CreateTemp && cfg.Create {
|
||||||
|
@ -469,7 +481,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
} else {
|
} else {
|
||||||
// If CAFile is unset, choose either the copy or local btcd cert.
|
// If CAFile is unset, choose either the copy or local btcd cert.
|
||||||
if cfg.CAFile == "" {
|
if cfg.CAFile == "" {
|
||||||
cfg.CAFile = filepath.Join(cfg.DataDir, defaultCAFilename)
|
cfg.CAFile = filepath.Join(cfg.AppDataDir, defaultCAFilename)
|
||||||
|
|
||||||
// If the CA copy does not exist, check if we're connecting to
|
// If the CA copy does not exist, check if we're connecting to
|
||||||
// a local btcd and switch to its RPC cert if it exists.
|
// a local btcd and switch to its RPC cert if it exists.
|
||||||
|
@ -481,13 +493,13 @@ func loadConfig() (*config, []string, error) {
|
||||||
if !certExists {
|
if !certExists {
|
||||||
if _, ok := localhostListeners[RPCHost]; ok {
|
if _, ok := localhostListeners[RPCHost]; ok {
|
||||||
btcdCertExists, err := cfgutil.FileExists(
|
btcdCertExists, err := cfgutil.FileExists(
|
||||||
btcdHomedirCAFile)
|
btcdDefaultCAFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if btcdCertExists {
|
if btcdCertExists {
|
||||||
cfg.CAFile = btcdHomedirCAFile
|
cfg.CAFile = btcdDefaultCAFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
; The directory to open and save wallet, transaction, and unspent transaction
|
; The directory to open and save wallet, transaction, and unspent transaction
|
||||||
; output files. Two directories, `mainnet` and `testnet` are used in this
|
; output files. Two directories, `mainnet` and `testnet` are used in this
|
||||||
; directory for mainnet and testnet wallets, respectively.
|
; directory for mainnet and testnet wallets, respectively.
|
||||||
; datadir=~/.btcwallet
|
; appdata=~/.btcwallet
|
||||||
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------------
|
; ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -99,13 +99,13 @@ func convertLegacyKeystore(legacyKeyStore *keystore.Store, manager *waddrmgr.Man
|
||||||
// and generates the wallet accordingly. The new wallet will reside at the
|
// and generates the wallet accordingly. The new wallet will reside at the
|
||||||
// provided path.
|
// provided path.
|
||||||
func createWallet(cfg *config) error {
|
func createWallet(cfg *config) error {
|
||||||
dbDir := networkDir(cfg.DataDir, activeNet.Params)
|
dbDir := networkDir(cfg.AppDataDir, activeNet.Params)
|
||||||
loader := wallet.NewLoader(activeNet.Params, dbDir)
|
loader := wallet.NewLoader(activeNet.Params, dbDir)
|
||||||
|
|
||||||
// When there is a legacy keystore, open it now to ensure any errors
|
// When there is a legacy keystore, open it now to ensure any errors
|
||||||
// don't end up exiting the process after the user has spent time
|
// don't end up exiting the process after the user has spent time
|
||||||
// entering a bunch of information.
|
// entering a bunch of information.
|
||||||
netDir := networkDir(cfg.DataDir, activeNet.Params)
|
netDir := networkDir(cfg.AppDataDir, activeNet.Params)
|
||||||
keystorePath := filepath.Join(netDir, keystore.Filename)
|
keystorePath := filepath.Join(netDir, keystore.Filename)
|
||||||
var legacyKeyStore *keystore.Store
|
var legacyKeyStore *keystore.Store
|
||||||
_, err := os.Stat(keystorePath)
|
_, err := os.Stat(keystorePath)
|
||||||
|
@ -207,7 +207,7 @@ func createSimulationWallet(cfg *config) error {
|
||||||
// Public passphrase is the default.
|
// Public passphrase is the default.
|
||||||
pubPass := []byte(wallet.InsecurePubPassphrase)
|
pubPass := []byte(wallet.InsecurePubPassphrase)
|
||||||
|
|
||||||
netDir := networkDir(cfg.DataDir, activeNet.Params)
|
netDir := networkDir(cfg.AppDataDir, activeNet.Params)
|
||||||
|
|
||||||
// Create the wallet.
|
// Create the wallet.
|
||||||
dbPath := filepath.Join(netDir, walletDbName)
|
dbPath := filepath.Join(netDir, walletDbName)
|
||||||
|
|
Loading…
Add table
Reference in a new issue