Documentation ¶
Index ¶
- Constants
- Variables
- func Abs(x int64) int64
- func BigIntFromNeoBytes(ba []byte) *big.Int
- func BigIntToNeoBytes(data *big.Int) []byte
- func BytesToHex(b []byte) string
- func BytesToUInt32(bs []byte) uint32
- func BytesToUInt64(bs []byte) uint64
- func CompareTo(a, b uint64) int
- func ConcatBytes(b1 []byte, b2 []byte) []byte
- func ConvertBigIntToUint64(t *big.Int, decimals int) uint64
- func ConvertFloat64StringToBigInt(s string, decimals int) *big.Int
- func ConvertUint64ToBigInt(u uint64, decimals int) *big.Int
- func GenerateRandomBytes(size int) ([]byte, error)
- func GetVarSize(value int) int
- func HexToBytes(s string) (b []byte)
- func Int16ToBytes(n int16) []byte
- func Int64ToBytes(n int64) []byte
- func IntToBytes(n int) []byte
- func PadRight(data []byte, length int, negative bool) []byte
- func ReverseBytes(data []byte) []byte
- func ReverseString(input string) string
- func UInt16ToBytes(n uint16) []byte
- func UInt32ToBytes(n uint32) []byte
- func UInt64ToBytes(n uint64) []byte
- func XOR(a, b []byte) []byte
- type ProtocolSettings
- type UInt160
- func (u *UInt160) CompareTo(other *UInt160) int
- func (u *UInt160) Deserialize(br *io.BinaryReader)
- func (u *UInt160) Equals(other *UInt160) bool
- func (u *UInt160) ExistsIn(list []*UInt160) bool
- func (u *UInt160) GetSize() int
- func (u *UInt160) Less(other *UInt160) bool
- func (u *UInt160) MarshalJSON() ([]byte, error)
- func (u *UInt160) Serialize(bw *io.BinaryWriter)
- func (u *UInt160) String() string
- func (u *UInt160) ToByteArray() []byte
- func (u *UInt160) UnmarshalJSON(data []byte) (err error)
- type UInt160Slice
- type UInt256
- func (u *UInt256) CompareTo(other *UInt256) int
- func (u *UInt256) Deserialize(br *io.BinaryReader)
- func (u *UInt256) Equals(other *UInt256) bool
- func (u *UInt256) ExistsIn(list []*UInt256) bool
- func (u *UInt256) Less(other *UInt256) bool
- func (u *UInt256) MarshalJSON() ([]byte, error)
- func (u *UInt256) Serialize(bw *io.BinaryWriter)
- func (u *UInt256) Size() int
- func (u *UInt256) String() string
- func (u *UInt256) ToByteArray() []byte
- func (u *UInt256) UnmarshalJSON(data []byte) (err error)
- type UInt256Slice
- type VarInt
Constants ¶
const ( Neo3Magic_MainNet uint32 = 860833102 // NEO3 Neo3Magic_TestNet uint32 = 894710606 // N3T5 DefaultAddressVersion byte = 0x35 // 53 )
const UINT160SIZE = 20
const UINT256SIZE = 32
const UINT32SIZE = 4
const UINT64SIZE = 8
Variables ¶
var DefaultProtocolSettings = ProtocolSettings{ Magic: Neo3Magic_MainNet, AddressVersion: DefaultAddressVersion, }
var UInt160Zero = NewUInt160()
var UInt256Zero = NewUInt256()
Functions ¶
func BigIntFromNeoBytes ¶
func BigIntToNeoBytes ¶
func BytesToUInt32 ¶
func BytesToUInt64 ¶
func ConvertBigIntToUint64 ¶ added in v1.1.2
func ConvertFloat64StringToBigInt ¶ added in v1.1.2
func ConvertUint64ToBigInt ¶ added in v1.1.2
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GetVarSize ¶
func ReverseBytes ¶
ReverseBytes without change original slice
func UInt16ToBytes ¶
UInt16ToBytes converts uint16 to byte array
func UInt32ToBytes ¶
UInt32ToBytes converts uint32 to byte array
func UInt64ToBytes ¶
UInt64ToBytes converts uint64 to byte array
Types ¶
type ProtocolSettings ¶
type UInt160 ¶
/ This class stores a 160 bit unsigned int, represented as a 20-byte little-endian byte array / It is composed by ulong(64) + ulong(64) + uint(32) = UInt160(160)
func NewUInt160 ¶
func NewUInt160() *UInt160
func UInt160FromBytes ¶
UInt160FromBytes attempts to decode the given little endian bytes into an UInt160.
func UInt160FromString ¶
UInt160FromString attempts to decode the given big endian string into an UInt160.
func (*UInt160) CompareTo ¶
/ Method CompareTo returns 1 if this UInt160 is bigger than other UInt160; -1 if it's smaller; 0 if it's equals / Example: assume this is 01ff00ff00ff00ff00ff00ff00ff00ff00ff00a4, this.CompareTo(02ff00ff00ff00ff00ff00ff00ff00ff00ff00a3) returns 1
func (*UInt160) Deserialize ¶
func (u *UInt160) Deserialize(br *io.BinaryReader)
func (*UInt160) Less ¶
Less returns true if this value is less than given UInt160 value. It's primarily intended to be used for sorting purposes.
func (*UInt160) MarshalJSON ¶
MarshalJSON implements the json marshaller interface.
func (*UInt160) Serialize ¶
func (u *UInt160) Serialize(bw *io.BinaryWriter)
func (*UInt160) ToByteArray ¶
ToByteArray returns the little endian byte slice representation of u.
func (*UInt160) UnmarshalJSON ¶
UnmarshalJSON implements the json unmarshall interface.
type UInt160Slice ¶
type UInt160Slice []*UInt160
func (UInt160Slice) GetVarSize ¶
func (us UInt160Slice) GetVarSize() int
func (UInt160Slice) Len ¶
func (us UInt160Slice) Len() int
func (UInt160Slice) Swap ¶
func (us UInt160Slice) Swap(i, j int)
type UInt256 ¶
UInt256 stores a 256 bit unsigned int, represented as a 32-byte little-endian byte array. Composed by ulong(64) + ulong(64) + ulong(64) + ulong(64) = UInt256(256)
func NewUInt256 ¶
func NewUInt256() *UInt256
func UInt256FromBytes ¶
UInt256FromBytes attempts to decode the given bytes (in LE representation) into an UInt256.
func UInt256FromString ¶
UInt256FromString attempts to decode the given string (in BE representation) into an UInt256.
func (*UInt256) CompareTo ¶
CompareTo returns 1 if this UInt256 is bigger than other UInt256; -1 if it's smaller; 0 if it's equals / Example: assume this is 01ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00a4, this.CompareTo(02ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00a3) returns 1
func (*UInt256) Deserialize ¶
func (u *UInt256) Deserialize(br *io.BinaryReader)
func (*UInt256) MarshalJSON ¶
MarshalJSON implements the json marshaller interface.
func (*UInt256) Serialize ¶
func (u *UInt256) Serialize(bw *io.BinaryWriter)
func (*UInt256) ToByteArray ¶
ToByteArray returns a byte slice representation of u.
func (*UInt256) UnmarshalJSON ¶
UnmarshalJSON implements the json unmarshall interface.
type UInt256Slice ¶
type UInt256Slice []*UInt256
func (UInt256Slice) GetVarSize ¶
func (us UInt256Slice) GetVarSize() int
func (UInt256Slice) Len ¶
func (us UInt256Slice) Len() int
func (UInt256Slice) Swap ¶
func (us UInt256Slice) Swap(i, j int)
type VarInt ¶
type VarInt struct {
Value uint64
}
VarInt
func ParseVarInt ¶
ParseVarInt parse the serialized bytes of the var int and return VarInt