helper

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 10 Imported by: 17

Documentation

Index

Constants

View Source
const D = 100000000
View Source
const PRECISION = 8
View Source
const ZeroScriptHashString = "0000000000000000000000000000000000000000"

Variables

This section is empty.

Functions

func Abs

func Abs(x int64) int64

func BigIntFromNeoBytes

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

func BigIntToNeoBytes

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

func BytesToHex

func BytesToHex(b []byte) string

BytesToHex bytes to hex string

func BytesToUInt32

func BytesToUInt32(bs []byte) uint32

func BytesToUInt64

func BytesToUInt64(bs []byte) uint64

func ConcatBytes

func ConcatBytes(b1 []byte, b2 []byte) []byte

ConcatBytes ...

func Fixed8ToFloat64

func Fixed8ToFloat64(f Fixed8) float64

Fixed8ToFloat64 returns the decimal value of a Fixed8 type.

func Fixed8ToInt64

func Fixed8ToInt64(f Fixed8) int64

Fixed8ToInt64 returns the original value representing Fixed8 as int64.

func Fixed8ToString

func Fixed8ToString(input Fixed8) string

Fixed8ToString converts a Fixed8 to a decimal string

func HexToBytes

func HexToBytes(hexstring string) (b []byte)

HexToBytes Simple hex string to bytes

func Int64ToBytes

func Int64ToBytes(n int64) []byte

Int64ToBytes ...

func PadRight

func PadRight(data []byte, length int) []byte

func ReverseBytes

func ReverseBytes(data []byte) []byte

ReverseBytes without change original slice

func ReverseString

func ReverseString(input string) string

ReverseString

func ScriptHashToAddress

func ScriptHashToAddress(scriptHash UInt160) string

func ToNibbles

func ToNibbles(data []byte) []byte

ToNibbles ..

func UInt32ToBytes

func UInt32ToBytes(n uint32) []byte

UInt32ToBytes ...

Types

type Fixed8

type Fixed8 struct {
	Value int64
}
var One Fixed8 = NewFixed8(int64(D))
var Satosh Fixed8 = NewFixed8(int64(1))
var Zero Fixed8 = NewFixed8(int64(0))

func Fixed8FromFloat64

func Fixed8FromFloat64(val float64) Fixed8

Fixed8FromFloat64 returns a new Fixed8 type multiplied by decimals.

func Fixed8FromInt64

func Fixed8FromInt64(val int64) Fixed8

Fixed8FromInt64 returns a new Fixed8 type multiplied by decimals.

func Fixed8FromString

func Fixed8FromString(s string) (Fixed8, error)

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

func NewFixed8

func NewFixed8(data int64) Fixed8

NewFixed8 returns a Fixed8 using an int64 as raw data

func (Fixed8) Abs

func (f Fixed8) Abs() Fixed8

Abs returns the absolute value of a Fixed8 type

func (Fixed8) Add

func (f Fixed8) Add(g Fixed8) Fixed8

Add implements Fixed8 + operator.

func (Fixed8) Ceiling

func (f Fixed8) Ceiling() Fixed8

Ceiling returns the ceiling value of a Fixed8 type

func (Fixed8) Div

func (f Fixed8) Div(g Fixed8) Fixed8

Div implements Fixed8 / operator.

func (Fixed8) Equal

func (f Fixed8) Equal(g Fixed8) bool

Equal implements Fixed8 == operator.

func (Fixed8) GreaterThan

func (f Fixed8) GreaterThan(g Fixed8) bool

GreaterThan implements Fixed8 > operator.

func (Fixed8) LessThan

func (f Fixed8) LessThan(g Fixed8) bool

LessThan implements Fixed8 < operator.

func (Fixed8) Mul

func (f Fixed8) Mul(g Fixed8) (Fixed8, error)

Mul implements Fixed8 * operator

func (Fixed8) String

func (f Fixed8) String() string

String implements the Stringer interface.

func (Fixed8) Sub

func (f Fixed8) Sub(g Fixed8) Fixed8

Sub implements Fixed8 - operator

type UInt160

type UInt160 [uint160Size]uint8

UInt160 is a 20 byte long unsigned integer. little endian

func AddressToScriptHash

func AddressToScriptHash(address string) (UInt160, error)

func BytesToScriptHash

func BytesToScriptHash(bs []byte) (UInt160, error)

func UInt160FromBytes

func UInt160FromBytes(b []byte) (u UInt160, err error)

UInt160FromBytes attempts to decode the given bytes into an UInt160.

func UInt160FromString

func UInt160FromString(s string) (UInt160, error)

UInt160FromString attempts to decode the given big endian string into an UInt160.

func (UInt160) Bytes

func (u UInt160) Bytes() []byte

Bytes returns the little endian byte slice 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) Less

func (u UInt160) Less(other UInt160) bool

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

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. Return big endian hex string.

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 UInt256FromBytes

func UInt256FromBytes(b []byte) (u UInt256, err error)

UInt256FromBytes attempts to decode the given bytes (in LE representation) into an UInt256.

func UInt256FromString

func UInt256FromString(s string) (u UInt256, err error)

UInt256FromString attempts to decode the given string (in BE representation) into an UInt256.

func (UInt256) Bytes

func (u UInt256) Bytes() []byte

Bytes returns a byte slice representation of u.

func (UInt256) CompareTo

func (u UInt256) CompareTo(other UInt256) int

CompareTo compares two UInt256 with each other. Possible output: 1, -1, 0

1 implies u > other.

-1 implies u < other.

0 implies  u = other.

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.

type VarInt

type VarInt struct {
	Value uint64
}

VarInt

func ParseVarInt

func ParseVarInt(bytes []byte) (VarInt, error)

ParseVarInt parse the serialized bytes of the var int and return VarInt

func VarIntFromInt

func VarIntFromInt(input int) VarInt

func VarIntFromInt16

func VarIntFromInt16(input int16) VarInt

func VarIntFromUInt64

func VarIntFromUInt64(input uint64) VarInt

func (VarInt) Bytes

func (v VarInt) Bytes() []byte

Bytes returns the serialized bytes of the var int

func (VarInt) Length

func (v VarInt) Length() int

Length returns the serialized bytes length of the var int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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