nef

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// Magic is a magic File header constant.
	Magic uint32 = 0x3346454E
	// MaxScriptLength is the maximum allowed contract script length.
	MaxScriptLength = 1024 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Header   Header
	Checksum uint32
	Script   []byte
}

File represents compiled contract file structure according to the NEF3 standard.

func FileFromBytes

func FileFromBytes(source []byte) (File, error)

FileFromBytes returns NEF File deserialized from given bytes.

func NewFile

func NewFile(script []byte) (File, error)

NewFile returns new NEF3 file with script specified.

func (File) Bytes

func (n File) Bytes() ([]byte, error)

Bytes returns byte array with serialized NEF File.

func (*File) DecodeBinary

func (n *File) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (*File) EncodeBinary

func (n *File) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

type Header struct {
	Magic      uint32
	Compiler   string
	Version    Version
	ScriptHash util.Uint160
}

Header represents File header.

func (*Header) CalculateChecksum

func (h *Header) CalculateChecksum() uint32

CalculateChecksum returns first 4 bytes of SHA256(Header) converted to uint32.

func (*Header) DecodeBinary

func (h *Header) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (*Header) EncodeBinary

func (h *Header) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

type Version

type Version struct {
	Major    int32
	Minor    int32
	Build    int32
	Revision int32
}

Version represents compiler version.

func GetVersion

func GetVersion(version string) (Version, error)

GetVersion returns Version from the given string. It accepts the following formats: `major.minor.build-[...]` `major.minor.build.revision-[...]` where `major`, `minor`, `build` and `revision` are 32-bit integers with base=10

func (*Version) DecodeBinary

func (v *Version) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (*Version) EncodeBinary

func (v *Version) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

Jump to

Keyboard shortcuts

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