Documentation ¶
Overview ¶
Package transaction contains Neo transaction definition.
This is one of the core structures of Neo blockchain.
Index ¶
- Constants
- Variables
- func IsValidAttrType(reservedAttributesEnabled bool, attrType AttrType) bool
- func SignersToStackItem(signers []Signer) stackitem.Item
- type AttrType
- type AttrValue
- type Attribute
- type ConditionAnd
- func (c *ConditionAnd) Copy() WitnessCondition
- func (c *ConditionAnd) DecodeBinarySpecific(r *io.BinReader, maxDepth int)
- func (c *ConditionAnd) EncodeBinary(w *io.BinWriter)
- func (c *ConditionAnd) MarshalJSON() ([]byte, error)
- func (c *ConditionAnd) Match(ctx MatchContext) (bool, error)
- func (c *ConditionAnd) ToStackItem() stackitem.Item
- func (c *ConditionAnd) Type() WitnessConditionType
- type ConditionBoolean
- func (c *ConditionBoolean) Copy() WitnessCondition
- func (c *ConditionBoolean) DecodeBinarySpecific(r *io.BinReader, maxDepth int)
- func (c *ConditionBoolean) EncodeBinary(w *io.BinWriter)
- func (c *ConditionBoolean) MarshalJSON() ([]byte, error)
- func (c *ConditionBoolean) Match(_ MatchContext) (bool, error)
- func (c *ConditionBoolean) ToStackItem() stackitem.Item
- func (c *ConditionBoolean) Type() WitnessConditionType
- type ConditionCalledByContract
- func (c *ConditionCalledByContract) Copy() WitnessCondition
- func (c *ConditionCalledByContract) DecodeBinarySpecific(r *io.BinReader, _ int)
- func (c *ConditionCalledByContract) EncodeBinary(w *io.BinWriter)
- func (c *ConditionCalledByContract) MarshalJSON() ([]byte, error)
- func (c *ConditionCalledByContract) Match(ctx MatchContext) (bool, error)
- func (c *ConditionCalledByContract) ToStackItem() stackitem.Item
- func (c *ConditionCalledByContract) Type() WitnessConditionType
- type ConditionCalledByEntry
- func (c ConditionCalledByEntry) Copy() WitnessCondition
- func (c ConditionCalledByEntry) DecodeBinarySpecific(_ *io.BinReader, _ int)
- func (c ConditionCalledByEntry) EncodeBinary(w *io.BinWriter)
- func (c ConditionCalledByEntry) MarshalJSON() ([]byte, error)
- func (c ConditionCalledByEntry) Match(ctx MatchContext) (bool, error)
- func (c ConditionCalledByEntry) ToStackItem() stackitem.Item
- func (c ConditionCalledByEntry) Type() WitnessConditionType
- type ConditionCalledByGroup
- func (c *ConditionCalledByGroup) Copy() WitnessCondition
- func (c *ConditionCalledByGroup) DecodeBinarySpecific(r *io.BinReader, _ int)
- func (c *ConditionCalledByGroup) EncodeBinary(w *io.BinWriter)
- func (c *ConditionCalledByGroup) MarshalJSON() ([]byte, error)
- func (c *ConditionCalledByGroup) Match(ctx MatchContext) (bool, error)
- func (c *ConditionCalledByGroup) ToStackItem() stackitem.Item
- func (c *ConditionCalledByGroup) Type() WitnessConditionType
- type ConditionGroup
- func (c *ConditionGroup) Copy() WitnessCondition
- func (c *ConditionGroup) DecodeBinarySpecific(r *io.BinReader, _ int)
- func (c *ConditionGroup) EncodeBinary(w *io.BinWriter)
- func (c *ConditionGroup) MarshalJSON() ([]byte, error)
- func (c *ConditionGroup) Match(ctx MatchContext) (bool, error)
- func (c *ConditionGroup) ToStackItem() stackitem.Item
- func (c *ConditionGroup) Type() WitnessConditionType
- type ConditionNot
- func (c *ConditionNot) Copy() WitnessCondition
- func (c *ConditionNot) DecodeBinarySpecific(r *io.BinReader, maxDepth int)
- func (c *ConditionNot) EncodeBinary(w *io.BinWriter)
- func (c *ConditionNot) MarshalJSON() ([]byte, error)
- func (c *ConditionNot) Match(ctx MatchContext) (bool, error)
- func (c *ConditionNot) ToStackItem() stackitem.Item
- func (c *ConditionNot) Type() WitnessConditionType
- type ConditionOr
- func (c *ConditionOr) Copy() WitnessCondition
- func (c *ConditionOr) DecodeBinarySpecific(r *io.BinReader, maxDepth int)
- func (c *ConditionOr) EncodeBinary(w *io.BinWriter)
- func (c *ConditionOr) MarshalJSON() ([]byte, error)
- func (c *ConditionOr) Match(ctx MatchContext) (bool, error)
- func (c *ConditionOr) ToStackItem() stackitem.Item
- func (c *ConditionOr) Type() WitnessConditionType
- type ConditionScriptHash
- func (c *ConditionScriptHash) Copy() WitnessCondition
- func (c *ConditionScriptHash) DecodeBinarySpecific(r *io.BinReader, _ int)
- func (c *ConditionScriptHash) EncodeBinary(w *io.BinWriter)
- func (c *ConditionScriptHash) MarshalJSON() ([]byte, error)
- func (c *ConditionScriptHash) Match(ctx MatchContext) (bool, error)
- func (c *ConditionScriptHash) ToStackItem() stackitem.Item
- func (c *ConditionScriptHash) Type() WitnessConditionType
- type Conflicts
- type MatchContext
- type NotValidBefore
- type NotaryAssisted
- type OracleResponse
- type OracleResponseCode
- type Reserved
- type Signer
- type Transaction
- func (t *Transaction) Bytes() []byte
- func (t *Transaction) Copy() *Transaction
- func (t *Transaction) DecodeBinary(br *io.BinReader)
- func (t *Transaction) DecodeHashableFields(buf []byte) error
- func (t *Transaction) EncodeBinary(bw *io.BinWriter)
- func (t *Transaction) EncodeHashableFields() ([]byte, error)
- func (t *Transaction) FeePerByte() int64
- func (t *Transaction) GetAttributes(typ AttrType) []Attribute
- func (t *Transaction) HasAttribute(typ AttrType) bool
- func (t *Transaction) HasSigner(hash util.Uint160) bool
- func (t *Transaction) Hash() util.Uint256
- func (t *Transaction) MarshalJSON() ([]byte, error)
- func (t *Transaction) Sender() util.Uint160
- func (t *Transaction) Size() int
- func (t *Transaction) ToStackItem() stackitem.Item
- func (t *Transaction) UnmarshalJSON(data []byte) error
- type Witness
- type WitnessAction
- type WitnessCondition
- type WitnessConditionType
- type WitnessRule
- func (w *WitnessRule) Copy() *WitnessRule
- func (w *WitnessRule) DecodeBinary(br *io.BinReader)
- func (w *WitnessRule) EncodeBinary(bw *io.BinWriter)
- func (w *WitnessRule) MarshalJSON() ([]byte, error)
- func (w *WitnessRule) ToStackItem() stackitem.Item
- func (w *WitnessRule) UnmarshalJSON(data []byte) error
- type WitnessScope
Constants ¶
const ( // ReservedLowerBound is the lower bound of reserved attribute types. ReservedLowerBound = 0xe0 // ReservedUpperBound is the upper bound of reserved attribute types. ReservedUpperBound = 0xff )
const ( // MaxScriptLength is the limit for transaction's script length. MaxScriptLength = math.MaxUint16 // MaxTransactionSize is the upper limit size in bytes that a transaction can reach. It is // set to be 102400. MaxTransactionSize = 102400 // MaxAttributes is maximum number of attributes including signers that can be contained // within a transaction. It is set to be 16. MaxAttributes = 16 )
const ( // MaxInvocationScript is the maximum length of allowed invocation // script. It should fit 11/21 multisignature for the committee. MaxInvocationScript = 1024 // MaxVerificationScript is the maximum allowed length of verification // script. It should be appropriate for 11/21 multisignature committee. MaxVerificationScript = 1024 )
const MaxOracleResultSize = math.MaxUint16
MaxOracleResultSize is the maximum allowed oracle answer size.
Variables ¶
var ( ErrInvalidResponseCode = errors.New("invalid oracle response code") ErrInvalidResult = errors.New("oracle response != success, but result is not empty") )
Various validation errors.
var ( ErrInvalidVersion = errors.New("only version 0 is supported") ErrNegativeSystemFee = errors.New("negative system fee") ErrNegativeNetworkFee = errors.New("negative network fee") ErrTooBigFees = errors.New("too big fees: int64 overflow") ErrEmptySigners = errors.New("signers array should contain sender") ErrNonUniqueSigners = errors.New("transaction signers should be unique") ErrInvalidAttribute = errors.New("invalid attribute") ErrEmptyScript = errors.New("no script") )
Various errors for transaction validation.
var ErrInvalidWitnessNum = errors.New("number of signers doesn't match witnesses")
ErrInvalidWitnessNum returns when the number of witnesses does not match signers.
Functions ¶
func IsValidAttrType ¶
IsValidAttrType returns whether the provided attribute type is valid.
func SignersToStackItem ¶
SignersToStackItem converts transaction.Signers to stackitem.Item.
Types ¶
type AttrType ¶
type AttrType uint8
AttrType represents the purpose of the attribute.
type AttrValue ¶
type AttrValue interface { io.Serializable // Copy returns a deep copy of the attribute value. Copy() AttrValue // contains filtered or unexported methods }
AttrValue represents a Transaction Attribute value.
type Attribute ¶
Attribute represents a Transaction attribute.
func (*Attribute) DecodeBinary ¶
DecodeBinary implements the Serializable interface.
func (*Attribute) EncodeBinary ¶
EncodeBinary implements the Serializable interface.
func (*Attribute) MarshalJSON ¶
MarshalJSON implements the json Marshaller interface.
func (*Attribute) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaller interface.
type ConditionAnd ¶
type ConditionAnd []WitnessCondition
ConditionAnd is a set of conditions required to match.
func (*ConditionAnd) Copy ¶
func (c *ConditionAnd) Copy() WitnessCondition
Copy implements the WitnessCondition interface and returns a deep copy of the condition.
func (*ConditionAnd) DecodeBinarySpecific ¶
func (c *ConditionAnd) DecodeBinarySpecific(r *io.BinReader, maxDepth int)
DecodeBinarySpecific implements the WitnessCondition interface allowing to deserialize condition-specific data.
func (*ConditionAnd) EncodeBinary ¶
func (c *ConditionAnd) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the WitnessCondition interface allowing to serialize condition.
func (*ConditionAnd) MarshalJSON ¶
func (c *ConditionAnd) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ConditionAnd) Match ¶
func (c *ConditionAnd) Match(ctx MatchContext) (bool, error)
Match implements the WitnessCondition interface checking whether this condition matches given context.
func (*ConditionAnd) ToStackItem ¶
func (c *ConditionAnd) ToStackItem() stackitem.Item
ToStackItem implements the WitnessCondition interface allowing to convert to stackitem.Item.
func (*ConditionAnd) Type ¶
func (c *ConditionAnd) Type() WitnessConditionType
Type implements the WitnessCondition interface and returns condition type.
type ConditionBoolean ¶
type ConditionBoolean bool
ConditionBoolean is a boolean condition type.
func (*ConditionBoolean) Copy ¶
func (c *ConditionBoolean) Copy() WitnessCondition
Copy returns a deep copy of the condition.
func (*ConditionBoolean) DecodeBinarySpecific ¶
func (c *ConditionBoolean) DecodeBinarySpecific(r *io.BinReader, maxDepth int)
DecodeBinarySpecific implements the WitnessCondition interface allowing to deserialize condition-specific data.
func (*ConditionBoolean) EncodeBinary ¶
func (c *ConditionBoolean) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the WitnessCondition interface allowing to serialize condition.
func (*ConditionBoolean) MarshalJSON ¶
func (c *ConditionBoolean) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ConditionBoolean) Match ¶
func (c *ConditionBoolean) Match(_ MatchContext) (bool, error)
Match implements the WitnessCondition interface checking whether this condition matches given context.
func (*ConditionBoolean) ToStackItem ¶
func (c *ConditionBoolean) ToStackItem() stackitem.Item
ToStackItem implements WitnessCondition interface allowing to convert to stackitem.Item.
func (*ConditionBoolean) Type ¶
func (c *ConditionBoolean) Type() WitnessConditionType
Type implements the WitnessCondition interface and returns condition type.
type ConditionCalledByContract ¶
ConditionCalledByContract is a condition matching calling script hash.
func (*ConditionCalledByContract) Copy ¶
func (c *ConditionCalledByContract) Copy() WitnessCondition
Copy implements the WitnessCondition interface and returns a deep copy of the condition.
func (*ConditionCalledByContract) DecodeBinarySpecific ¶
func (c *ConditionCalledByContract) DecodeBinarySpecific(r *io.BinReader, _ int)
DecodeBinarySpecific implements the WitnessCondition interface allowing to deserialize condition-specific data.
func (*ConditionCalledByContract) EncodeBinary ¶
func (c *ConditionCalledByContract) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the WitnessCondition interface allowing to serialize condition.
func (*ConditionCalledByContract) MarshalJSON ¶
func (c *ConditionCalledByContract) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ConditionCalledByContract) Match ¶
func (c *ConditionCalledByContract) Match(ctx MatchContext) (bool, error)
Match implements the WitnessCondition interface checking whether this condition matches given context.
func (*ConditionCalledByContract) ToStackItem ¶
func (c *ConditionCalledByContract) ToStackItem() stackitem.Item
ToStackItem implements the WitnessCondition interface allowing to convert to stackitem.Item.
func (*ConditionCalledByContract) Type ¶
func (c *ConditionCalledByContract) Type() WitnessConditionType
Type implements the WitnessCondition interface and returns condition type.
type ConditionCalledByEntry ¶
type ConditionCalledByEntry struct{}
ConditionCalledByEntry is a condition matching entry script or one directly called by it.
func (ConditionCalledByEntry) Copy ¶
func (c ConditionCalledByEntry) Copy() WitnessCondition
Copy implements the WitnessCondition interface and returns a deep copy of the condition.
func (ConditionCalledByEntry) DecodeBinarySpecific ¶
func (c ConditionCalledByEntry) DecodeBinarySpecific(_ *io.BinReader, _ int)
DecodeBinarySpecific implements the WitnessCondition interface allowing to deserialize condition-specific data.
func (ConditionCalledByEntry) EncodeBinary ¶
func (c ConditionCalledByEntry) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the WitnessCondition interface allowing to serialize condition.
func (ConditionCalledByEntry) MarshalJSON ¶
func (c ConditionCalledByEntry) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (ConditionCalledByEntry) Match ¶
func (c ConditionCalledByEntry) Match(ctx MatchContext) (bool, error)
Match implements the WitnessCondition interface checking whether this condition matches given context.
func (ConditionCalledByEntry) ToStackItem ¶
func (c ConditionCalledByEntry) ToStackItem() stackitem.Item
ToStackItem implements the WitnessCondition interface allowing to convert to stackitem.Item.
func (ConditionCalledByEntry) Type ¶
func (c ConditionCalledByEntry) Type() WitnessConditionType
Type implements the WitnessCondition interface and returns condition type.
type ConditionCalledByGroup ¶
ConditionCalledByGroup is a condition matching calling script group.
func (*ConditionCalledByGroup) Copy ¶
func (c *ConditionCalledByGroup) Copy() WitnessCondition
Copy implements the WitnessCondition interface and returns a deep copy of the condition.
func (*ConditionCalledByGroup) DecodeBinarySpecific ¶
func (c *ConditionCalledByGroup) DecodeBinarySpecific(r *io.BinReader, _ int)
DecodeBinarySpecific implements the WitnessCondition interface allowing to deserialize condition-specific data.
func (*ConditionCalledByGroup) EncodeBinary ¶
func (c *ConditionCalledByGroup) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the WitnessCondition interface allowing to serialize condition.
func (*ConditionCalledByGroup) MarshalJSON ¶
func (c *ConditionCalledByGroup) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ConditionCalledByGroup) Match ¶
func (c *ConditionCalledByGroup) Match(ctx MatchContext) (bool, error)
Match implements the WitnessCondition interface checking whether this condition matches given context.
func (*ConditionCalledByGroup) ToStackItem ¶
func (c *ConditionCalledByGroup) ToStackItem() stackitem.Item
ToStackItem implements WitnessCondition interface allowing to convert to stackitem.Item.
func (*ConditionCalledByGroup) Type ¶
func (c *ConditionCalledByGroup) Type() WitnessConditionType
Type implements the WitnessCondition interface and returns condition type.
type ConditionGroup ¶
ConditionGroup is a condition matching executing script group.
func (*ConditionGroup) Copy ¶
func (c *ConditionGroup) Copy() WitnessCondition
Copy implements the WitnessCondition interface and returns a deep copy of the condition.
func (*ConditionGroup) DecodeBinarySpecific ¶
func (c *ConditionGroup) DecodeBinarySpecific(r *io.BinReader, _ int)
DecodeBinarySpecific implements the WitnessCondition interface allowing to deserialize condition-specific data.
func (*ConditionGroup) EncodeBinary ¶
func (c *ConditionGroup) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the WitnessCondition interface allowing to serialize condition.
func (*ConditionGroup) MarshalJSON ¶
func (c *ConditionGroup) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ConditionGroup) Match ¶
func (c *ConditionGroup) Match(ctx MatchContext) (bool, error)
Match implements the WitnessCondition interface checking whether this condition matches given context.
func (*ConditionGroup) ToStackItem ¶
func (c *ConditionGroup) ToStackItem() stackitem.Item
ToStackItem implements the WitnessCondition interface allowing to convert to stackitem.Item.
func (*ConditionGroup) Type ¶
func (c *ConditionGroup) Type() WitnessConditionType
Type implements the WitnessCondition interface and returns condition type.
type ConditionNot ¶
type ConditionNot struct {
Condition WitnessCondition
}
ConditionNot inverses the meaning of contained condition.
func (*ConditionNot) Copy ¶
func (c *ConditionNot) Copy() WitnessCondition
Copy implements the WitnessCondition interface and returns a deep copy of the condition.
func (*ConditionNot) DecodeBinarySpecific ¶
func (c *ConditionNot) DecodeBinarySpecific(r *io.BinReader, maxDepth int)
DecodeBinarySpecific implements the WitnessCondition interface allowing to deserialize condition-specific data.
func (*ConditionNot) EncodeBinary ¶
func (c *ConditionNot) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the WitnessCondition interface allowing to serialize condition.
func (*ConditionNot) MarshalJSON ¶
func (c *ConditionNot) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ConditionNot) Match ¶
func (c *ConditionNot) Match(ctx MatchContext) (bool, error)
Match implements the WitnessCondition interface checking whether this condition matches given context.
func (*ConditionNot) ToStackItem ¶
func (c *ConditionNot) ToStackItem() stackitem.Item
ToStackItem implements the WitnessCondition interface allowing to convert to stackitem.Item.
func (*ConditionNot) Type ¶
func (c *ConditionNot) Type() WitnessConditionType
Type implements the WitnessCondition interface and returns condition type.
type ConditionOr ¶
type ConditionOr []WitnessCondition
ConditionOr is a set of conditions one of which is required to match.
func (*ConditionOr) Copy ¶
func (c *ConditionOr) Copy() WitnessCondition
Copy implements the WitnessCondition interface and returns a deep copy of the condition.
func (*ConditionOr) DecodeBinarySpecific ¶
func (c *ConditionOr) DecodeBinarySpecific(r *io.BinReader, maxDepth int)
DecodeBinarySpecific implements the WitnessCondition interface allowing to deserialize condition-specific data.
func (*ConditionOr) EncodeBinary ¶
func (c *ConditionOr) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the WitnessCondition interface allowing to serialize condition.
func (*ConditionOr) MarshalJSON ¶
func (c *ConditionOr) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ConditionOr) Match ¶
func (c *ConditionOr) Match(ctx MatchContext) (bool, error)
Match implements the WitnessCondition interface checking whether this condition matches given context.
func (*ConditionOr) ToStackItem ¶
func (c *ConditionOr) ToStackItem() stackitem.Item
ToStackItem implements the WitnessCondition interface allowing to convert to stackitem.Item.
func (*ConditionOr) Type ¶
func (c *ConditionOr) Type() WitnessConditionType
Type implements the WitnessCondition interface and returns condition type.
type ConditionScriptHash ¶
ConditionScriptHash is a condition matching executing script hash.
func (*ConditionScriptHash) Copy ¶
func (c *ConditionScriptHash) Copy() WitnessCondition
Copy implements the WitnessCondition interface and returns a deep copy of the condition.
func (*ConditionScriptHash) DecodeBinarySpecific ¶
func (c *ConditionScriptHash) DecodeBinarySpecific(r *io.BinReader, _ int)
DecodeBinarySpecific implements the WitnessCondition interface allowing to deserialize condition-specific data.
func (*ConditionScriptHash) EncodeBinary ¶
func (c *ConditionScriptHash) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the WitnessCondition interface allowing to serialize condition.
func (*ConditionScriptHash) MarshalJSON ¶
func (c *ConditionScriptHash) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ConditionScriptHash) Match ¶
func (c *ConditionScriptHash) Match(ctx MatchContext) (bool, error)
Match implements the WitnessCondition interface checking whether this condition matches given context.
func (*ConditionScriptHash) ToStackItem ¶
func (c *ConditionScriptHash) ToStackItem() stackitem.Item
ToStackItem implements the WitnessCondition interface allowing to convert to stackitem.Item.
func (*ConditionScriptHash) Type ¶
func (c *ConditionScriptHash) Type() WitnessConditionType
Type implements the WitnessCondition interface and returns condition type.
type Conflicts ¶
Conflicts represents attribute for conflicting transactions.
func (*Conflicts) DecodeBinary ¶
DecodeBinary implements the io.Serializable interface.
func (*Conflicts) EncodeBinary ¶
EncodeBinary implements the io.Serializable interface.
type MatchContext ¶
type MatchContext interface { GetCallingScriptHash() util.Uint160 GetCurrentScriptHash() util.Uint160 CallingScriptHasGroup(*keys.PublicKey) (bool, error) CurrentScriptHasGroup(*keys.PublicKey) (bool, error) IsCalledByEntry() bool }
MatchContext is a set of methods from execution engine needed to perform the witness check.
type NotValidBefore ¶
type NotValidBefore struct {
Height uint32 `json:"height"`
}
NotValidBefore represents attribute with the height transaction is not valid before.
func (*NotValidBefore) Copy ¶
func (n *NotValidBefore) Copy() AttrValue
Copy implements the AttrValue interface.
func (*NotValidBefore) DecodeBinary ¶
func (n *NotValidBefore) DecodeBinary(br *io.BinReader)
DecodeBinary implements the io.Serializable interface.
func (*NotValidBefore) EncodeBinary ¶
func (n *NotValidBefore) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the io.Serializable interface.
type NotaryAssisted ¶
type NotaryAssisted struct {
NKeys uint8 `json:"nkeys"`
}
NotaryAssisted represents attribute for notary service transactions.
func (*NotaryAssisted) Copy ¶
func (n *NotaryAssisted) Copy() AttrValue
Copy implements the AttrValue interface.
func (*NotaryAssisted) DecodeBinary ¶
func (n *NotaryAssisted) DecodeBinary(br *io.BinReader)
DecodeBinary implements the io.Serializable interface.
func (*NotaryAssisted) EncodeBinary ¶
func (n *NotaryAssisted) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the io.Serializable interface.
type OracleResponse ¶
type OracleResponse struct { ID uint64 `json:"id"` Code OracleResponseCode `json:"code"` Result []byte `json:"result"` }
OracleResponse represents oracle response.
func (*OracleResponse) Copy ¶
func (r *OracleResponse) Copy() AttrValue
Copy implements the AttrValue interface.
func (*OracleResponse) DecodeBinary ¶
func (r *OracleResponse) DecodeBinary(br *io.BinReader)
DecodeBinary implements the io.Serializable interface.
func (*OracleResponse) EncodeBinary ¶
func (r *OracleResponse) EncodeBinary(w *io.BinWriter)
EncodeBinary implements the io.Serializable interface.
type OracleResponseCode ¶
type OracleResponseCode byte
OracleResponseCode represents result code of oracle response.
const ( Success OracleResponseCode = 0x00 ProtocolNotSupported OracleResponseCode = 0x10 ConsensusUnreachable OracleResponseCode = 0x12 NotFound OracleResponseCode = 0x14 Timeout OracleResponseCode = 0x16 Forbidden OracleResponseCode = 0x18 ResponseTooLarge OracleResponseCode = 0x1a InsufficientFunds OracleResponseCode = 0x1c ContentTypeNotSupported OracleResponseCode = 0x1f Error OracleResponseCode = 0xff )
Enumeration of possible oracle response types.
func (OracleResponseCode) IsValid ¶
func (c OracleResponseCode) IsValid() bool
IsValid checks if c is valid response code.
func (OracleResponseCode) MarshalJSON ¶
func (c OracleResponseCode) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (OracleResponseCode) String ¶
func (i OracleResponseCode) String() string
func (*OracleResponseCode) UnmarshalJSON ¶
func (c *OracleResponseCode) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type Reserved ¶
type Reserved struct {
Value []byte
}
Reserved represents an attribute for experimental or private usage.
func (*Reserved) DecodeBinary ¶
DecodeBinary implements the io.Serializable interface.
func (*Reserved) EncodeBinary ¶
EncodeBinary implements the io.Serializable interface.
type Signer ¶
type Signer struct { Account util.Uint160 `json:"account"` Scopes WitnessScope `json:"scopes"` AllowedContracts []util.Uint160 `json:"allowedcontracts,omitempty"` AllowedGroups []*keys.PublicKey `json:"allowedgroups,omitempty"` Rules []WitnessRule `json:"rules,omitempty"` }
Signer implements a Transaction signer.
func (*Signer) DecodeBinary ¶
DecodeBinary implements the Serializable interface.
func (*Signer) EncodeBinary ¶
EncodeBinary implements the 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. E.g. if VUB=N, then transaction // can be accepted to block with index N, but not to block with index N+1. 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 // 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 ¶
func New(script []byte, gas int64) *Transaction
New returns a new transaction to execute given script and pay given system fee.
func NewTransactionFromBytes ¶
func NewTransactionFromBytes(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) Copy ¶
func (t *Transaction) Copy() *Transaction
Copy creates a deep copy of the Transaction, including all slice fields. Cached values like 'hashed' and 'size' are reset to ensure the copy can be modified independently of the original.
func (*Transaction) DecodeBinary ¶
func (t *Transaction) DecodeBinary(br *io.BinReader)
DecodeBinary implements the Serializable interface.
func (*Transaction) DecodeHashableFields ¶
func (t *Transaction) DecodeHashableFields(buf []byte) error
DecodeHashableFields decodes a part of transaction which should be hashed.
func (*Transaction) EncodeBinary ¶
func (t *Transaction) EncodeBinary(bw *io.BinWriter)
EncodeBinary implements the Serializable interface.
func (*Transaction) EncodeHashableFields ¶
func (t *Transaction) EncodeHashableFields() ([]byte, error)
EncodeHashableFields returns serialized transaction's fields which are hashed.
func (*Transaction) FeePerByte ¶
func (t *Transaction) FeePerByte() int64
FeePerByte returns NetworkFee of the transaction divided by its size.
func (*Transaction) GetAttributes ¶
func (t *Transaction) GetAttributes(typ AttrType) []Attribute
GetAttributes returns the list of transaction's attributes of the given type. Returns nil in case if attributes not found.
func (*Transaction) HasAttribute ¶
func (t *Transaction) HasAttribute(typ AttrType) bool
HasAttribute returns true iff t has an attribute of type typ.
func (*Transaction) HasSigner ¶
func (t *Transaction) HasSigner(hash util.Uint160) bool
HasSigner returns true in case if hash is present in the list of signers.
func (*Transaction) Hash ¶
func (t *Transaction) Hash() util.Uint256
Hash returns the hash of the transaction.
func (*Transaction) MarshalJSON ¶
func (t *Transaction) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*Transaction) Sender ¶
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) Size ¶
func (t *Transaction) Size() int
Size returns size of the serialized transaction.
func (*Transaction) ToStackItem ¶
func (t *Transaction) ToStackItem() stackitem.Item
ToStackItem converts Transaction to stackitem.Item.
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type Witness ¶
type Witness struct { InvocationScript []byte `json:"invocation"` VerificationScript []byte `json:"verification"` }
Witness contains 2 scripts.
func (*Witness) DecodeBinary ¶
DecodeBinary implements the Serializable interface.
func (*Witness) EncodeBinary ¶
EncodeBinary implements the Serializable interface.
func (Witness) ScriptHash ¶
ScriptHash returns the hash of the VerificationScript.
type WitnessAction ¶
type WitnessAction byte
WitnessAction represents an action to perform in WitnessRule if WitnessCondition matches.
const ( // WitnessDeny rejects current witness if condition is met. WitnessDeny WitnessAction = 0 // Deny // WitnessAllow approves current witness if condition is met. WitnessAllow WitnessAction = 1 // Allow )
func (WitnessAction) String ¶
func (i WitnessAction) String() string
type WitnessCondition ¶
type WitnessCondition interface { // Type returns a type of this condition. Type() WitnessConditionType // Match checks whether this condition matches current context. Match(MatchContext) (bool, error) // EncodeBinary allows to serialize condition to its binary // representation (including type data). EncodeBinary(*io.BinWriter) // DecodeBinarySpecific decodes type-specific binary data from the given // reader (not including type data). DecodeBinarySpecific(*io.BinReader, int) // ToStackItem converts WitnessCondition to stackitem.Item. ToStackItem() stackitem.Item // Copy returns a deep copy of the condition. Copy() WitnessCondition json.Marshaler }
WitnessCondition is a condition of WitnessRule.
func DecodeBinaryCondition ¶
func DecodeBinaryCondition(r *io.BinReader) WitnessCondition
DecodeBinaryCondition decodes and returns condition from the given binary stream.
func UnmarshalConditionJSON ¶
func UnmarshalConditionJSON(data []byte) (WitnessCondition, error)
UnmarshalConditionJSON unmarshalls condition from the given JSON data.
type WitnessConditionType ¶
type WitnessConditionType byte
WitnessConditionType encodes a type of witness condition.
const ( // WitnessBoolean is a generic boolean condition. WitnessBoolean WitnessConditionType = 0x00 // Boolean // WitnessNot reverses another condition. WitnessNot WitnessConditionType = 0x01 // Not // WitnessAnd means that all conditions must be met. WitnessAnd WitnessConditionType = 0x02 // And // WitnessOr means that any of conditions must be met. WitnessOr WitnessConditionType = 0x03 // Or // WitnessScriptHash matches executing contract's script hash. WitnessScriptHash WitnessConditionType = 0x18 // ScriptHash // WitnessGroup matches executing contract's group key. WitnessGroup WitnessConditionType = 0x19 // Group // WitnessCalledByEntry matches when current script is an entry script or is called by an entry script. WitnessCalledByEntry WitnessConditionType = 0x20 // CalledByEntry // WitnessCalledByContract matches when current script is called by the specified contract. WitnessCalledByContract WitnessConditionType = 0x28 // CalledByContract // WitnessCalledByGroup matches when current script is called by contract belonging to the specified group. WitnessCalledByGroup WitnessConditionType = 0x29 // CalledByGroup // MaxConditionNesting limits the maximum allowed level of condition nesting. MaxConditionNesting = 2 )
func (WitnessConditionType) String ¶
func (i WitnessConditionType) String() string
type WitnessRule ¶
type WitnessRule struct { Action WitnessAction `json:"action"` Condition WitnessCondition `json:"condition"` }
WitnessRule represents a single rule for Rules witness scope.
func (*WitnessRule) Copy ¶
func (w *WitnessRule) Copy() *WitnessRule
Copy creates a deep copy of the WitnessRule.
func (*WitnessRule) DecodeBinary ¶
func (w *WitnessRule) DecodeBinary(br *io.BinReader)
DecodeBinary implements the Serializable interface.
func (*WitnessRule) EncodeBinary ¶
func (w *WitnessRule) EncodeBinary(bw *io.BinWriter)
EncodeBinary implements the Serializable interface.
func (*WitnessRule) MarshalJSON ¶
func (w *WitnessRule) MarshalJSON() ([]byte, error)
UnmarshalJSON implements the json.Unmarshaler interface.
func (*WitnessRule) ToStackItem ¶
func (w *WitnessRule) ToStackItem() stackitem.Item
ToStackItem implements Convertible interface.
func (*WitnessRule) UnmarshalJSON ¶
func (w *WitnessRule) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type WitnessScope ¶
type WitnessScope byte
WitnessScope represents set of witness flags for Transaction signer.
const ( // None specifies that no contract was witnessed. Only sign the transaction. None WitnessScope = 0 // CalledByEntry witness is only valid in entry script and ones directly called by it. // 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 // Rules is a set of conditions with boolean operators. Rules WitnessScope = 0x40 // WitnessRules // Global allows this witness in all contexts (default Neo2 behavior). // This cannot be combined with other flags. Global WitnessScope = 0x80 )
func ScopesFromByte ¶
func ScopesFromByte(b byte) (WitnessScope, error)
ScopesFromByte converts byte to a set of WitnessScopes and performs validity check.
func ScopesFromString ¶
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 ¶
func (s WitnessScope) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (WitnessScope) String ¶
func (i WitnessScope) String() string
func (*WitnessScope) UnmarshalJSON ¶
func (s *WitnessScope) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
Source Files ¶
- attribute.go
- attrtype.go
- attrtype_string.go
- conflicts.go
- doc.go
- not_valid_before.go
- notary_assisted.go
- oracle.go
- oracleresponsecode_string.go
- reserved.go
- signer.go
- transaction.go
- witness.go
- witness_condition.go
- witness_rule.go
- witness_scope.go
- witness_scope_string.go
- witnessaction_string.go
- witnessconditiontype_string.go