Documentation
¶
Index ¶
- Constants
- Variables
- func GetSystemAssetId() common.Uint256
- func IsValidAttributeType(usage AttributeUsage) bool
- type Asset
- type AssetRecordType
- type AssetType
- type Attribute
- type AttributeUsage
- type BaseHeader
- type Block
- type Header
- func (header *Header) Deserialize(r io.Reader) error
- func (header *Header) GetAuxPow() *auxpow.SideAuxPow
- func (header *Header) GetBits() uint32
- func (header *Header) GetHeaderSize() int
- func (header *Header) GetHeight() uint32
- func (header *Header) GetMainChainHeight() uint32
- func (header *Header) GetMerkleRoot() common.Uint256
- func (header *Header) GetNonce() uint32
- func (header *Header) GetPrevious() common.Uint256
- func (header *Header) GetTimeStamp() uint32
- func (header *Header) GetVersion() uint32
- func (header *Header) Hash() common.Uint256
- func (header *Header) Serialize(w io.Writer) error
- func (header *Header) SetAuxPow(sideAuxPow *auxpow.SideAuxPow)
- func (header *Header) SetBits(bits uint32)
- func (header *Header) SetHeight(height uint32)
- func (header *Header) SetMerkleRoot(root common.Uint256)
- func (header *Header) SetNonce(nonce uint32)
- func (header *Header) SetPrevious(previous common.Uint256)
- func (header *Header) SetTimeStamp(timestamp uint32)
- func (header *Header) SetVersion(version uint32)
- type Input
- type OutPoint
- type Output
- type Payload
- type PayloadCoinBase
- type PayloadRechargeToSideChain
- func (t *PayloadRechargeToSideChain) Data(version byte) []byte
- func (t *PayloadRechargeToSideChain) Deserialize(r io.Reader, version byte) error
- func (t *PayloadRechargeToSideChain) GetMainchainTxHash(payloadVersion byte) (*common.Uint256, error)
- func (t *PayloadRechargeToSideChain) Serialize(w io.Writer, version byte) error
- type PayloadRecord
- type PayloadRegisterAsset
- type PayloadTransferAsset
- type PayloadTransferCrossChainAsset
- type Program
- type Transaction
- func (tx *Transaction) Deserialize(r io.Reader) error
- func (tx *Transaction) DeserializeUnsigned(r io.Reader) error
- func (tx *Transaction) GetData() []byte
- func (tx *Transaction) GetSize() int
- func (tx *Transaction) Hash() common.Uint256
- func (tx *Transaction) IsCoinBaseTx() bool
- func (tx *Transaction) IsRechargeToSideChainTx() bool
- func (tx *Transaction) IsRegisterAssetTx() bool
- func (tx *Transaction) IsSideChainPowTx() bool
- func (tx *Transaction) IsTransferCrossChainAssetTx() bool
- func (tx *Transaction) Serialize(w io.Writer) error
- func (tx *Transaction) SerializeUnsigned(w io.Writer) error
- func (tx *Transaction) String() string
- type TxType
- type UTXO
Constants ¶
View Source
const ( MaxPrecision = 8 MinPrecision = 0 )
View Source
const ( // BlockVersion is the version of block. BlockVersion uint32 = 0 // GenesisNonce is the nonce of genesis block. GenesisNonce uint32 = 3194347904 // MaxBlockSize is the maximum size of a block. MaxBlockSize = 8000000 // MaxBlockHeaderSize is the maximum number of bytes allowed per block header. MaxBlockHeaderSize uint32 = 2000000 // MaxTxPerBlock is the maximum transactions can be included in // a block. MaxTxPerBlock = 100000 )
View Source
const ( RechargeToSideChainPayloadVersion0 byte = 0x00 RechargeToSideChainPayloadVersion1 byte = 0x01 )
View Source
const ( // MaxProgramCodeSize is the maximum allowed length of program code. MaxProgramCodeSize = 10000 // MaxProgramParamSize is the maximum allowed length of program parameter. MaxProgramParamSize = MaxProgramCodeSize * 2 )
View Source
const ( // MaxPayloadDataSize is the maximum allowed length of payload data. MaxPayloadDataSize = 1024 * 1024 // 1MB )
View Source
const PayloadCoinBaseVersion byte = 0x04
View Source
const RecordPayloadVersion byte = 0x00
Variables ¶
View Source
var DeserializeOutput = func(output *Output, r io.Reader) error { err := output.AssetID.Deserialize(r) if err != nil { return err } err = output.Value.Deserialize(r) if err != nil { return err } temp, err := common.ReadUint32(r) if err != nil { return err } output.OutputLock = uint32(temp) err = output.ProgramHash.Deserialize(r) if err != nil { return err } return nil }
View Source
var GetDataContainer = func(programHash *common.Uint168, tx *Transaction) interfaces.IDataContainer {
return tx
}
View Source
var GetPayloadByTxType = func(txType TxType) (Payload, error) { var p Payload switch txType { case CoinBase: p = new(PayloadCoinBase) case RegisterAsset: p = new(PayloadRegisterAsset) case TransferAsset: p = new(PayloadTransferAsset) case Record: p = new(PayloadRecord) case RechargeToSideChain: p = new(PayloadRechargeToSideChain) case TransferCrossChainAsset: p = new(PayloadTransferCrossChainAsset) default: return nil, errors.New("[Transaction], invalid transaction type.") } return p, nil }
View Source
var SerializeOutput = func(output *Output, w io.Writer) error { err := output.AssetID.Serialize(w) if err != nil { return err } err = output.Value.Serialize(w) if err != nil { return err } common.WriteUint32(w, output.OutputLock) err = output.ProgramHash.Serialize(w) if err != nil { return err } return nil }
View Source
var TxTypeStr = func(txType TxType) string { s, ok := ttStrings[txType] if ok { return s } return fmt.Sprintf("TxType%d", txType) }
Functions ¶
func GetSystemAssetId ¶
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
}
func NewAttribute ¶
func NewAttribute(u AttributeUsage, d []byte) Attribute
type AttributeUsage ¶
type AttributeUsage byte
const ( Nonce AttributeUsage = 0x00 Script AttributeUsage = 0x20 Memo AttributeUsage = 0x81 Description AttributeUsage = 0x90 DescriptionUrl AttributeUsage = 0x91 )
func (AttributeUsage) Name ¶
func (u AttributeUsage) Name() string
type BaseHeader ¶ added in v0.1.6
type BaseHeader struct {
Version uint32
Previous common.Uint256
MerkleRoot common.Uint256
Timestamp uint32
Bits uint32
Nonce uint32
Height uint32
}
func (*BaseHeader) Deserialize ¶ added in v0.1.6
func (header *BaseHeader) Deserialize(r io.Reader) error
type Block ¶
type Block struct {
interfaces.Header
Transactions []*Transaction
}
type Header ¶
type Header struct {
Base BaseHeader
SideAuxPow auxpow.SideAuxPow
}
func (*Header) GetAuxPow ¶ added in v0.1.5
func (header *Header) GetAuxPow() *auxpow.SideAuxPow
func (*Header) GetHeaderSize ¶ added in v0.1.8
func (*Header) GetMainChainHeight ¶ added in v0.2.0
func (*Header) GetMerkleRoot ¶ added in v0.1.5
func (*Header) GetPrevious ¶ added in v0.1.5
func (*Header) GetTimeStamp ¶ added in v0.1.5
func (*Header) GetVersion ¶ added in v0.1.5
func (*Header) SetAuxPow ¶ added in v0.1.5
func (header *Header) SetAuxPow(sideAuxPow *auxpow.SideAuxPow)
func (*Header) SetMerkleRoot ¶ added in v0.1.5
func (*Header) SetPrevious ¶ added in v0.1.5
func (*Header) SetTimeStamp ¶ added in v0.1.5
func (*Header) SetVersion ¶ added in v0.1.5
type Input ¶
type OutPoint ¶
func OutPointFromBytes ¶
type Output ¶
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
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 PayloadRechargeToSideChain ¶
type PayloadRechargeToSideChain struct {
MerkleProof []byte
MainChainTransaction []byte
MainChainTransactionHash common.Uint256
}
func (*PayloadRechargeToSideChain) Data ¶
func (t *PayloadRechargeToSideChain) Data(version byte) []byte
func (*PayloadRechargeToSideChain) Deserialize ¶
func (t *PayloadRechargeToSideChain) Deserialize(r io.Reader, version byte) error
func (*PayloadRechargeToSideChain) GetMainchainTxHash ¶
func (t *PayloadRechargeToSideChain) GetMainchainTxHash(payloadVersion byte) (*common.Uint256, 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 ¶
func (*PayloadRegisterAsset) Data ¶
func (a *PayloadRegisterAsset) Data(version byte) []byte
func (*PayloadRegisterAsset) Deserialize ¶
func (a *PayloadRegisterAsset) 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 {
CrossChainAddresses []string
OutputIndexes []uint64
CrossChainAmounts []common.Fixed64
}
func (*PayloadTransferCrossChainAsset) Data ¶
func (a *PayloadTransferCrossChainAsset) Data(version byte) []byte
func (*PayloadTransferCrossChainAsset) Deserialize ¶
func (a *PayloadTransferCrossChainAsset) 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 TxType
PayloadVersion byte
Payload Payload
Attributes []*Attribute
Inputs []*Input
Outputs []*Output
LockTime uint32
Programs []*Program
Fee common.Fixed64
FeePerKB common.Fixed64
// contains filtered or unexported fields
}
func NewTrimmedTx ¶
func NewTrimmedTx(hash common.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() common.Uint256
func (*Transaction) IsCoinBaseTx ¶
func (tx *Transaction) IsCoinBaseTx() bool
func (*Transaction) IsRechargeToSideChainTx ¶
func (tx *Transaction) IsRechargeToSideChainTx() bool
func (*Transaction) IsRegisterAssetTx ¶
func (tx *Transaction) IsRegisterAssetTx() bool
func (*Transaction) IsSideChainPowTx ¶
func (tx *Transaction) IsSideChainPowTx() bool
func (*Transaction) IsTransferCrossChainAssetTx ¶
func (tx *Transaction) IsTransferCrossChainAssetTx() 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 TxType ¶
type TxType byte
for different transaction types with different payload format and transaction process methods
const ( CoinBase TxType = 0x00 RegisterAsset TxType = 0x01 TransferAsset TxType = 0x02 Record TxType = 0x03 Deploy TxType = 0x04 SideChainPow TxType = 0x05 RechargeToSideChain TxType = 0x06 WithdrawFromSideChain TxType = 0x07 TransferCrossChainAsset TxType = 0x08 Invoke TxType = 0xF0 InvalidTransactionSize = -1 )
Click to show internal directories.
Click to hide internal directories.