common

package
v0.0.0-...-118dd9e Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultConfigAccountAliasesDirName fro accounts
	DefaultConfigAccountAliasesDirName = "account-keys"
	// DefaultPassphrase for accounts
	DefaultPassphrase = ""
	// Secp256k1PrivateKeyBytesLength privete key
	Secp256k1PrivateKeyBytesLength = 32
	// AmountDecimalPoint TRX decimal point
	AmountDecimalPoint = 6
)
View Source
const (
	// HashLength is the expected length of the hash
	HashLength = 32
)

Variables

View Source
var (
	// DefaultConfigDirName for wallets
	DefaultConfigDirName = ".tronctl"
	DebugGRPC            = false
	DebugTransaction     = false
	ErrNotAbsPath        = errors.New("keypath is not absolute path")
	ErrBadKeyLength      = errors.New("Invalid private key (wrong length)")
	ErrFoundNoPass       = errors.New("found no passphrase file")
)
View Source
var (
	EmptyString = &hexError{"empty hex string"}
)

Functions

func Bytes2Hex

func Bytes2Hex(d []byte) string

Bytes2Hex returns the hexadecimal encoding of d.

func BytesToHexString

func BytesToHexString(bytes []byte) string

BytesToHexString encodes bytes as a hex string.

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

CopyBytes returns an exact copy of the provided bytes.

func Decode

func Decode(input string) ([]byte, error)

func DecodeCheck

func DecodeCheck(input string) ([]byte, error)

func EnableAllVerbose

func EnableAllVerbose()

EnableAllVerbose sets debug vars to true

func Encode

func Encode(input []byte) string

func EncodeCheck

func EncodeCheck(input []byte) string

func FromHex

func FromHex(s string) ([]byte, error)

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func Has0xPrefix

func Has0xPrefix(str string) bool

Has0xPrefix validates str begins with '0x' or '0X'.

func Hex2Bytes

func Hex2Bytes(str string) ([]byte, error)

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func Hex2BytesFixed

func Hex2BytesFixed(str string, flen int) []byte

Hex2BytesFixed returns bytes of a specified fixed length flen.

func HexStringToBytes

func HexStringToBytes(input string) ([]byte, error)

HexStringToBytes hex string as bytes

func JSONPrettyFormat

func JSONPrettyFormat(in string) string

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

LeftPadBytes zero-pads slice to the left up to length l.

func RightPadBytes

func RightPadBytes(slice []byte, l int) []byte

RightPadBytes zero-pads slice to the right up to length l.

func ToHex deprecated

func ToHex(b []byte) string

ToHex returns the hex representation of b, prefixed with '0x'. For empty slices, the return value is "0x0".

Deprecated: use BytesToHexString instead.

func ToHexArray

func ToHexArray(b [][]byte) []string

ToHexArray creates a array of hex-string based on []byte

func ToJSONUnsafe

func ToJSONUnsafe(payload interface{}, pretty bool) string

returns "{}" on failure case

func TrimLeftZeroes

func TrimLeftZeroes(s []byte) []byte

TrimLeftZeroes returns a subslice of s without leading zeroes

Types

type Hash

type Hash [HashLength]byte

Hash represents the 32 byte Keccak256 hash of arbitrary data.

func BigToHash

func BigToHash(b *big.Int) Hash

BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.

func BytesToHash

func BytesToHash(b []byte) Hash

BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.

func HexToHash

func HexToHash(s string) (Hash, error)

HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.

func (Hash) Big

func (h Hash) Big() *big.Int

Big converts a hash to a big integer.

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes gets the byte representation of the underlying hash.

func (Hash) Hex

func (h Hash) Hex() string

Hex converts a hash to a hex string.

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.

func (Hash) String

func (h Hash) String() string

String implements the stringer interface and is used also by the logger when doing full logging into a file.

func (Hash) TerminalString

func (h Hash) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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