tx

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Success OracleResponseCode = 0x00

	ProtocolNotSupported = 0x10
	ConsensusUnreachable = 0x12
	NotFound             = 0x14
	Timeout              = 0x16
	Forbidden            = 0x18
	ResponseTooLarge     = 0x1a
	InsufficientFunds    = 0x1c

	Error = 0xff
)
View Source
const (
	TransactionVersion          uint8  = 0
	MaxTransactionSize                 = 102400
	MaxValidUntilBlockIncrement uint32 = 5760 // 24 hours
	MaxTransactionAttributes           = 16   // Maximum number of attributes that can be contained within a transaction
	MaxSigners                         = 16   // Maximum number of cosigners that can be contained within a transaction
)
View Source
const ECDsaVerifyPrice = 1 << 15
View Source
const ExecFeeFactor = 30
View Source
const FeePerByte = 1000
View Source
const GasFactor = 100000000
View Source
const GasTokenId = "0xd2a4cff31913016155e38e474a2c06d08be276cf"
View Source
const MaxInvocationScript = 1024

MaxInvocationScript This is designed to allow a MultiSig 21/11 (committee) Invocation = 11 * (64 + 2) = 726

View Source
const (
	MaxSubitems = 16 // This limits maximum number of AllowedContracts or AllowedGroups here.
)
View Source
const MaxVerificationScript = 1024

MaxVerificationScript Verification = m + (PUSH_PubKey * 21) + length + null + syscall = 1 + ((2 + 33) * 21) + 2 + 1 + 5 = 744

View Source
const NeoTokenId = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"

Variables

Functions

func CalculateHash

func CalculateHash(verifiable IVerifiable) *helper.UInt256

func CreateInvocationScript added in v0.2.3

func CreateInvocationScript(msg []byte, pairs []*keys.KeyPair) ([]byte, error)

CreateInvocationScript pushes signature

func GetSignData

func GetSignData(verifiable IVerifiable, magic uint32) []byte

func VerifyMultiSignatureWitness added in v0.2.3

func VerifyMultiSignatureWitness(msg []byte, witness *Witness) bool

func VerifySignatureWitness added in v0.2.3

func VerifySignatureWitness(msg []byte, witness *Witness) bool

Types

type HighPriorityAttribute

type HighPriorityAttribute struct {
}

only committee can use this attribute

func (*HighPriorityAttribute) AllowMultiple

func (h *HighPriorityAttribute) AllowMultiple() bool

func (*HighPriorityAttribute) Deserialize

func (h *HighPriorityAttribute) Deserialize(br *io.BinaryReader)

func (*HighPriorityAttribute) DeserializeWithoutType

func (h *HighPriorityAttribute) DeserializeWithoutType(br *io.BinaryReader)

func (*HighPriorityAttribute) GetAttributeSize

func (h *HighPriorityAttribute) GetAttributeSize() int

func (*HighPriorityAttribute) GetAttributeType

func (h *HighPriorityAttribute) GetAttributeType() TransactionAttributeType

func (*HighPriorityAttribute) Serialize

func (h *HighPriorityAttribute) Serialize(bw *io.BinaryWriter)

func (*HighPriorityAttribute) SerializeWithoutType

func (h *HighPriorityAttribute) SerializeWithoutType(bw *io.BinaryWriter)

type ITransactionAttribute

type ITransactionAttribute interface {
	GetAttributeType() TransactionAttributeType
	AllowMultiple() bool
	GetAttributeSize() int

	Deserialize(br *io.BinaryReader)
	Serialize(bw *io.BinaryWriter)
	DeserializeWithoutType(br *io.BinaryReader)
	SerializeWithoutType(bw *io.BinaryWriter)
}

func CreateTransactionAttribute

func CreateTransactionAttribute(attributeType TransactionAttributeType) ITransactionAttribute

func DeserializeFrom

func DeserializeFrom(br *io.BinaryReader) ITransactionAttribute

type IVerifiable

