// 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 := coinutil.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)) }
"strings" "github.com/conseweb/coinutil" flags "github.com/conseweb/go-flags" "github.com/conseweb/stcd/btcjson" ) 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 = coinutil.AppDataDir("xcoind", false) btcctlHomeDir = coinutil.AppDataDir("xcoinctl", false) btcwalletHomeDir = coinutil.AppDataDir("xcoinwallet", false) defaultConfigFile = filepath.Join(btcctlHomeDir, "xcoinctl.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
// defaultPubPassphrase is the default public wallet passphrase which is // used when the user indicates they do not want additional protection // provided by having all public data in the wallet encrypted by a // passphrase only known to them. defaultPubPassphrase = "public" // maxEmptyAccounts is the number of accounts to scan even if they have no // transaction history. This is a deviation from BIP044 to make account // creation easier by allowing a limited number of empty accounts. maxEmptyAccounts = 100 walletDbName = "wallet.db" ) var ( btcdHomeDir = coinutil.AppDataDir("stcd", false) btcwalletHomeDir = coinutil.AppDataDir("stcwallet", false) btcdHomedirCAFile = filepath.Join(btcdHomeDir, "rpc.cert") defaultConfigFile = filepath.Join(btcwalletHomeDir, defaultConfigFilename) defaultDataDir = btcwalletHomeDir defaultRPCKeyFile = filepath.Join(btcwalletHomeDir, "rpc.key") defaultRPCCertFile = filepath.Join(btcwalletHomeDir, "rpc.cert") defaultLogDir = filepath.Join(btcwalletHomeDir, defaultLogDirname) ) type config struct { 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"` CreateTemp bool `long:"createtemp" description:"Create a temporary simulation wallet (pass=password) in the data directory indicated; must call with --datadir"` CAFile string `long:"cafile" description:"File containing root certificates to authenticate a TLS connections with btcd"` RPCConnect string `short:"c" long:"rpcconnect" description:"Hostname/IP and port of btcd RPC server to connect to (default localhost:18334, mainnet: localhost:8334, simnet: localhost:18556)"`
flags "github.com/conseweb/go-flags" "github.com/conseweb/stcd/chaincfg" "github.com/conseweb/stcd/database" _ "github.com/conseweb/stcd/database/ldb" "github.com/conseweb/stcd/wire" ) const ( minCandidates = 1 maxCandidates = 20 defaultNumCandidates = 5 defaultDbType = "leveldb" ) var ( btcdHomeDir = coinutil.AppDataDir("xcoind", false) defaultDataDir = filepath.Join(btcdHomeDir, "data") knownDbTypes = database.SupportedDBs() activeNetParams = &chaincfg.MainNetParams ) // config defines the configuration options for findcheckpoint. // // See loadConfig for details on the configuration load process. type config struct { DataDir string `short:"b" long:"datadir" description:"Location of the xcoind data directory"` DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"` TestNet3 bool `long:"testnet" description:"Use the test network"` RegressionTest bool `long:"regtest" description:"Use the regression test network"` SimNet bool `long:"simnet" description:"Use the simulation test network"` NumCandidates int `short:"n" long:"numcandidates" description:"Max num of checkpoint candidates to show {1-20}"`
import ( "bufio" "fmt" "os" "path/filepath" "github.com/conseweb/coinutil" "github.com/conseweb/go-flags" "github.com/conseweb/stcwallet/walletdb" _ "github.com/conseweb/stcwallet/walletdb/bdb" ) const defaultNet = "mainnet" var datadir = coinutil.AppDataDir("btcwallet", false) // Flags. var opts = struct { Force bool `short:"f" description:"Force removal without prompt"` DbPath string `long:"db" description:"Path to wallet database"` }{ Force: false, DbPath: filepath.Join(datadir, defaultNet, "wallet.db"), } func init() { _, err := flags.Parse(&opts) if err != nil { os.Exit(1) }