transaction

package
v0.91.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: MIT Imports: 13 Imported by: 43

Documentation

Index

Constants

View Source
const (
	// MaxTransactionSize is the upper limit size in bytes that a transaction can reach. It is
	// set to be 102400.
	MaxTransactionSize = 102400
	// MaxValidUntilBlockIncrement is the upper increment size of blockhain height in blocs after
	// exceeding that a transaction should fail validation. It is set to be 2102400.
	MaxValidUntilBlockIncrement = 2102400
	// MaxAttributes is maximum number of attributes including signers that can be contained
	// within a transaction. It is set to be 16.
	MaxAttributes = 16
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttrType added in v0.91.0

type AttrType uint8

AttrType represents the purpose of the attribute.

type Attribute

type Attribute struct {
	Type AttrType
	Data []byte
}

Attribute represents a Transaction attribute.

func (*Attribute) DecodeBinary

func (attr *Attribute) DecodeBinary(br *io.BinReader)

DecodeBinary implements Serializable interface.

func (*Attribute) EncodeBinary

func (attr *Attribute) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements Serializable interface.

func (*Attribute) MarshalJSON

func (attr *Attribute) MarshalJSON() ([]byte, error)

MarshalJSON implements the json Marshaller interface.

func (*Attribute) UnmarshalJSON added in v0.75.0

func (attr *Attribute) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

type Signer added in v0.91.0

type Signer struct {
	Account          util.Uint160      `json:"account"`
	Scopes           WitnessScope      `json:"scopes"`
	AllowedContracts []util.Uint160    `json:"allowedcontracts,omitempty"`
	AllowedGroups    []*keys.PublicKey `json:"allowedgroups,omitempty"`
}

Signer implements a Transaction signer.

func (*Signer) DecodeBinary added in v0.91.0

func (c *Signer) DecodeBinary(br *io.BinReader)

DecodeBinary implements Serializable interface.

func (*Signer) EncodeBinary added in v0.91.0

func (c *Signer) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements Serializable interface.

type Transaction

type Transaction struct {
	// The trading version which is currently 0.
	Version uint8

	// Random number to avoid hash collision.
	Nonce uint32

	// Fee to be burned.
	SystemFee int64

	// Fee to be distributed to consensus nodes.
	NetworkFee int64

	// Maximum blockchain height exceeding which
	// transaction should fail verification.
	ValidUntilBlock uint32

	// Code to run in NeoVM for this transaction.
	Script []byte

	// Transaction attributes.
	Attributes []Attribute

	// Transaction signers list (starts with Sender).
	Signers []Signer

	// The scripts that comes with this transaction.
	// Scripts exist out of the verification script
	// and invocation script.
	Scripts []Witness

	// Network magic number. This one actually is not a part of the
	// wire-representation of Transaction, but it's absolutely necessary
	// for correct signing/verification.
	Network netmode.Magic

	// Trimmed indicates this is a transaction from trimmed
	// data.
	Trimmed bool
	// contains filtered or unexported fields
}

Transaction is a process recorded in the NEO blockchain.

func New added in v0.90.0

func New(network netmode.Magic, script []byte, gas int64) *Transaction

New returns a new transaction to execute given script and pay given system fee.

func NewTransactionFromBytes added in v0.90.0

func NewTransactionFromBytes(network netmode.Magic, b []byte) (*Transaction, error)

NewTransactionFromBytes decodes byte array into *Transaction

func NewTrimmedTX

func NewTrimmedTX(hash util.Uint256) *Transaction

NewTrimmedTX returns a trimmed transaction with only its hash and Trimmed to true.

func (*Transaction) Bytes

func (t *Transaction) Bytes() []byte

Bytes converts the transaction to []byte

func (*Transaction) DecodeBinary

func (t *Transaction) DecodeBinary(br *io.BinReader)

DecodeBinary implements Serializable interface.

func (*Transaction) DecodeSignedPart added in v0.90.0

func (t *Transaction) DecodeSignedPart(buf []byte) error

DecodeSignedPart decodes a part of transaction from GetSignedPart data.

func (*Transaction) EncodeBinary

func (t *Transaction) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements Serializable interface.

func (*Transaction) FeePerByte added in v0.90.0

func (t *Transaction) FeePerByte() int64

FeePerByte returns NetworkFee of the transaction divided by its size

func (*Transaction) GetSignedPart

func (t *Transaction) GetSignedPart() []byte

GetSignedPart returns a part of the transaction which must be signed.

func (*Transaction) Hash

func (t *Transaction) Hash() util.Uint256

Hash returns the hash of the transaction.

func (*Transaction) MarshalJSON added in v0.75.0

func (t *Transaction) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Transaction) Sender added in v0.90.0

func (t *Transaction) Sender() util.Uint160

Sender returns the sender of the transaction which is always on the first place in the transaction's signers list.

func (*Transaction) UnmarshalJSON added in v0.75.0

func (t *Transaction) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

func (*Transaction) VerificationHash

func (t *Transaction) VerificationHash() util.Uint256

VerificationHash returns the hash of the transaction used to verify it.

type Witness

type Witness struct {
	InvocationScript   []byte `json:"invocation"`
	VerificationScript []byte `json:"verification"`
}

Witness contains 2 scripts.

func (*Witness) DecodeBinary

func (w *Witness) DecodeBinary(br *io.BinReader)

DecodeBinary implements Serializable interface.

func (*Witness) EncodeBinary

func (w *Witness) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements Serializable interface.

func (Witness) ScriptHash

func (w Witness) ScriptHash() util.Uint160

ScriptHash returns the hash of the VerificationScript.

type WitnessScope added in v0.90.0

type WitnessScope byte

WitnessScope represents set of witness flags for Transaction signer.

const (
	// FeeOnly is only valid for a sender, it can't be used during the execution.
	FeeOnly WitnessScope = 0
	// CalledByEntry means that this condition must hold: EntryScriptHash == CallingScriptHash.
	// No params is needed, as the witness/permission/signature given on first invocation will
	// automatically expire if entering deeper internal invokes. This can be default safe
	// choice for native NEO/GAS (previously used on Neo 2 as "attach" mode).
	CalledByEntry WitnessScope = 0x01
	// CustomContracts define custom hash for contract-specific.
	CustomContracts WitnessScope = 0x10
	// CustomGroups define custom pubkey for group members.
	CustomGroups WitnessScope = 0x20
	// Global allows this witness in all contexts (default Neo2 behavior).
	// This cannot be combined with other flags.
	Global WitnessScope = 0x80
)

func ScopesFromString added in v0.90.0

func ScopesFromString(s string) (WitnessScope, error)

ScopesFromString converts string of comma-separated scopes to a set of scopes (case-sensitive). String can combine several scopes, e.g. be any of: 'Global', 'CalledByEntry,CustomGroups' etc. In case of an empty string an error will be returned.

func (WitnessScope) MarshalJSON added in v0.90.0

func (s WitnessScope) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (WitnessScope) String added in v0.90.0

func (i WitnessScope) String() string

func (*WitnessScope) UnmarshalJSON added in v0.90.0

func (s *WitnessScope) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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