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 EnableAllVerbose()
- func Encode(input []byte) string
- func EncodeCheck(input []byte) 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 JSONPrettyFormat(in string) string
- 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 ToJSONUnsafe(payload interface{}, pretty bool) string
- func TrimLeftZeroes(s []byte) []byte
- type Hash
Constants ¶
const ( // DefaultConfigAccountAliasesDirName fro accounts DefaultConfigAccountAliasesDirName = "account-keys" // DefaultPassphrase for accounts DefaultPassphrase = "" // Secp256k1PrivateKeyBytesLength privete key Secp256k1PrivateKeyBytesLength = 32 // AmountDecimalPoint TRX decimal point AmountDecimalPoint = 6 )
const (
// HashLength is the expected length of the hash
HashLength = 32
)
Variables ¶
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") )
var (
ACAlphabet = base58.NewAlphabet("123456789ABCDEFGHJKLMNPQRSWUVTXYZabcdefghijkmnopqrswuvtxyz")
)
var (
EmptyString = &hexError{"empty hex string"}
)
Functions ¶
func BytesToHexString ¶
BytesToHexString encodes bytes as a hex string.
func DecodeCheck ¶
func EncodeCheck ¶
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 JSONPrettyFormat ¶
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 ToJSONUnsafe ¶
returns "{}" on failure case
func TrimLeftZeroes ¶
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 ¶
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.