Documentation
¶
Overview ¶
Package hexutil implements hex encoding with 0x prefix. This encoding is used by the Ubiq RPC API to transport binary data in JSON payloads.
Encoding Rules ¶
All hex data must have prefix "0x".
For byte slices, the hex data must be of even length. An empty byte slice encodes as "0x".
Integers are encoded using the least amount of digits (no leading zero digits). Their encoding may be of uneven length. The number zero encodes as "0x0".
Index ¶
- Variables
- func BigFloatToString(f *big.Float, prec int) string
- func CaculateBlockReward(height uint64, uncleNo int) *big.Int
- func CaculateUncleReward(height uint64, uncleHeight uint64) *big.Int
- func Decode(input string) ([]byte, error)
- func DecodeBig(input string) (*big.Int, error)
- func DecodeHex(str string) uint64
- func DecodeUint64(input string) (uint64, error)
- func DecodeValueHex(val string) string
- func Encode(b []byte) string
- func EncodeBig(bigint *big.Int) string
- func EncodeUint64(i uint64) string
- func FloatToString(f float64) string
- func FormatQwark(str string) string
- func FromWei(str string) string
- func FromWeiToGwei(str string) string
- func GetJson(client *http.Client, url string, target interface{}) error
- func InputParamsToAddress(str string) string
- func MakeTimestamp() int64
- func MustDecode(input string) []byte
- func MustDecodeBig(input string) *big.Int
- func MustDecodeUint64(input string) uint64
- type DateValuesSlice
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyString = &decError{"empty hex string"} ErrSyntax = &decError{"invalid hex string"} ErrMissingPrefix = &decError{"hex string without 0x prefix"} ErrOddLength = &decError{"hex string of odd length"} ErrEmptyNumber = &decError{"hex string \"0x\""} ErrLeadingZero = &decError{"hex number with leading zero digits"} ErrUint64Range = &decError{"hex number > 64 bits"} ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", uintBits)} ErrBig256Range = &decError{"hex number > 256 bits"} )
Errors
Functions ¶
func DecodeBig ¶
DecodeBig decodes a hex string with 0x prefix as a quantity. Numbers larger than 256 bits are not accepted.
func DecodeUint64 ¶
DecodeUint64 decodes a hex string with 0x prefix as a quantity.
func DecodeValueHex ¶
func EncodeBig ¶
EncodeBig encodes bigint as a hex string with 0x prefix. The sign of the integer is ignored.
func EncodeUint64 ¶
EncodeUint64 encodes i as a hex string with 0x prefix.
func FloatToString ¶
func FormatQwark ¶
func FromWeiToGwei ¶
func InputParamsToAddress ¶
func MakeTimestamp ¶
func MakeTimestamp() int64
func MustDecode ¶
MustDecode decodes a hex string with 0x prefix. It panics for invalid input.
func MustDecodeBig ¶
MustDecodeBig decodes a hex string with 0x prefix as a quantity. It panics for invalid input.
func MustDecodeUint64 ¶
MustDecodeUint64 decodes a hex string with 0x prefix as a quantity. It panics for invalid input.
Types ¶
type DateValuesSlice ¶
func (DateValuesSlice) Len ¶
func (sbo DateValuesSlice) Len() int
func (DateValuesSlice) Less ¶
func (sbo DateValuesSlice) Less(i, j int) bool
func (DateValuesSlice) Swap ¶
func (sbo DateValuesSlice) Swap(i, j int)