// cleanAndExpandPath expands environement variables and leading ~ in the // passed path, cleans the result, and returns it. func cleanAndExpandPath(path string) string { // Expand initial ~ to OS specific home directory. if strings.HasPrefix(path, "~") { appHomeDir := btcutil.AppDataDir("gencerts", false) homeDir := filepath.Dir(appHomeDir) path = strings.Replace(path, "~", homeDir, 1) } // NOTE: The os.ExpandEnv doesn't work with Windows-style %VARIABLE%, // but they variables can still be expanded via POSIX-style $VARIABLE. return filepath.Clean(os.ExpandEnv(path)) }
import ( "errors" "fmt" "os" "path/filepath" "github.com/chrjen/btcd/chaincfg" database "github.com/chrjen/btcd/database2" _ "github.com/chrjen/btcd/database2/ffldb" "github.com/chrjen/btcd/wire" "github.com/chrjen/btcutil" ) var ( btcdHomeDir = btcutil.AppDataDir("btcd", false) knownDbTypes = database.SupportedDrivers() activeNetParams = &chaincfg.MainNetParams // Default global config. cfg = &config{ DataDir: filepath.Join(btcdHomeDir, "data"), DbType: "ffldb", } ) // config defines the global configuration options. type config struct { DataDir string `short:"b" long:"datadir" description:"Location of the btcd data directory"` DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"` TestNet3 bool `long:"testnet" description:"Use the test network"`
"strings" "github.com/chrjen/btcd/btcjson" "github.com/chrjen/btcutil" flags "github.com/chrjen/go-flags" ) const ( // unusableFlags are the command usage flags which this utility are not // able to use. In particular it doesn't support websockets and // consequently notifications. unusableFlags = btcjson.UFWebsocketOnly | btcjson.UFNotification ) var ( btcdHomeDir = btcutil.AppDataDir("btcd", false) btcctlHomeDir = btcutil.AppDataDir("btcctl", false) btcwalletHomeDir = btcutil.AppDataDir("btcwallet", false) defaultConfigFile = filepath.Join(btcctlHomeDir, "btcctl.conf") defaultRPCServer = "localhost" defaultRPCCertFile = filepath.Join(btcdHomeDir, "rpc.cert") defaultWalletCertFile = filepath.Join(btcwalletHomeDir, "rpc.cert") ) // listCommands categorizes and lists all of the usable commands along with // their one-line usage. func listCommands() { const ( categoryChain uint8 = iota categoryWallet numCategories