util

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayContains

func ArrayContains(arr []string, item string) bool

func ArrayContainsIndex

func ArrayContainsIndex(arr []string, item string) (bool, int)

func ByteToInt64

func ByteToInt64(arr string) int64

ByteToInt64 : Convert a byte array from tendermint back into an int64

func BytesToIP

func BytesToIP(encoded_ip []byte) string

BytesToIP : takes an IP byte array and converts it to corresponding dot string format

func Contains

func Contains(s interface{}, elem interface{}) bool

Contains : generic method for testing set (slice) inclusion

func Copy

func Copy(src, dst string) error

Copy a file safely

func CreateSig

func CreateSig(data string, key ecdsa.PrivateKey) string

CreateSig : create signature from data in base64

func DecodeIP

func DecodeIP(remote_ip string) string

DecodeIP: decode tendermint's arcane remote_ip format

func DecodeJWK

func DecodeJWK(jwkType types.Jwk) (string, *ecdsa.PublicKey, error)

func DecodePubKey

func DecodePubKey(tx types.Tx) (*ecdsa.PublicKey, error)

func DecodeTx

func DecodeTx(incoming []byte) (types.Tx, error)

DecodeTxAndVerifySig accepts a Chainpoint Calendar transaction in base64 and decodes it into abci.Tx struct

func DecodeTxAndVerifySig

func DecodeTxAndVerifySig(incoming []byte, CoreKeys map[string]ecdsa.PublicKey) (types.Tx, error)

DecodeTxAndVerifySig accepts a Chainpoint Calendar transaction in base64 and decodes it into abci.Tx struct

func DetermineIP

func DetermineIP(peer core_types.Peer) string

DetermineIP : use remoteIP if routable, use listenAddr if not

func EncodeTx

func EncodeTx(outgoing types.Tx) string

EncodeTx : encode a tx to base64

func EncodeTxWithKey

func EncodeTxWithKey(outgoing types.Tx, privateKey *ecdsa.PrivateKey) string

EncodeTxWithKey : Encodes a Tendermint transaction to base64

func GenerateKey

func GenerateKey(privateKey *ecdsa.PrivateKey, kid string) types.Jwk

func GetAPIStatus

func GetAPIStatus(ip string) types.CoreAPIStatus

GetAPIStatus : get metadata from a core, given its IP

func GetClientIP

func GetClientIP(r *http.Request) string

func GetCurrentFuncName

func GetCurrentFuncName(numCallStack int) string

GetCurrentFuncName : get name of function being called

func GetEnv

func GetEnv(key string, def string) string

GetEnv : GetArray an env var but with a default. Untyped, defaults to string.

func GetIPOnly

func GetIPOnly(ip string) string

func GetNISTTimestamp

func GetNISTTimestamp(record string) int64

GetNISTTimestamp : gets Unix timestamp from record

func Int2Ip

func Int2Ip(nn uint32) net.IP

Int2Ip : converts uint32 to IP

func Int64ToByte

func Int64ToByte(num int64) []byte

Int64ToByte : Convert an int64 to a byte for use in the Tendermint tagging system

func Ip2Int

func Ip2Int(ip net.IP) uint32

Ip2Int : converts IP to uint32

func IsULID added in v1.0.0

func IsULID(proofId string) bool

func IsUUID added in v1.0.0

func IsUUID(proofId string) bool

func LogError

func LogError(err error) error

LogError : Log error if it exists

func LoggerError

func LoggerError(logger log.Logger, err error) error

LoggerError : Log error if it exists using a logger

func MaxInt64

func MaxInt64(x, y int64) int64

func NormalizeUri

func NormalizeUri(uri string, removePort bool, http bool, https bool) string

func ReadContractJSON

func ReadContractJSON(file string, testnet bool) string

ReadContractJSON : reads in TierionNetworkToken and ChainpointRegistry json files and extracts addresses

func ReadLines

func ReadLines(path string) ([]string, error)

ReadLines reads a whole file into memory and returns a slice of its lines.

func ReverseTxHex

func ReverseTxHex(str string) string

func UUIDFromHash

func UUIDFromHash(seedBytes []byte) (uuid.UUID, error)

UUIDFromHash : generate a uuid from a byte hash, must be 16 bytes

func UniquifyAddresses

func UniquifyAddresses(s []common.Address) []common.Address

UniquifyAddresses: make unique array of addresses

func UniquifyStrings

func UniquifyStrings(s []string) []string

UniquifyStrings : make unique array of strings

func ValidateIPAddress

func ValidateIPAddress(ip string) error

func VerifySig

func VerifySig(data string, originalSig string, key ecdsa.PublicKey) bool

VerifySig : verifies an ecdsa signature

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL