Documentation
¶
Index ¶
- Constants
- Variables
- func Bytes2Hex(d []byte) string
- func BytesToHexString(bytes []byte) string
- func CopyBytes(b []byte) (copiedBytes []byte)
- func Decode(input string) ([]byte, error)
- func DecodeCheck(input string) ([]byte, error)
- func Encode(input []byte) string
- func EncodeCheck(input []byte) string
- func FormatPrecisionNumber(number int64, precision int) string
- func FormatPrecisionString(number string, precision int) string
- func FromHex(s string) ([]byte, error)
- func Has0xPrefix(str string) bool
- func Hex2Bytes(str string) ([]byte, error)
- func Hex2BytesFixed(str string, flen int) []byte
- func HexStringToBytes(input string) ([]byte, error)
- func IsHex(str string) bool
- func Keccak256(msg []byte) []byte
- func LeftPadBytes(slice []byte, l int) []byte
- func RightPadBytes(slice []byte, l int) []byte
- func ToHex(b []byte) stringdeprecated
- func ToHexArray(b [][]byte) []string
- func TrimLeftZeroes(s []byte) []byte
- 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 = 21 // AddressLengthBase58 is the expected length of the address in base58format AddressLengthBase58 = 34 // TronBytePrefix is the hex prefix to address TronBytePrefix = byte(0x41) )
Variables ¶
var EmptyString = &hexError{"empty hex string"}
Functions ¶
func BytesToHexString ¶
BytesToHexString encodes bytes as a hex string.
func DecodeCheck ¶
func EncodeCheck ¶
func FormatPrecisionNumber ¶
FormatPrecisionNumber formats an integer number (as int64) into a decimal string with the specified precision
func FormatPrecisionString ¶
FormatPrecisionString formats a string number into a decimal string with the specified precision
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func Has0xPrefix ¶
Has0xPrefix validates str begins with '0x' or '0X'.
func Hex2BytesFixed ¶
Hex2BytesFixed returns bytes of a specified fixed length flen.
func HexStringToBytes ¶
HexStringToBytes hex string as bytes
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
func ToHexArray ¶
ToHexArray creates a array of hex-string based on []byte
func TrimLeftZeroes ¶
TrimLeftZeroes returns a subslice of s without leading zeroes
Types ¶
type Address ¶
type Address []byte
Address represents the 21 byte address of an Tron account.
func Base58ToAddress ¶
Base58ToAddress returns Address with byte values of s.
func Base64ToAddress ¶
Base64ToAddress returns Address with byte values of s.
func BigToAddress ¶
BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.
func HexToAddress ¶
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
func PubkeyToAddress ¶
PubkeyToAddress returns address from ecdsa public key
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func BigToHash ¶
BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (*Hash) SetBytes ¶
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 ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.