Documentation ¶
Index ¶
- Constants
- func CheckAssetPrecision(Tx *Transaction) error
- func CheckAttributeProgram(Tx *Transaction) error
- func CheckDuplicateInput(tx *Transaction) error
- func CheckInputOutputTooLong(tx *Transaction) bool
- func CheckTransactionBalance(txn *Transaction) error
- func CheckTransactionContracts(Tx *Transaction) error
- func CheckTransactionPayload(txn *Transaction) error
- func IsDoubleSpend(tx *Transaction) bool
- func IsValidAttributeType(usage TransactionAttributeUsage) bool
- func VerifyTransaction(Tx *Transaction) ErrCode
- func VerifyTransactionWithBlock(iterator Iterator) ErrCode
- func VerifyTransactionWithLedger(Tx *Transaction) ErrCode
- type Iterator
- type Payload
- type Transaction
- func NewCommitTransaction(sigChain []byte, submitter Uint160) (*Transaction, error)
- func NewDeleteNameTransaction(registrant []byte) (*Transaction, error)
- func NewIssueAssetTransaction(outputs []*TxnOutput) (*Transaction, error)
- func NewPrepaidTransaction(inputs []*TxnInput, changes *TxnOutput, assetID Uint256, amount, rates string) (*Transaction, error)
- func NewRegisterAssetTransaction(asset *asset.Asset, amount Fixed64, issuer *crypto.PubKey, conroller Uint160) (*Transaction, error)
- func NewRegisterNameTransaction(registrant []byte, name string) (*Transaction, error)
- func NewSubscribeTransaction(subscriber []byte, identifier string, topic string, duration uint32) (*Transaction, error)
- func NewTransferAssetTransaction(inputs []*TxnInput, outputs []*TxnOutput) (*Transaction, error)
- func NewWithdrawTransaction(output *TxnOutput) (*Transaction, error)
- func (tx *Transaction) Deserialize(r io.Reader) error
- func (tx *Transaction) DeserializeUnsigned(r io.Reader) error
- func (tx *Transaction) DeserializeUnsignedWithoutType(r io.Reader) error
- func (tx *Transaction) GenerateAssetMaps()
- func (tx *Transaction) GetMergedAssetIDValueFromOutputs() TransactionResult
- func (tx *Transaction) GetMergedAssetIDValueFromReference() (TransactionResult, error)
- func (tx *Transaction) GetMessage() []byte
- func (tx *Transaction) GetOutputHashes() ([]Uint160, error)
- func (tx *Transaction) GetProgramHashes() ([]Uint160, error)
- func (tx *Transaction) GetPrograms() []*program.Program
- func (tx *Transaction) GetReference() (map[*TxnInput]*TxnOutput, error)
- func (tx *Transaction) GetTransactionResults() (TransactionResult, error)
- func (tx *Transaction) Hash() Uint256
- func (tx *Transaction) MarshalJson() ([]byte, error)
- func (tx *Transaction) Serialize(w io.Writer) error
- func (tx *Transaction) SerializeUnsigned(w io.Writer) error
- func (tx *Transaction) SetHash(hash Uint256)
- func (tx *Transaction) SetPrograms(programs []*program.Program)
- func (tx *Transaction) ToArray() []byte
- func (tx *Transaction) Type() InventoryType
- func (tx *Transaction) UnmarshalJson(data []byte) error
- func (tx *Transaction) Verify() error
- type TransactionAttributeUsage
- type TransactionInfo
- type TransactionResult
- type TransactionType
- type TxnAttribute
- func (attr *TxnAttribute) Deserialize(r io.Reader) error
- func (attr *TxnAttribute) Equal(tx2 *TxnAttribute) bool
- func (attr *TxnAttribute) GetSize() uint32
- func (attr *TxnAttribute) MarshalJson() ([]byte, error)
- func (attr *TxnAttribute) Serialize(w io.Writer) error
- func (attr *TxnAttribute) ToArray() []byte
- func (attr *TxnAttribute) UnmarshalJson(data []byte) error
- type TxnAttributeInfo
- type TxnCollector
- type TxnInput
- func (input *TxnInput) Deserialize(r io.Reader) error
- func (input *TxnInput) Equal(ui2 *TxnInput) bool
- func (input *TxnInput) Equals(other *TxnInput) bool
- func (input *TxnInput) MarshalJson() ([]byte, error)
- func (input *TxnInput) Serialize(w io.Writer) error
- func (input *TxnInput) ToArray() []byte
- func (input *TxnInput) ToString() string
- func (input *TxnInput) UnmarshalJson(data []byte) error
- type TxnInputInfo
- type TxnOutput
- func (output *TxnOutput) Deserialize(r io.Reader) error
- func (output *TxnOutput) Equal(o2 *TxnOutput) bool
- func (output *TxnOutput) MarshalJson() ([]byte, error)
- func (output *TxnOutput) Serialize(w io.Writer) error
- func (output *TxnOutput) ToArray() []byte
- func (output *TxnOutput) UnmarshalJson(data []byte) error
- type TxnOutputInfo
- type TxnSource
- type TxnStore
- type UTXOUnspent
Constants ¶
const ( SubscriptionsLimit = 1000 MaxSubscriptionDuration = 65535 )
const (
MaxCollectableEntityNum = 20480
)
const MaxRefIndex = int(math.MaxUint16)
MaxRefIndex is the max of TxnInput.ReferTxOutputIndex
const (
TransactionNonceLength = 32
)
Variables ¶
This section is empty.
Functions ¶
func CheckAssetPrecision ¶
func CheckAssetPrecision(Tx *Transaction) error
func CheckAttributeProgram ¶
func CheckAttributeProgram(Tx *Transaction) error
func CheckDuplicateInput ¶
func CheckDuplicateInput(tx *Transaction) error
validate the transaction of duplicate UTXO input
func CheckInputOutputTooLong ¶
func CheckInputOutputTooLong(tx *Transaction) bool
CheckInputOutputLen validate len(inputs/outputs) less than MAX of ReferTxOutputIndex
func CheckTransactionBalance ¶
func CheckTransactionBalance(txn *Transaction) error
func CheckTransactionContracts ¶
func CheckTransactionContracts(Tx *Transaction) error
func CheckTransactionPayload ¶
func CheckTransactionPayload(txn *Transaction) error
func IsDoubleSpend ¶
func IsDoubleSpend(tx *Transaction) bool
func IsValidAttributeType ¶
func IsValidAttributeType(usage TransactionAttributeUsage) bool
func VerifyTransaction ¶
func VerifyTransaction(Tx *Transaction) ErrCode
VerifyTransaction verifys received single transaction
func VerifyTransactionWithBlock ¶
func VerifyTransactionWithBlock(iterator Iterator) ErrCode
VerifyTransactionWithBlock verifys a transaction with current transaction pool in memory
func VerifyTransactionWithLedger ¶
func VerifyTransactionWithLedger(Tx *Transaction) ErrCode
VerifyTransactionWithLedger verifys a transaction with history transaction in ledger
Types ¶
type Iterator ¶
type Iterator interface {
Iterate(handler func(item *Transaction) ErrCode) ErrCode
}
type Payload ¶
type Payload interface { // Get payload data Data(version byte) []byte //Serialize payload data Serialize(w io.Writer, version byte) error Deserialize(r io.Reader, version byte) error MarshalJson() ([]byte, error) UnmarshalJson(data []byte) error }
Payload define the func for loading the payload data base on payload type which have different struture
type Transaction ¶
type Transaction struct { TxType TransactionType PayloadVersion byte Payload Payload Attributes []*TxnAttribute Inputs []*TxnInput Outputs []*TxnOutput Programs []*program.Program // contains filtered or unexported fields }
func NewCommitTransaction ¶
func NewCommitTransaction(sigChain []byte, submitter Uint160) (*Transaction, error)
func NewDeleteNameTransaction ¶
func NewDeleteNameTransaction(registrant []byte) (*Transaction, error)
func NewIssueAssetTransaction ¶
func NewIssueAssetTransaction(outputs []*TxnOutput) (*Transaction, error)
func NewPrepaidTransaction ¶
func NewPrepaidTransaction(inputs []*TxnInput, changes *TxnOutput, assetID Uint256, amount, rates string) (*Transaction, error)
func NewRegisterAssetTransaction ¶
func NewRegisterAssetTransaction(asset *asset.Asset, amount Fixed64, issuer *crypto.PubKey, conroller Uint160) (*Transaction, error)
initial a new transaction with asset registration payload
func NewRegisterNameTransaction ¶
func NewRegisterNameTransaction(registrant []byte, name string) (*Transaction, error)
func NewSubscribeTransaction ¶
func NewTransferAssetTransaction ¶
func NewTransferAssetTransaction(inputs []*TxnInput, outputs []*TxnOutput) (*Transaction, error)
func NewWithdrawTransaction ¶
func NewWithdrawTransaction(output *TxnOutput) (*Transaction, error)
func (*Transaction) Deserialize ¶
func (tx *Transaction) Deserialize(r io.Reader) error
deserialize the Transaction
func (*Transaction) DeserializeUnsigned ¶
func (tx *Transaction) DeserializeUnsigned(r io.Reader) error
func (*Transaction) DeserializeUnsignedWithoutType ¶
func (tx *Transaction) DeserializeUnsignedWithoutType(r io.Reader) error
func (*Transaction) GenerateAssetMaps ¶
func (tx *Transaction) GenerateAssetMaps()
func (*Transaction) GetMergedAssetIDValueFromOutputs ¶
func (tx *Transaction) GetMergedAssetIDValueFromOutputs() TransactionResult
func (*Transaction) GetMergedAssetIDValueFromReference ¶
func (tx *Transaction) GetMergedAssetIDValueFromReference() (TransactionResult, error)
func (*Transaction) GetMessage ¶
func (tx *Transaction) GetMessage() []byte
func (*Transaction) GetOutputHashes ¶
func (tx *Transaction) GetOutputHashes() ([]Uint160, error)
func (*Transaction) GetProgramHashes ¶
func (tx *Transaction) GetProgramHashes() ([]Uint160, error)
func (*Transaction) GetPrograms ¶
func (tx *Transaction) GetPrograms() []*program.Program
func (*Transaction) GetReference ¶
func (tx *Transaction) GetReference() (map[*TxnInput]*TxnOutput, error)
func (*Transaction) GetTransactionResults ¶
func (tx *Transaction) GetTransactionResults() (TransactionResult, error)
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() Uint256
func (*Transaction) MarshalJson ¶
func (tx *Transaction) MarshalJson() ([]byte, error)
func (*Transaction) Serialize ¶
func (tx *Transaction) Serialize(w io.Writer) error
Serialize the Transaction
func (*Transaction) SerializeUnsigned ¶
func (tx *Transaction) SerializeUnsigned(w io.Writer) error
Serialize the Transaction data without contracts
func (*Transaction) SetHash ¶
func (tx *Transaction) SetHash(hash Uint256)
func (*Transaction) SetPrograms ¶
func (tx *Transaction) SetPrograms(programs []*program.Program)
func (*Transaction) ToArray ¶
func (tx *Transaction) ToArray() []byte
func (*Transaction) Type ¶
func (tx *Transaction) Type() InventoryType
func (*Transaction) UnmarshalJson ¶
func (tx *Transaction) UnmarshalJson(data []byte) error
func (*Transaction) Verify ¶
func (tx *Transaction) Verify() error
type TransactionAttributeUsage ¶
type TransactionAttributeUsage byte
const ( Nonce TransactionAttributeUsage = 0x00 Script TransactionAttributeUsage = 0x20 Description TransactionAttributeUsage = 0x90 )
type TransactionInfo ¶
type TransactionInfo struct { TxType TransactionType `json:"txType"` PayloadVersion byte `json:"payloadVersion"` Payload interface{} `json:"payload"` Attributes []TxnAttributeInfo `json:"attributes"` Inputs []TxnInputInfo `json:"inputs"` Outputs []TxnOutputInfo `json:"outputs"` Programs []program.ProgramInfo `json:"programs"` Hash string `json:"hash"` }
type TransactionResult ¶
type TransactionResult map[Uint256]Fixed64
type TransactionType ¶
type TransactionType byte
for different transaction types with different payload format and transaction process methods
const ( Coinbase TransactionType = 0x00 TransferAsset TransactionType = 0x10 RegisterAsset TransactionType = 0x11 IssueAsset TransactionType = 0x12 Prepaid TransactionType = 0x40 Withdraw TransactionType = 0x41 Commit TransactionType = 0x42 RegisterName TransactionType = 0x50 TransferName TransactionType = 0x51 DeleteName TransactionType = 0x52 Subscribe TransactionType = 0x60 )
type TxnAttribute ¶
type TxnAttribute struct { Usage TransactionAttributeUsage Data []byte Size uint32 }
func NewTxAttribute ¶
func NewTxAttribute(u TransactionAttributeUsage, d []byte) TxnAttribute
func (*TxnAttribute) Deserialize ¶
func (attr *TxnAttribute) Deserialize(r io.Reader) error
func (*TxnAttribute) Equal ¶
func (attr *TxnAttribute) Equal(tx2 *TxnAttribute) bool
func (*TxnAttribute) GetSize ¶
func (attr *TxnAttribute) GetSize() uint32
func (*TxnAttribute) MarshalJson ¶
func (attr *TxnAttribute) MarshalJson() ([]byte, error)
func (*TxnAttribute) ToArray ¶
func (attr *TxnAttribute) ToArray() []byte
func (*TxnAttribute) UnmarshalJson ¶
func (attr *TxnAttribute) UnmarshalJson(data []byte) error
type TxnAttributeInfo ¶
type TxnAttributeInfo struct { Usage TransactionAttributeUsage `json:"usage"` Data string `json:"data"` }
type TxnCollector ¶
TxnCollector collects transactions from transaction pool
func NewTxnCollector ¶
func NewTxnCollector(source TxnSource, num int) *TxnCollector
func (*TxnCollector) Append ¶
func (tc *TxnCollector) Append(txn *Transaction) errors.ErrCode
func (*TxnCollector) Cleanup ¶
func (tc *TxnCollector) Cleanup(txns []*Transaction) error
func (*TxnCollector) Collect ¶
func (tc *TxnCollector) Collect(winningHash Uint256) (map[Uint256]*Transaction, error)
func (*TxnCollector) GetTransaction ¶
func (tc *TxnCollector) GetTransaction(hash Uint256) *Transaction
type TxnInput ¶
type TxnInput struct { //Indicate the previous Tx which include the UTXO output for usage ReferTxID common.Uint256 //The index of output in the referTx output list ReferTxOutputIndex uint16 }
func (*TxnInput) MarshalJson ¶
func (*TxnInput) UnmarshalJson ¶
type TxnInputInfo ¶
type TxnOutputInfo ¶
type TxnSource ¶
type TxnSource interface { GetTxnByCount(num int, hash Uint256) (map[Uint256]*Transaction, error) GetTransaction(hash Uint256) *Transaction AppendTxnPool(txn *Transaction) errors.ErrCode CleanSubmittedTransactions(txns []*Transaction) error }
Transaction pool should be a concrete entity of this interface
type TxnStore ¶
type TxnStore interface { GetTransaction(hash Uint256) (*Transaction, error) GetQuantityIssued(AssetId Uint256) (Fixed64, error) IsDoubleSpend(tx *Transaction) bool GetAsset(hash Uint256) (*asset.Asset, error) GetPrepaidInfo(programHash Uint160) (*Fixed64, *Fixed64, error) IsTxHashDuplicate(txhash Uint256) bool GetName(registrant []byte) (*string, error) GetRegistrant(name string) ([]byte, error) IsSubscribed(subscriber []byte, identifier string, topic string) (bool, error) GetSubscribersCount(topic string) int }
var Store TxnStore
type UTXOUnspent ¶
func (*UTXOUnspent) Deserialize ¶
func (uu *UTXOUnspent) Deserialize(r io.Reader) error