type IVerifiable interface {
	GetHash() *helper.UInt256
	GetSize() int

	Deserialize(br *io.BinaryReader)
	Serialize(bw *io.BinaryWriter)
	DeserializeUnsigned(br *io.BinaryReader)
	SerializeUnsigned(bw *io.BinaryWriter)

	GetWitnesses() []*Witness
	SetWitnesses(data []*Witness)
	GetScriptHashesForVerifying() []*helper.UInt160
}

type OracleResponseAttribute

type OracleResponseAttribute struct {
	FixedScript []byte
	Id          uint64
	Code        OracleResponseCode
	Result      []byte
}

only oracle can use this attribute

func NewOracleResponseAttribute

func NewOracleResponseAttribute() (*OracleResponseAttribute, error)

func (*OracleResponseAttribute) AllowMultiple

func (o *OracleResponseAttribute) AllowMultiple() bool

func (*OracleResponseAttribute) Deserialize

func (o *OracleResponseAttribute) Deserialize(br *io.BinaryReader)

func (*OracleResponseAttribute) DeserializeWithoutType

func (o *OracleResponseAttribute) DeserializeWithoutType(br *io.BinaryReader)

func (*OracleResponseAttribute) GetAttributeSize

func (o *OracleResponseAttribute) GetAttributeSize() int

func (*OracleResponseAttribute) GetAttributeType

func (o *OracleResponseAttribute) GetAttributeType() TransactionAttributeType

func (*OracleResponseAttribute) GetMaxResultSize

func (o *OracleResponseAttribute) GetMaxResultSize() int

func (*OracleResponseAttribute) Serialize

func (o *OracleResponseAttribute) Serialize(bw *io.BinaryWriter)

func (*OracleResponseAttribute) SerializeWithoutType

func (o *OracleResponseAttribute) SerializeWithoutType(bw *io.BinaryWriter)

type OracleResponseCode

type OracleResponseCode byte

func (OracleResponseCode) IsDefined

func (code OracleResponseCode) IsDefined() bool

type Signer

type Signer struct {
	Account          *helper.UInt160
	Scopes           WitnessScope
	AllowedContracts []*helper.UInt160
	AllowedGroups    []*crypto.ECPoint
	Rules            []*WitnessRule
}

func NewDefaultSigner

func NewDefaultSigner() *Signer

func NewSigner

func NewSigner(account *helper.UInt160, scopes WitnessScope) *Signer

func (*Signer) CompareTo

func (c *Signer) CompareTo(d *Signer) int

func (*Signer) Deserialize

func (c *Signer) Deserialize(br *io.BinaryReader)

Deserialize implements Serializable interface.

func (*Signer) GetSize added in v1.2.0

func (c *Signer) GetSize() int

func (*Signer) Serialize

func (c *Signer) Serialize(bw *io.BinaryWriter)

type SignerSlice

type SignerSlice []*Signer

func (SignerSlice) GetVarSize

func (cs SignerSlice) GetVarSize() int

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction() *Transaction

func (*Transaction) Deserialize

func (tx *Transaction) Deserialize(br *io.BinaryReader)

Deserialize implements Serializable interface.

func (*Transaction) DeserializeUnsigned

func (tx *Transaction) DeserializeUnsigned(br *io.BinaryReader)

func (*Transaction) DeserializeWitnesses

func (tx *Transaction) DeserializeWitnesses(br *io.BinaryReader)

func (*Transaction) FeePerByte

func (tx *Transaction) FeePerByte() int64

FeePerByte is The NetworkFee for the transaction divided by its GetSize. Note that this property must be used with care. Getting the value of this property multiple times will return the same result. The value of this property can only be obtained after the transaction has been completely built (no longer modified).

func (*Transaction) GetAttributes

func (tx *Transaction) GetAttributes() []ITransactionAttribute

GetAttributes is the getter of tx.attributes

func (*Transaction) GetHash

func (tx *Transaction) GetHash() *helper.UInt256

GetHash is the getter of tx._hash, using default magic

func (*Transaction) GetNetworkFee

func (tx *Transaction) GetNetworkFee() int64

GetNetworkFee is the getter of tx.netfee

func (*Transaction) GetNonce

func (tx *Transaction) GetNonce() uint32

GetNonce is the getter of tx.nonce

func (*Transaction) GetScript

func (tx *Transaction) GetScript() []byte

GetScript is the getter of tx.script

func (*Transaction) GetScriptHashesForVerifying

func (tx *Transaction) GetScriptHashesForVerifying() []*helper.UInt160

func (*Transaction) GetSender

func (tx *Transaction) GetSender() *helper.UInt160

GetSender

func (*Transaction) GetSigners

func (tx *Transaction) GetSigners() []*Signer

GetSigners is the getter of tx.signers

func (*Transaction) GetSize

func (tx *Transaction) GetSize() int

GetSize is the getter of tx._size

func (*Transaction) GetSystemFee

func (tx *Transaction) GetSystemFee() int64

GetSystemFee is the getter of tx.sysfee

func (*Transaction) GetValidUntilBlock

func (tx *Transaction) GetValidUntilBlock() uint32

GetValidUntilBlock is the getter of tx.validUntilBlock

func (*Transaction) GetVersion

func (tx *Transaction) GetVersion() uint8

GetVersion is the getter of tx.version

func (*Transaction) GetWitnesses

func (tx *Transaction) GetWitnesses() []*Witness

GetWitnesses is the getter of tx.witnesses

func (*Transaction) HeaderSize

func (tx *Transaction) HeaderSize() int

func (*Transaction) Serialize

func (tx *Transaction) Serialize(bw *io.BinaryWriter)

Serialize implements Serializable interface.

func (*Transaction) SerializeUnsigned

func (tx *Transaction) SerializeUnsigned(bw *io.BinaryWriter)

func (*Transaction) SerializeWitnesses

func (tx *Transaction) SerializeWitnesses(bw *io.BinaryWriter)

func (*Transaction) SetAttributes

func (tx *Transaction) SetAttributes(value []ITransactionAttribute)

SetAttributes is the setter of tx.attributes

func (*Transaction) SetNetworkFee

func (tx *Transaction) SetNetworkFee(value int64)

SetNetworkFee is the setter of tx.netfee

func (*Transaction) SetNonce

func (tx *Transaction) SetNonce(value uint32)

SetNonce is the setter of tx.nonce

func (*Transaction) SetScript

func (tx *Transaction) SetScript(value []byte)

SetScript is the setter of tx.script

func (*Transaction) SetSigners

func (tx *Transaction) SetSigners(value []*Signer)

SetSigners is the setter of tx.signers

func (*Transaction) SetSystemFee

func (tx *Transaction) SetSystemFee(value int64)

SetSystemFee is the setter of tx.sysfee

func (*Transaction) SetValidUntilBlock

func (tx *Transaction) SetValidUntilBlock(value uint32)

SetValidUntilBlock is the setter of tx.validUntilBlock

func (*Transaction) SetVersion

func (tx *Transaction) SetVersion(value uint8)

SetVersion is the setter of tx.version

func (*Transaction) SetWitnesses

func (tx *Transaction) SetWitnesses(value []*Witness)

SetWitnesses is the setter of tx.witnesses

func (*Transaction) ToByteArray

func (tx *Transaction) ToByteArray() []byte

ToByteArray returns signed tx data

type TransactionAttributeSlice

type TransactionAttributeSlice []ITransactionAttribute

func (TransactionAttributeSlice) GetVarSize

func (ts TransactionAttributeSlice) GetVarSize() int

type TransactionAttributeType

type TransactionAttributeType byte

Transaction attribute type

const (
	HighPriority   TransactionAttributeType = 0x01 //
	OracleResponse TransactionAttributeType = 0x11
)

func (TransactionAttributeType) IsDefined

func (u TransactionAttributeType) IsDefined() bool

func (TransactionAttributeType) String

