Documentation
¶
Index ¶
- Constants
- Variables
- func B64Decode(str string) (buf []byte, err error)
- func B64Encode(buf []byte) string
- func CalcGasCost(gasLimit uint64, gasPrice *big.Int) *big.Int
- func CmdRunBegin(v *viper.Viper)
- func CopyMissingValues(src, dst interface{})
- func CreateKeyStore(path string, password string) (*ks.KeyStore, string, error)
- func EqualBytes(a [32]byte, b [32]byte) bool
- func ErrorContains(t *testing.T, err error, contains, msg string, args ...interface{})
- func Fatal(format string, v ...interface{})
- func FatalError(t *testing.T, err error, msg string, args ...interface{})
- func FileExists(name string) bool
- func FlagString(v *viper.Viper, flags *pflag.FlagSet, name, short string, def string, ...)
- func FromECDSA(privateKey *ecdsa.PrivateKey) string
- func GetDefaultConfigFile(cmdName string) string
- func GetECPrivateKey(raw []byte) (*ecdsa.PrivateKey, error)
- func GetKey(file string, password string) (*ks.Key, error)
- func GetMaskedURL(url string) string
- func GetRSAPrivateKey(raw []byte) (*rsa.PrivateKey, error)
- func GetSerialAsHex(serial *big.Int) string
- func GetSliceFromList(split string, delim string) []string
- func HTTPRequestToString(req *http.Request) string
- func HTTPResponseToString(resp *http.Response) string
- func Hostname() string
- func ImportKeyStore(file string, password string) (*ks.KeyStore, *accounts.Account, error)
- func IsSubsetOf(small, big string) error
- func IsValidAddress(iaddress interface{}) bool
- func IsZeroAddress(iaddress interface{}) bool
- func ListContains(list, find string) bool
- func MakeFileAbs(file, dir string) (string, error)
- func MakeFileNamesAbsolute(files []*string, home string) error
- func Marshal(from interface{}, what string) ([]byte, error)
- func NormalizeFileList(files []string, homeDir string) ([]string, error)
- func NormalizeStringSlice(slice []string) []string
- func ParseObj(obj interface{}, cb func(*Field) error, tags map[string]string) error
- func PublicKeyBytesToAddress(publicKey []byte) common.Address
- func RandomString(n int) string
- func Read(r io.Reader, data []byte) ([]byte, error)
- func ReadFile(file string) ([]byte, error)
- func RegisterFlags(v *viper.Viper, flags *pflag.FlagSet, config interface{}, ...) error
- func RemoveQuotes(str string) string
- func ReplaceTextFile(path, old, new string) error
- func SigRSV(isig interface{}) ([32]byte, [32]byte, uint8)
- func StrContained(str string, strs []string) bool
- func StructToString(si interface{}) string
- func ToDecimal(ivalue interface{}, decimals int) decimal.Decimal
- func ToWei(iamount interface{}, decimals int) *big.Int
- func Unmarshal(from []byte, to interface{}, what string) error
- func ValidateAndReturnAbsConf(configFilePath, homeDir, cmdName string) (string, string, error)
- func ViperUnmarshal(cfg interface{}, stringSliceFields []string, vp *viper.Viper) error
- func WriteFile(file string, buf []byte, perm os.FileMode) error
- type ECDSASignature
- type Field
Constants ¶
const ( // TagDefault is the tag name for a default value of a field as recognized // by RegisterFlags. TagDefault = "def" // TagHelp is the tag name for a help message of a field as recognized // by RegisterFlags. TagHelp = "help" // TagOpt is the tag name for a one character option of a field as recognized // by RegisterFlags. For example, a value of "d" reserves "-d" for the // command line argument. TagOpt = "opt" // TagSkip is the tag name which causes the field to be skipped by // RegisterFlags. TagSkip = "skip" // TagHide is the tag name which causes the field to be hidden TagHide = "hide" )
const SecretTag = "mask"
SecretTag to tag a field as secret as in password, token
Variables ¶
var ( // ErrNotImplemented used to return errors for functions not implemented ErrNotImplemented = errors.New("NOT YET IMPLEMENTED") )
var RevocationReasonCodes = map[string]int{ "unspecified": ocsp.Unspecified, "keycompromise": ocsp.KeyCompromise, "cacompromise": ocsp.CACompromise, "affiliationchanged": ocsp.AffiliationChanged, "superseded": ocsp.Superseded, "cessationofoperation": ocsp.CessationOfOperation, "certificatehold": ocsp.CertificateHold, "removefromcrl": ocsp.RemoveFromCRL, "privilegewithdrawn": ocsp.PrivilegeWithdrawn, "aacompromise": ocsp.AACompromise, }
RevocationReasonCodes is a map between string reason codes to integers as defined in RFC 5280
var URLRegex = regexp.MustCompile("(ldap|http)s*://(\\S+):(\\S+)@")
URLRegex is the regular expression to check if a value is an URL
Functions ¶
func CalcGasCost ¶
CalcGasCost calculate gas cost given gas limit (units) and gas price (wei)
func CmdRunBegin ¶
CmdRunBegin is called at the beginning of each cobra run function
func CopyMissingValues ¶
func CopyMissingValues(src, dst interface{})
CopyMissingValues checks the dst interface for missing values and replaces them with value from src config struct. This does a deep copy of pointers.
func CreateKeyStore ¶
CreateKeyStore in host directory
func ErrorContains ¶
ErrorContains will check to see if an error occurred, if so it will check that it contains the appropriate error message
func FatalError ¶
FatalError will check to see if an error occured if so it will cause the test cases exit
func FlagString ¶
FlagString sets up a flag for a string, binding it to its name
func GetDefaultConfigFile ¶
GetDefaultConfigFile gets the default path for the config file to display in usage message
func GetECPrivateKey ¶
func GetECPrivateKey(raw []byte) (*ecdsa.PrivateKey, error)
GetECPrivateKey get *ecdsa.PrivateKey from key pem
func GetMaskedURL ¶
GetMaskedURL returns masked URL. It masks username and password from the URL if present
func GetRSAPrivateKey ¶
func GetRSAPrivateKey(raw []byte) (*rsa.PrivateKey, error)
GetRSAPrivateKey get *rsa.PrivateKey from key pem
func GetSerialAsHex ¶
GetSerialAsHex returns the serial number from certificate as hex format
func GetSliceFromList ¶
GetSliceFromList will return a slice from a list
func HTTPRequestToString ¶
HTTPRequestToString returns a string for an HTTP request for debuggging
func HTTPResponseToString ¶
HTTPResponseToString returns a string for an HTTP response for debuggging
func ImportKeyStore ¶
ImportKeyStore from keystore in host directory
func IsSubsetOf ¶
IsSubsetOf returns an error if there is something in 'small' that is not in 'big'. Both small and big are assumed to be comma-separated strings. All string comparisons are case-insensitive. Examples: 1) IsSubsetOf('a,B', 'A,B,C') returns nil 2) IsSubsetOf('A,B,C', 'B,C') returns an error because A is not in the 2nd set.
func IsValidAddress ¶
func IsValidAddress(iaddress interface{}) bool
IsValidAddress validate hex address
func IsZeroAddress ¶
func IsZeroAddress(iaddress interface{}) bool
IsZeroAddress validate if it's a 0 address
func ListContains ¶
ListContains looks through a comma separated list to see if a string exists
func MakeFileAbs ¶
MakeFileAbs makes 'file' absolute relative to 'dir' if not already absolute
func MakeFileNamesAbsolute ¶
MakeFileNamesAbsolute makes all file names in the list absolute, relative to home
func NormalizeFileList ¶
NormalizeFileList provides absolute pathing for the list of files
func NormalizeStringSlice ¶
NormalizeStringSlice checks for seperators
func PublicKeyBytesToAddress ¶
PublicKeyBytesToAddress ...
func RegisterFlags ¶
func RegisterFlags(v *viper.Viper, flags *pflag.FlagSet, config interface{}, tags map[string]string) error
RegisterFlags registers flags for all fields in an arbitrary 'config' object. This method recognizes the following field tags: "def" - the default value of the field; "opt" - the optional one character short name to use on the command line; "help" - the help message to display on the command line; "skip" - to skip the field.
func RemoveQuotes ¶
RemoveQuotes removes outer quotes from a string if necessary
func ReplaceTextFile ¶
ReplaceTextFile replace a text in a file
func StrContained ¶
StrContained returns true if 'str' is in 'strs'; otherwise return false
func StructToString ¶
func StructToString(si interface{}) string
StructToString converts a struct to a string. If a field has a 'secret' tag, it is masked in the returned string
func ValidateAndReturnAbsConf ¶
ValidateAndReturnAbsConf checks to see that there are no conflicts between the configuration file path and home directory. If no conflicts, returns back the absolute path for the configuration file and home directory.
func ViperUnmarshal ¶
ViperUnmarshal is a work around for a bug in viper.Unmarshal This can be removed once https://github.com/spf13/viper/issues/327 is fixed and vendored.
Types ¶
type ECDSASignature ¶
ECDSASignature forms the structure for R and S value for ECDSA