Documentation ¶
Index ¶
- Constants
- func GroupInputsByPrevHash(ins []Input) [][]*Input
- func HaveDuplicateInputs(ins []Input) bool
- type AssetType
- type AttrUsage
- type Attribute
- type ClaimTX
- type ContractTX
- type DescStateType
- type EnrollmentTX
- type InOut
- type Input
- type InvocationTX
- type IssueTX
- type MinerTX
- type Output
- type PublishTX
- type RegisterTX
- type Result
- type StateDescriptor
- type StateTX
- type TXType
- type TXer
- type Transaction
- func (t *Transaction) AddInput(in *Input)
- func (t *Transaction) AddOutput(out *Output)
- func (t *Transaction) AddVerificationHash(addr util.Uint160)
- func (t *Transaction) Bytes() []byte
- func (t *Transaction) DecodeBinary(br *io.BinReader)
- func (t *Transaction) EncodeBinary(bw *io.BinWriter)
- func (t *Transaction) GetSignedPart() []byte
- func (t Transaction) GroupOutputByAssetID() map[util.Uint256][]*Output
- func (t *Transaction) Hash() util.Uint256
- func (t *Transaction) VerificationHash() util.Uint256
- type Witness
Constants ¶
const ( // MaxTransactionSize is the upper limit size in bytes that a transaction can reach. It is // set to be 102400. MaxTransactionSize = 102400 )
Variables ¶
This section is empty.
Functions ¶
func GroupInputsByPrevHash ¶
GroupInputsByPrevHash groups all TX inputs by their previous hash into several slices (which actually are subslices of one new slice with pointers). Each of these slices contains at least one element.
func HaveDuplicateInputs ¶
HaveDuplicateInputs checks inputs for duplicates and returns true if there are any.
Types ¶
type AttrUsage ¶
type AttrUsage uint8
AttrUsage represents the purpose of the attribute.
const ( ContractHash AttrUsage = 0x00 ECDH02 AttrUsage = 0x02 ECDH03 AttrUsage = 0x03 Script AttrUsage = 0x20 Vote AttrUsage = 0x30 CertURL AttrUsage = 0x80 DescriptionURL AttrUsage = 0x81 Description AttrUsage = 0x90 Hash1 AttrUsage = 0xa1 Hash2 AttrUsage = 0xa2 Hash3 AttrUsage = 0xa3 Hash4 AttrUsage = 0xa4 Hash5 AttrUsage = 0xa5 Hash6 AttrUsage = 0xa6 Hash7 AttrUsage = 0xa7 Hash8 AttrUsage = 0xa8 Hash9 AttrUsage = 0xa9 Hash10 AttrUsage = 0xaa Hash11 AttrUsage = 0xab Hash12 AttrUsage = 0xac Hash13 AttrUsage = 0xad Hash14 AttrUsage = 0xae Hash15 AttrUsage = 0xaf Remark AttrUsage = 0xf0 Remark1 AttrUsage = 0xf1 Remark2 AttrUsage = 0xf2 Remark3 AttrUsage = 0xf3 Remark4 AttrUsage = 0xf4 Remark5 AttrUsage = 0xf5 Remark6 AttrUsage = 0xf6 Remark7 AttrUsage = 0xf7 Remark8 AttrUsage = 0xf8 Remark9 AttrUsage = 0xf9 Remark10 AttrUsage = 0xfa Remark11 AttrUsage = 0xfb Remark12 AttrUsage = 0xfc Remark13 AttrUsage = 0xfd Remark14 AttrUsage = 0xfe Remark15 AttrUsage = 0xff )
List of valid attribute usages.
type Attribute ¶
Attribute represents a Transaction attribute.
func (*Attribute) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Attribute) EncodeBinary ¶
EncodeBinary implements Serializable interface.
func (*Attribute) MarshalJSON ¶
MarshalJSON implements the json Marshaller interface.
type ClaimTX ¶
type ClaimTX struct {
Claims []Input
}
ClaimTX represents a claim transaction.
func (*ClaimTX) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*ClaimTX) EncodeBinary ¶
EncodeBinary implements Serializable interface.
type ContractTX ¶
type ContractTX struct{}
ContractTX represents a contract transaction. This TX has not special attributes.
func (*ContractTX) DecodeBinary ¶
func (tx *ContractTX) DecodeBinary(r *io.BinReader)
DecodeBinary implements Serializable interface.
func (*ContractTX) EncodeBinary ¶
func (tx *ContractTX) EncodeBinary(w *io.BinWriter)
EncodeBinary implements Serializable interface.
type DescStateType ¶
type DescStateType uint8
DescStateType represents the type of StateDescriptor.
const ( Account DescStateType = 0x40 Validator DescStateType = 0x48 )
Valid DescStateType constants.
type EnrollmentTX ¶
EnrollmentTX transaction represents an enrollment form, which indicates that the sponsor of the transaction would like to sign up as a validator. The way to sign up is: To construct an EnrollmentTransaction type of transaction, and send a deposit to the address of the PublicKey. The way to cancel the registration is: Spend the deposit on the address of the PublicKey.
func (*EnrollmentTX) DecodeBinary ¶
func (tx *EnrollmentTX) DecodeBinary(r *io.BinReader)
DecodeBinary implements Serializable interface.
func (*EnrollmentTX) EncodeBinary ¶
func (tx *EnrollmentTX) EncodeBinary(w *io.BinWriter)
EncodeBinary implements Serializable interface.
type InOut ¶
InOut represents an Input bound to its corresponding Output which is a useful combination for many purposes.
type Input ¶
type Input struct { // The hash of the previous transaction. PrevHash util.Uint256 `json:"txid"` // The index of the previous transaction. PrevIndex uint16 `json:"vout"` }
Input represents a Transaction input (CoinReference).
func MapInputsToSorted ¶
MapInputsToSorted maps given slice of inputs into a new slice of pointers to inputs sorted by their PrevHash and PrevIndex.
func (*Input) Cmp ¶
Cmp compares two Inputs by their hash and index allowing to make a set of transactions ordered.
func (*Input) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Input) EncodeBinary ¶
EncodeBinary implements Serializable interface.
type InvocationTX ¶
type InvocationTX struct { // Script output of the smart contract. Script []byte // Gas cost of the smart contract. Gas util.Fixed8 Version uint8 }
InvocationTX represents a invocation transaction and is used to deploy smart contract to the NEO blockchain.
func (*InvocationTX) DecodeBinary ¶
func (tx *InvocationTX) DecodeBinary(br *io.BinReader)
DecodeBinary implements Serializable interface.
func (*InvocationTX) EncodeBinary ¶
func (tx *InvocationTX) EncodeBinary(bw *io.BinWriter)
EncodeBinary implements Serializable interface.
type IssueTX ¶
type IssueTX struct{}
IssueTX represents a issue transaction. This TX has not special attributes.
func (*IssueTX) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*IssueTX) EncodeBinary ¶
EncodeBinary implements Serializable interface.
type MinerTX ¶
type MinerTX struct { // Random number to avoid hash collision. Nonce uint32 }
MinerTX represents a miner transaction.
func (*MinerTX) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*MinerTX) EncodeBinary ¶
EncodeBinary implements Serializable interface.
type Output ¶
type Output struct { // The NEO asset id used in the transaction. AssetID util.Uint256 `json:"asset"` // Amount of AssetType send or received. Amount util.Fixed8 `json:"value"` // The address of the recipient. ScriptHash util.Uint160 `json:"address"` // The position of the Output in slice []Output. This is actually set in NewTransactionOutputRaw // and used for displaying purposes. Position int `json:"n"` }
Output represents a Transaction output.
func (*Output) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Output) EncodeBinary ¶
EncodeBinary implements Serializable interface.
func (*Output) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
func (*Output) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface.
type PublishTX ¶
type PublishTX struct { Script []byte ParamList []smartcontract.ParamType ReturnType smartcontract.ParamType NeedStorage bool Name string CodeVersion string Author string Email string Description string Version uint8 // Version of the parent struct Transaction. Used in reading NeedStorage flag. }
PublishTX represents a publish transaction. NOTE: This is deprecated and should no longer be used.
func (*PublishTX) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*PublishTX) EncodeBinary ¶
EncodeBinary implements Serializable interface.
type RegisterTX ¶
type RegisterTX struct { // The type of the asset being registered. AssetType AssetType // Name of the asset being registered. Name string // Amount registered. // Unlimited mode -0.00000001. Amount util.Fixed8 // Decimals. Precision uint8 // Public key of the owner. Owner keys.PublicKey Admin util.Uint160 }
RegisterTX represents a register transaction. NOTE: This is deprecated.
func (*RegisterTX) DecodeBinary ¶
func (tx *RegisterTX) DecodeBinary(br *io.BinReader)
DecodeBinary implements Serializable interface.
func (*RegisterTX) EncodeBinary ¶
func (tx *RegisterTX) EncodeBinary(bw *io.BinWriter)
EncodeBinary implements Serializable interface.
type StateDescriptor ¶
type StateDescriptor struct { Type DescStateType Key []byte Value []byte Field string }
StateDescriptor ..
func (*StateDescriptor) DecodeBinary ¶
func (s *StateDescriptor) DecodeBinary(r *io.BinReader)
DecodeBinary implements Serializable interface.
func (*StateDescriptor) EncodeBinary ¶
func (s *StateDescriptor) EncodeBinary(w *io.BinWriter)
EncodeBinary implements Serializable interface.
type StateTX ¶
type StateTX struct {
Descriptors []*StateDescriptor
}
StateTX represents a state transaction.
func (*StateTX) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*StateTX) EncodeBinary ¶
EncodeBinary implements Serializable interface.
type TXType ¶
type TXType uint8
TXType is the type of a transaction.
const ( MinerType TXType = 0x00 IssueType TXType = 0x01 ClaimType TXType = 0x02 EnrollmentType TXType = 0x20 VotingType TXType = 0x24 RegisterType TXType = 0x40 ContractType TXType = 0x80 StateType TXType = 0x90 AgencyType TXType = 0xb0 PublishType TXType = 0xd0 InvocationType TXType = 0xd1 )
Constants for all valid transaction types.
func TXTypeFromString ¶
TXTypeFromString searches for TXType by string name.
func (TXType) MarshalJSON ¶
MarshalJSON implements the json marshaller interface.
func (*TXType) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type TXer ¶
type TXer interface { io.Serializable }
TXer is interface that can act as the underlying data of a transaction.
type Transaction ¶
type Transaction struct { // The type of the transaction. Type TXType `json:"type"` // The trading version which is currently 0. Version uint8 `json:"version"` // Data specific to the type of the transaction. // This is always a pointer to a <Type>Transaction. Data TXer `json:"-"` // Transaction attributes. Attributes []Attribute `json:"attributes"` // The inputs of the transaction. Inputs []Input `json:"vin"` // The outputs of the transaction. Outputs []Output `json:"vout"` // The scripts that comes with this transaction. // Scripts exist out of the verification script // and invocation script. Scripts []Witness `json:"scripts"` // Trimmed indicates this is a transaction from trimmed // data. Trimmed bool `json:"-"` // contains filtered or unexported fields }
Transaction is a process recorded in the NEO blockchain.
func NewContractTX ¶
func NewContractTX() *Transaction
NewContractTX creates Transaction of ContractType type.
func NewInvocationTX ¶
func NewInvocationTX(script []byte, gas util.Fixed8) *Transaction
NewInvocationTX returns a new invocation transaction.
func NewTrimmedTX ¶
func NewTrimmedTX(hash util.Uint256) *Transaction
NewTrimmedTX returns a trimmed transaction with only its hash and Trimmed to true.
func (*Transaction) AddInput ¶
func (t *Transaction) AddInput(in *Input)
AddInput adds the given input to the transaction inputs.
func (*Transaction) AddOutput ¶
func (t *Transaction) AddOutput(out *Output)
AddOutput adds the given output to the transaction outputs.
func (*Transaction) AddVerificationHash ¶
func (t *Transaction) AddVerificationHash(addr util.Uint160)
AddVerificationHash adds a script attribute for transaction verification.
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) EncodeBinary ¶
func (t *Transaction) EncodeBinary(bw *io.BinWriter)
EncodeBinary implements Serializable interface.
func (*Transaction) GetSignedPart ¶
func (t *Transaction) GetSignedPart() []byte
GetSignedPart returns a part of the transaction which must be signed.
func (Transaction) GroupOutputByAssetID ¶
func (t Transaction) GroupOutputByAssetID() map[util.Uint256][]*Output
GroupOutputByAssetID groups all TX outputs by their assetID.
func (*Transaction) Hash ¶
func (t *Transaction) Hash() util.Uint256
Hash returns the hash of the transaction.
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 ¶
DecodeBinary implements Serializable interface.
func (*Witness) EncodeBinary ¶
EncodeBinary implements Serializable interface.
func (Witness) MarshalJSON ¶
MarshalJSON implements the json marshaller interface.
func (Witness) ScriptHash ¶
ScriptHash returns the hash of the VerificationScript.
func (*Witness) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface.