util

package
v0.0.0-...-866bf41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2018 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ADDR_LEN = 20

Variables

This section is empty.

Functions

func ArrayReverse

func ArrayReverse(b []byte) []byte

ArrayReverse return a reversed version of the given byte slice.

func ConvertBigIntegerToBytes

func ConvertBigIntegerToBytes(data *big.Int) []byte

func ConvertBytesToBigInteger

func ConvertBytesToBigInteger(ba []byte) *big.Int

func RandUint32

func RandUint32(min, max int) uint32

RandUint32 return a random number between min and max.

func RandomInt

func RandomInt(min, max int) int

RandomInt returns a ramdom integer betweeen min and max.

func RandomString

func RandomString(n int) string

RandomString returns a random string with the n as its length.

func ReadVarBytes

func ReadVarBytes(r io.Reader) ([]byte, error)

ReadVarBytes reads a variable length byte array.

func ReadVarString

func ReadVarString(r io.Reader) (string, error)

ReadVarString reads a variable length string.

func ReadVarUint

func ReadVarUint(r io.Reader) uint64

ReadVarUint reads a variable unsigned integer and returns it as a uint64.

func WriteVarBytes

func WriteVarBytes(w io.Writer, b []byte) error

WriteVarBytes writes a variable length byte array.

func WriteVarString

func WriteVarString(w io.Writer, s string) error

WriteVarString writes a variable length string.

func WriteVarUint

func WriteVarUint(w io.Writer, val uint64) error

WriteVarUint writes a variable unsigned integer.

Types

type Address

type Address [ADDR_LEN]byte

func AddressFromBase58

func AddressFromBase58(encoded string) (Address, error)

AddressFromBase58 returns Address from encoded base58 string

func AddressParseFromBytes

func AddressParseFromBytes(f []byte) (Address, error)

AddressParseFromBytes returns parsed Address

func (*Address) Deserialize

func (self *Address) Deserialize(r io.Reader) error

Deserialize deserialize Address from io.Reader

func (*Address) Serialize

func (self *Address) Serialize(w io.Writer) error

Serialize serialize Address into io.Writer

func (*Address) ToBase58

func (f *Address) ToBase58() string

ToBase58 returns base58 encoded address string

func (*Address) ToHexString

func (self *Address) ToHexString() string

ToHexString returns hex string representation of Address

type Fixed8

type Fixed8 int64

Fixed8 represents a fixed-point number with precision 10^-8.

func Fixed8DecodeString

func Fixed8DecodeString(s string) (Fixed8, error)

Fixed8DecodeString parses s which must be a fixed point number with precision up to 10^-8

func NewFixed8

func NewFixed8(val int) Fixed8

NewFixed8 return a new Fixed8 type multiplied by decimals.

func (Fixed8) String

func (f Fixed8) String() string

String implements the Stringer interface.

func (*Fixed8) UnmarshalJSON

func (f *Fixed8) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json unmarshaller interface.

func (Fixed8) Value

func (f Fixed8) Value() int64

Value returns the original value representing the Fixed8.

type Uint160

type Uint160 [uint160Size]uint8

Uint160 is a 20 byte long unsigned integer.

func RandomUint160

func RandomUint160() Uint160

RandomUint160 returns a random Uint160.

func Uint160DecodeBytes

func Uint160DecodeBytes(b []byte) (u Uint160, err error)

Uint160DecodeBytes attempts to decode the given bytes into an Uint160.

func Uint160DecodeString

func Uint160DecodeString(s string) (u Uint160, err error)

Uint160DecodeString attempts to decode the given string into an Uint160.

func Uint160FromScript

func Uint160FromScript(script []byte) (u Uint160, err error)

Uint160FromScript returns a Uint160 type from a raw script.

func (Uint160) Bytes

func (u Uint160) Bytes() []byte

Bytes returns the byte slice representation of u.

func (Uint160) BytesReverse

func (u Uint160) BytesReverse() []byte

BytesReverse return a reversed byte representation of u.

func (Uint160) Equals

func (u Uint160) Equals(other Uint160) bool

Equals returns true if both Uint256 values are the same.

func (Uint160) MarshalJSON

func (u Uint160) MarshalJSON() ([]byte, error)

MarshalJSON implements the json marshaller interface.

func (Uint160) String

func (u Uint160) String() string

String implements the stringer interface.

func (*Uint160) UnmarshalJSON

func (u *Uint160) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json unmarshaller interface.

type Uint256

type Uint256 [uint256Size]uint8

Uint256 is a 32 byte long unsigned integer.

func RandomUint256

func RandomUint256() Uint256

RandomUint256 returns a random Uint256.

func Read2000Uint256Hashes

func Read2000Uint256Hashes(b []byte) ([]Uint256, error)

Read2000Uint256Hashes attempt to read 2000 Uint256 hashes from the given byte array.

func Uint256DecodeBytes

func Uint256DecodeBytes(b []byte) (u Uint256, err error)

Uint256DecodeBytes attempts to decode the given string into an Uint256.

func Uint256DecodeString

func Uint256DecodeString(s string) (u Uint256, err error)

Uint256DecodeString attempts to decode the given string into an Uint256.

func (Uint256) Bytes

func (u Uint256) Bytes() []byte

Bytes returns a byte slice representation of u.

func (Uint256) BytesReverse

func (u Uint256) BytesReverse() []byte

BytesReverse return a reversed byte representation of u.

func (Uint256) Equals

func (u Uint256) Equals(other Uint256) bool

Equals returns true if both Uint256 values are the same.

func (Uint256) MarshalJSON

func (u Uint256) MarshalJSON() ([]byte, error)

MarshalJSON implements the json marshaller interface.

func (Uint256) String

func (u Uint256) String() string

String implements the stringer interface.

func (*Uint256) UnmarshalJSON

func (u *Uint256) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json unmarshaller interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL