kaspad/cmd/txgen/config.go
Ori Newman 6250342b86 [NOD-205] Reimplement txgen (#320)
* [NOD-205] Reimplement txgen

* [NOD-205] remove prev outpoints of all initial transactions

* [NOD-205] break txloop to smaller functions

* [NOD-205] Limit collectTransactions iterations

* [NOD-205] Use requiredConfirmations constant instead of inline number

* [NOD-205] Rename wTx -> walletTx

* [NOD-205] Remove handleNewBlock

* [NOD-205] Fix search and replace error
2019-06-04 18:06:35 +03:00

49 lines
1.2 KiB
Go

package main
import (
"errors"
"github.com/daglabs/btcd/util"
"path/filepath"
"github.com/jessevdk/go-flags"
)
const (
defaultLogFilename = "txgen.log"
)
var (
// Default configuration options
defaultHomeDir = util.AppDataDir("txgen", false)
defaultLogFile = filepath.Join(defaultHomeDir, defaultLogFilename)
)
type config struct {
Address string `long:"address" description:"An address to a JSON-RPC endpoints" required:"true"`
PrivateKey string `long:"private-key" description:"Private key" required:"true"`
CertificatePath string `long:"cert" description:"Path to certificate accepted by JSON-RPC endpoint"`
DisableTLS bool `long:"notls" description:"Disable TLS"`
}
func parseConfig() (*config, error) {
cfg := &config{}
parser := flags.NewParser(cfg, flags.PrintErrors|flags.HelpFlag)
_, err := parser.Parse()
if err != nil {
return nil, err
}
if cfg.CertificatePath == "" && !cfg.DisableTLS {
return nil, errors.New("--notls has to be disabled if --cert is used")
}
if cfg.CertificatePath != "" && cfg.DisableTLS {
return nil, errors.New("--cert should be omitted if --notls is used")
}
initLogRotator(defaultLogFile)
return cfg, nil
}