Documentation
¶
Index ¶
- Constants
- Variables
- func Bytes2BigInt(b [32]byte) *big.Int
- func Bytes2Hex(d []byte) string
- func CopyBytes(b []byte) (copiedBytes []byte)
- func FromHex(s string) []byte
- func GetCurrentTime() string
- func Hex2Bytes(str string) []byte
- func Hex2BytesFixed(str string, flen int) []byte
- func IsHexAddress(s string) bool
- func LeftPadBytes(slice []byte, l int) []byte
- func ParseHexOrString(str string) ([]byte, error)
- func ReadFile(filename string) []byte
- func RightPadBytes(slice []byte, l int) []byte
- func StringIsAllNumber(str string) bool
- func TimestampToTime(timestamp int64) string
- func TrimLeftZeroes(s []byte) []byte
- func TrimRightZeroes(s []byte) []byte
- func WriteFile(filename, context string)
- type Address
- type Hash
Constants ¶
const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength is the expected length of the address AddressLength = 20 )
Lengths of hashes and addresses in bytes.
Variables ¶
var ( Big0 = big.NewInt(0) Big1 = big.NewInt(1) Big2 = big.NewInt(2) Big3 = big.NewInt(3) Big32 = big.NewInt(32) Big256 = big.NewInt(256) Big257 = big.NewInt(257) )
Common big integers often used
Functions ¶
func Bytes2BigInt ¶ added in v1.4.0
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func GetCurrentTime ¶ added in v1.4.0
func GetCurrentTime() string
func Hex2BytesFixed ¶
Hex2BytesFixed returns bytes of a specified fixed length flen.
func IsHexAddress ¶
IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func ParseHexOrString ¶
ParseHexOrString tries to hexdecode b, but if the prefix is missing, it instead just returns the raw bytes
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
func StringIsAllNumber ¶ added in v1.4.0
func TimestampToTime ¶ added in v1.4.0
func TrimLeftZeroes ¶
TrimLeftZeroes returns a subslice of s without leading zeroes
func TrimRightZeroes ¶
TrimRightZeroes returns a subslice of s without trailing zeroes
Types ¶
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an wallet.
func BytesToAddress ¶
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte hash of arbitrary data.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.