func (u TransactionAttributeType) String() string

type Witness

type Witness struct {
	InvocationScript   []byte // signature
	VerificationScript []byte // pub key
	// contains filtered or unexported fields
}

func CreateContractWitness

func CreateContractWitness(msg []byte, pairs []*keys.KeyPair, contract *sc.Contract) (*Witness, error)

CreateContractWitness creates single signature witness

func CreateMultiSignatureWitness added in v0.2.3

func CreateMultiSignatureWitness(msg []byte, pairs []*keys.KeyPair, least int, publicKeys []*crypto.ECPoint) (*Witness, error)

CreateMultiSignatureWitness creates multi signatures witness

func CreateSignatureWitness added in v0.2.3

func CreateSignatureWitness(msg []byte, pair *keys.KeyPair) (*Witness, error)

CreateSignatureWitness creates single signature witness

func CreateWitness

func CreateWitness(invocationScript []byte, verificationScript []byte) (*Witness, error)

CreateWitness with invocationScript and verificationScript

func CreateWitnessWithScriptHash

func CreateWitnessWithScriptHash(scriptHash *helper.UInt160, invocationScript []byte) (witness *Witness)

CreateWitnessWithScriptHash is only used for empty VerificationScript, neo blockchain will search the contract script with scriptHash

func (*Witness) Deserialize

func (w *Witness) Deserialize(br *io.BinaryReader)

Deserialize implements Serializable interface.

func (*Witness) GetScriptHash

func (w *Witness) GetScriptHash() *helper.UInt160

func (*Witness) GetSize added in v1.2.0

func (w *Witness) GetSize() int

func (*Witness) MarshalJSON

func (w *Witness) MarshalJSON() ([]byte, error)

MarshalJSON implements the json marshaller interface.

func (*Witness) Serialize

func (w *Witness) Serialize(bw *io.BinaryWriter)

Serialize implements Serializable interface.

type WitnessRule added in v1.2.0

type WitnessRule struct {
	Action    WitnessRuleAction
	Condition *conditions.WitnessCondition
}

func (*WitnessRule) Deserialize added in v1.2.0

func (this *WitnessRule) Deserialize(br *io.BinaryReader)

func (*WitnessRule) GetSize added in v1.2.0

func (this *WitnessRule) GetSize() int

func (*WitnessRule) Serialize added in v1.2.0

func (this *WitnessRule) Serialize(bw *io.BinaryWriter)

type WitnessRuleAction added in v1.2.0

type WitnessRuleAction byte
const (
	Deny  WitnessRuleAction = 0
	Allow WitnessRuleAction = 1
)

func (WitnessRuleAction) GetSize added in v1.2.0

func (this WitnessRuleAction) GetSize() int

func (WitnessRuleAction) String added in v1.2.0

func (this WitnessRuleAction) String() string

type WitnessScope

type WitnessScope byte
const (
	// None indicates that No contract was witnessed. Only sign the transaction.
	None WitnessScope = 0x00

	// CalledByEntry means that this condition must hold: EntryScriptHash == CallingScriptHash
	// 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 represents Custom hash for contract-specific.
	CustomContracts WitnessScope = 0x10

	// CustomGroups represents Custom public key for group members.
	CustomGroups WitnessScope = 0x20

	// WitnessRules Indicates that the current context must satisfy the specified rules.
	WitnessRules WitnessScope = 0x40

	// Global allows this witness in all contexts (default Neo2 behavior).
	// Note: It cannot be combined with other flags.
	Global WitnessScope = 0x80
)

func (WitnessScope) CompareTo

func (w WitnessScope) CompareTo(other WitnessScope) int

func (WitnessScope) String

func (w WitnessScope) String() string

type WitnessSlice

type WitnessSlice []Witness

func (WitnessSlice) Len

func (ws WitnessSlice) Len() int

func (WitnessSlice) Less

func (ws WitnessSlice) Less(i, j int) bool

func (WitnessSlice) Swap

func (ws WitnessSlice) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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