Documentation ¶
Index ¶
- func Blake2b(msg []byte) ([]byte, error)
- func Blake2b256(data []byte) (output []byte)
- func Blake2b512(msg []byte) ([]byte, error)
- func Bytes2Bits(data []byte) []int
- func BytesEqual(a, b []byte) bool
- func BytesToHex(bytes []byte) string
- func BytesToString(typ CodecType, bytes []byte) (string, error)
- func ConcatBytes(arrays ...[]byte) ([]byte, error)
- func FromB64(base64String string) ([]byte, error)
- func FromHEX(input string) []uint8
- func GetErrorCategoryName(code ErrorCategory) string
- func GetHexByteLength(input string) float64
- func Hash160(msg []byte) []byte
- func HexTo32Uint8(h string) ([32]uint8, error)
- func HexTo4Uint8(h string) ([4]uint8, error)
- func HexToBytes(h string) ([]byte, error)
- func IsBytes(a interface{}) bool
- func IsHex(input interface{}) bool
- func NormalizeHex(input string) string
- func ParseHex(hexStr string) ([]byte, error)
- func ParseRoochErrorCode(errorMessage string) *uint32
- func PrettyJson(x any) string
- func Sha256(msg []byte) []byte
- func Sha256Double(msgs ...[]byte) ([]byte, error)
- func Sha3256(data []byte) (output []byte)
- func Sha3256Hash(bytes [][]byte) (output []byte)
- func Sha512(msg []byte) []byte
- func Str(typ CodecType, bytes []byte) (string, error)
- func Str2Uint64(str string) (uint64, error)
- func StrToBigInt(val string) (num *big.Int, err error)
- func StrToUint64(s string) (uint64, error)
- func StringToBytes(typ CodecType, str string) ([]byte, error)
- func TaggedHash(tag string, msg []byte) []byte
- func ToB64(bytes []byte) string
- func ToHEX(input []uint8) (string, error)
- func ValidateWitness(version int, data []byte) error
- func VarintByteNum(input uint64) []byte
- type CodecType
- type ErrorCategory
- type SubStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Blake2b256 ¶
Blake2b256 hashes the input bytes using Blake2b256-256
func Blake2b512 ¶
Blake2b computes BLAKE2b hash of the input bytes
func Bytes2Bits ¶
func BytesToHex ¶
BytesToHex converts a byte slice to a hex string with a leading 0x
func BytesToString ¶
BytesToString matches JS 'BytesToString'
func ConcatBytes ¶
ConcatBytes matches JS 'ConcatBytes'
func GetErrorCategoryName ¶
func GetErrorCategoryName(code ErrorCategory) string
GetErrorCategoryName returns the string representation of an ErrorCategory
func GetHexByteLength ¶
GetHexByteLength returns the byte length of a hex string.
func HexTo32Uint8 ¶
func HexTo4Uint8 ¶
func HexToBytes ¶
func NormalizeHex ¶
NormalizeHex removes the "0x" prefix from a hex string if present.
func ParseRoochErrorCode ¶
ParseRoochErrorCode parses the error code from a Rooch RPC error message
func Sha256Double ¶
Sha256Double computes SHA256(SHA256(concatenated msgs))
func Sha3256Hash ¶
SHA3256Hash hashes the input bytes using SHA3-256
func Str2Uint64 ¶
func StrToBigInt ¶
StrToBigInt converts a string to a big.Int for u128 and u256 values
func StrToUint64 ¶
StrToUint64 converts a string to a uint64
func StringToBytes ¶
StringToBytes matches JS 'StringToBytes'
func TaggedHash ¶
func ValidateWitness ¶
validateWitness checks if the witness program is valid according to BIP-0141 rules
func VarintByteNum ¶
VarintByteNum matches JS 'VarintByteNum'
Types ¶
type ErrorCategory ¶
type ErrorCategory uint16
ErrorCategory represents different types of errors with their corresponding codes
const ( InvalidArgument ErrorCategory = 0x1 // Caller specified an invalid argument (http: 400) OutOfRange ErrorCategory = 0x2 // An input or result of a computation is out of range (http: 400) InvalidState ErrorCategory = 0x3 // The system is not in a state where the operation can be performed (http: 400) Unauthenticated ErrorCategory = 0x4 // Request not authenticated due to missing, invalid, or expired auth token (http: 401) PermissionDenied ErrorCategory = 0x5 // client does not have sufficient permission (http: 403) NotFound ErrorCategory = 0x6 // A specified resource is not found (http: 404) Aborted ErrorCategory = 0x7 // Concurrency conflict, such as read-modify-write conflict (http: 409) AlreadyExists ErrorCategory = 0x8 // The resource that a client tried to create already exists (http: 409) ResourceExhausted ErrorCategory = 0x9 // Out of gas or other forms of quota (http: 429) Cancelled ErrorCategory = 0xa // Request cancelled by the client (http: 499) Internal ErrorCategory = 0xb // Internal error (http: 500) NotImplemented ErrorCategory = 0xc // Feature not implemented (http: 501) )
type SubStatus ¶
type SubStatus struct { Category ErrorCategory Reason uint16 }
SubStatus represents the error category and reason
func ParseRoochErrorSubStatus ¶
ParseRoochErrorSubStatus parses the SubStatus from a Rooch RPC error message