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 DeleteFile(path string) error
- func Div(str string, pos int) string
- func Encode(input []byte) string
- func EncodeCheck(input []byte) string
- func FromHex(s string) ([]byte, error)
- func GetLocalNodeId(path string) (string, error)
- func Has0xPrefix(str string) bool
- func Hex2Address(hex string) (string, error)
- func Hex2Address2(hex string) (string, error)
- func Hex2Bytes(str string) ([]byte, error)
- func Hex2BytesFixed(str string, flen int) []byte
- func HexStringToBytes(input string) ([]byte, error)
- func HexToInt(hex string) (string, error)
- func HexToInt2(hex string) (int64, error)
- func Int2Hex(data string) (string, error)
- func Keccak256(msg []byte) []byte
- func LeftPadBytes(slice []byte, l int) []byte
- func NftData(data string) (string, string, error)
- func PathExists(path string) (bool, error)
- func ReadLatestBlock() ([]byte, error)
- func RightPadBytes(slice []byte, l int) []byte
- func ToHex(b []byte) stringdeprecated
- func ToHexArray(b [][]byte) []string
- func TrimLeftZeroes(s []byte) []byte
- func WriteLatestBlock(content string) error
- 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) )
const ( Key = "key" NodePath = "./data" NodeFile = "./data/key" LatestBlockPath = "./data" LatestBlockFile = "./data/blockchain.json" )
const (
// HashLength is the expected length of the hash
HashLength = 32
)
Variables ¶
var (
EmptyString = &hexError{"empty hex string"}
)
Functions ¶
func BytesToHexString ¶
BytesToHexString encodes bytes as a hex string.
func DecodeCheck ¶
func DeleteFile ¶
func EncodeCheck ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func GetLocalNodeId ¶
func Has0xPrefix ¶
Has0xPrefix validates str begins with '0x' or '0X'.
func Hex2Address ¶
func Hex2Address2 ¶
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 PathExists ¶
func ReadLatestBlock ¶
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
func WriteLatestBlock ¶
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.