Documentation
¶
Index ¶
- Constants
- func IsValidAttributeType(usage AttributeUsage) bool
- type Asset
- type AssetRecordType
- type AssetType
- type Attribute
- type AttributeUsage
- type Block
- type Header
- type Input
- type OutPoint
- type Output
- type Payload
- type PayloadCoinBase
- type PayloadIssueToken
- type PayloadRecord
- type PayloadRegisterAsset
- type PayloadSideMining
- type PayloadTransferAsset
- type PayloadTransferCrossChainAsset
- type PayloadWithdrawAsset
- type Program
- type Transaction
- func (tx *Transaction) Deserialize(r io.Reader) error
- func (tx *Transaction) DeserializeUnsigned(r io.Reader) error
- func (tx *Transaction) GetSize() int
- func (tx *Transaction) Hash() Uint256
- func (tx *Transaction) IsCoinBaseTx() bool
- func (tx *Transaction) IsIssueTokenTx() bool
- func (tx *Transaction) IsWithdrawTx() bool
- func (tx *Transaction) Serialize(w io.Writer) error
- func (tx *Transaction) SerializeUnsigned(w io.Writer) error
- func (tx *Transaction) String() string
- type TransactionType
Constants ¶
View Source
const ( MaxPrecision = 8 MinPrecision = 0 )
View Source
const ( BlockVersion uint32 = 0 GenesisNonce uint32 = 2083236893 InvalidBlockSize int = -1 CheckTxOut = 1 << 1 BlockHeightCheckTxOut = 88812 )
View Source
const (
InvalidTransactionSize = -1
)
View Source
const IssueTokenPayloadVersion byte = 0x00
View Source
const PayloadCoinBaseVersion byte = 0x04
View Source
const RecordPayloadVersion byte = 0x00
View Source
const SideMiningPayloadVersion byte = 0x00
View Source
const WithdrawAssetPayloadVersion byte = 0x00
Variables ¶
This section is empty.
Functions ¶
func IsValidAttributeType ¶
func IsValidAttributeType(usage AttributeUsage) bool
Types ¶
type Asset ¶
type Asset struct {
Name string
Description string
Precision byte
AssetType AssetType
RecordType AssetRecordType
}
registered asset will be assigned to contract address
func (*Asset) Deserialize ¶
Deserialize is the implement of SignableData interface.
type AssetRecordType ¶
type AssetRecordType byte
const ( Unspent AssetRecordType = 0x00 Balance AssetRecordType = 0x01 )
type Attribute ¶
type Attribute struct {
Usage AttributeUsage
Data []byte
Size uint32
}
func NewAttribute ¶
func NewAttribute(u AttributeUsage, d []byte) Attribute
type AttributeUsage ¶
type AttributeUsage byte
const ( Nonce AttributeUsage = 0x00 Script AttributeUsage = 0x20 DescriptionUrl AttributeUsage = 0x81 Description AttributeUsage = 0x90 Memo AttributeUsage = 0x91 )
func (AttributeUsage) Name ¶
func (self AttributeUsage) Name() string
type Block ¶
type Block struct {
Header
Transactions []*Transaction
}
type Header ¶
type Input ¶
type OutPoint ¶
type OutPoint struct {
TxID Uint256
Index uint16
}
func NewOutPoint ¶
func OutPointFromBytes ¶
type Output ¶
type Output struct {
AssetID Uint256
Value Fixed64
OutputLock uint32
ProgramHash Uint168
}
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
}
Payload define the func for loading the payload data base on payload type which have different struture
func GetPayload ¶
func GetPayload(txType TransactionType) (Payload, error)
type PayloadCoinBase ¶
type PayloadCoinBase struct {
CoinbaseData []byte
}
func (*PayloadCoinBase) Data ¶
func (a *PayloadCoinBase) Data(version byte) []byte
func (*PayloadCoinBase) Deserialize ¶
func (a *PayloadCoinBase) Deserialize(r io.Reader, version byte) error
type PayloadIssueToken ¶
type PayloadIssueToken struct {
MerkleProof []byte
}
func (*PayloadIssueToken) Data ¶
func (t *PayloadIssueToken) Data(version byte) []byte
func (*PayloadIssueToken) Deserialize ¶
func (t *PayloadIssueToken) Deserialize(r io.Reader, version byte) error
type PayloadRecord ¶
func (*PayloadRecord) Data ¶
func (a *PayloadRecord) Data(version byte) []byte
func (*PayloadRecord) Deserialize ¶
func (a *PayloadRecord) Deserialize(r io.Reader, version byte) error
Deserialize is the implement of SignableData interface.
type PayloadRegisterAsset ¶
type PayloadRegisterAsset struct {
Asset Asset
Amount Fixed64
Controller Uint168
}
func (*PayloadRegisterAsset) Data ¶
func (a *PayloadRegisterAsset) Data(version byte) []byte
func (*PayloadRegisterAsset) Deserialize ¶
func (a *PayloadRegisterAsset) Deserialize(r io.Reader, version byte) error
type PayloadSideMining ¶
type PayloadSideMining struct {
SideBlockHash Uint256
SideGenesisHash Uint256
}
func (*PayloadSideMining) Data ¶
func (a *PayloadSideMining) Data(version byte) []byte
func (*PayloadSideMining) Deserialize ¶
func (a *PayloadSideMining) Deserialize(r io.Reader, version byte) error
type PayloadTransferAsset ¶
type PayloadTransferAsset struct{}
func (*PayloadTransferAsset) Data ¶
func (a *PayloadTransferAsset) Data(version byte) []byte
func (*PayloadTransferAsset) Deserialize ¶
func (a *PayloadTransferAsset) Deserialize(r io.Reader, version byte) error
type PayloadTransferCrossChainAsset ¶
type PayloadTransferCrossChainAsset struct {
// string: publickey; uint64: output index
AddressesMap map[string]uint64
}
func (*PayloadTransferCrossChainAsset) Data ¶
func (a *PayloadTransferCrossChainAsset) Data(version byte) []byte
func (*PayloadTransferCrossChainAsset) Deserialize ¶
func (a *PayloadTransferCrossChainAsset) Deserialize(r io.Reader, version byte) error
type PayloadWithdrawAsset ¶
type PayloadWithdrawAsset struct {
BlockHeight uint32
GenesisBlockAddress string
SideChainTransactionHash string
}
func (*PayloadWithdrawAsset) Data ¶
func (t *PayloadWithdrawAsset) Data(version byte) []byte
func (*PayloadWithdrawAsset) Deserialize ¶
func (t *PayloadWithdrawAsset) Deserialize(r io.Reader, version byte) error
type Program ¶
type Program struct {
//the contract program code,which will be run on VM or specific envrionment
Code []byte
//the program code's parameter
Parameter []byte
}
func (*Program) Deserialize ¶
Deserialize the Program
type Transaction ¶
type Transaction struct {
TxType TransactionType
PayloadVersion byte
Payload Payload
Attributes []*Attribute
Inputs []*Input
Outputs []*Output
LockTime uint32
Programs []*Program
Fee Fixed64
FeePerKB Fixed64
// contains filtered or unexported fields
}
func NewTrimmedTx ¶
func NewTrimmedTx(hash Uint256) *Transaction
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) GetSize ¶
func (tx *Transaction) GetSize() int
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() Uint256
func (*Transaction) IsCoinBaseTx ¶
func (tx *Transaction) IsCoinBaseTx() bool
func (*Transaction) IsIssueTokenTx ¶
func (tx *Transaction) IsIssueTokenTx() bool
func (*Transaction) IsWithdrawTx ¶
func (tx *Transaction) IsWithdrawTx() bool
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) String ¶
func (tx *Transaction) String() string
type TransactionType ¶
type TransactionType byte
for different transaction types with different payload format and transaction process methods
const ( CoinBase TransactionType = 0x00 RegisterAsset TransactionType = 0x01 TransferAsset TransactionType = 0x02 Record TransactionType = 0x03 Deploy TransactionType = 0x04 SideMining TransactionType = 0x05 IssueToken TransactionType = 0x06 WithdrawAsset TransactionType = 0x07 TransferCrossChainAsset TransactionType = 0x08 )
func (TransactionType) Name ¶
func (self TransactionType) Name() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.