core

package
v0.2.1-80ce Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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 (
	// 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 (
	InvalidTransactionSize = -1
)
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
View Source
const SideChainPowPayloadVersion byte = 0x00
View Source
const WithdrawFromSideChainPayloadVersion 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

func (a *Asset) Deserialize(r io.Reader) error

Deserialize is the implement of SignableData interface.

func (*Asset) Hash added in v0.2.1

func (a *Asset) Hash() common.Uint256

func (*Asset) Serialize

func (a *Asset) Serialize(w io.Writer) error

Serialize is the implement of SignableData interface.

type AssetRecordType

type AssetRecordType byte
const (
	Unspent AssetRecordType = 0x00
	Balance AssetRecordType = 0x01
)

type AssetType

type AssetType byte

AssetType

const (
	Token AssetType = 0x00
	Share AssetType = 0x01
)

type Attribute

type Attribute struct {
	Usage AttributeUsage
	Data  []byte
}

func NewAttribute

func NewAttribute(u AttributeUsage, d []byte) Attribute

func (*Attribute) Deserialize

func (attr *Attribute) Deserialize(r io.Reader) error

func (*Attribute) Serialize

func (attr *Attribute) Serialize(w io.Writer) error

func (Attribute) String

func (attr Attribute) String() string

type AttributeUsage

type AttributeUsage byte
const (
	Nonce          AttributeUsage = 0x00
	Script         AttributeUsage = 0x20
	Memo           AttributeUsage = 0x81
	Description    AttributeUsage = 0x90
	DescriptionUrl AttributeUsage = 0x91
	Confirmations  AttributeUsage = 0x92
)

func (AttributeUsage) Name

func (it AttributeUsage) Name() string

type Block

type Block struct {
	Header
	Transactions []*Transaction
}

func (*Block) Deserialize

func (b *Block) Deserialize(r io.Reader) error

func (*Block) FromTrimmedData

func (b *Block) FromTrimmedData(r io.Reader) error

func (*Block) GetSize

func (b *Block) GetSize() int

func (*Block) Hash

func (b *Block) Hash() common.Uint256

func (*Block) Serialize

func (b *Block) Serialize(w io.Writer) error

func (*Block) Trim

func (b *Block) Trim(w io.Writer) error
type Header struct {
	Version    uint32
	Previous   Uint256
	MerkleRoot Uint256
	Timestamp  uint32
	Bits       uint32
	Nonce      uint32
	Height     uint32
	AuxPow     auxpow.AuxPow
}

func (*Header) Deserialize

func (header *Header) Deserialize(r io.Reader) error

func (*Header) Hash

func (header *Header) Hash() Uint256

func (*Header) Serialize

func (header *Header) Serialize(w io.Writer) error

type Input

type Input struct {
	// Reference outpoint of this input
	Previous OutPoint

	// Sequence number
	Sequence uint32
}

func (*Input) Deserialize

func (i *Input) Deserialize(r io.Reader) error

func (*Input) IsEqual

func (i *Input) IsEqual(o Input) bool

func (*Input) ReferKey

func (i *Input) ReferKey() string

func (*Input) Serialize

func (i *Input) Serialize(w io.Writer) error

func (Input) String

func (i Input) String() string

type OutPoint

type OutPoint struct {
	TxID  Uint256
	Index uint16
}

func NewOutPoint

func NewOutPoint(txID Uint256, index uint16) *OutPoint

func OutPointFromBytes

func OutPointFromBytes(value []byte) (*OutPoint, error)

func (*OutPoint) Bytes

func (op *OutPoint) Bytes() []byte

func (*OutPoint) Deserialize

func (op *OutPoint) Deserialize(r io.Reader) error

func (*OutPoint) IsEqual

func (op *OutPoint) IsEqual(o OutPoint) bool

func (*OutPoint) Serialize

func (op *OutPoint) Serialize(w io.Writer) error

type Output

type Output struct {
	AssetID     Uint256
	Value       Fixed64
	OutputLock  uint32
	ProgramHash Uint168
}

func (*Output) Deserialize

func (o *Output) Deserialize(r io.Reader) error

func (*Output) Serialize

func (o *Output) Serialize(w io.Writer) error

func (Output) String

func (o Output) String() string

type Payload

type Payload interface {
	// Get payload data
	Data(version byte) []byte

	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 structure

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

func (*PayloadCoinBase) Serialize

func (a *PayloadCoinBase) Serialize(w io.Writer, version byte) error

type PayloadRecord

type PayloadRecord struct {
	RecordType string
	RecordData []byte
}

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.

func (*PayloadRecord) Serialize

func (a *PayloadRecord) Serialize(w io.Writer, version byte) error

Serialize 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

func (*PayloadRegisterAsset) Serialize

func (a *PayloadRegisterAsset) Serialize(w io.Writer, version byte) error

type PayloadSideChainPow added in v0.1.1

type PayloadSideChainPow struct {
	SideBlockHash   Uint256
	SideGenesisHash Uint256
	BlockHeight     uint32
	SignedData      []byte
}

func (*PayloadSideChainPow) Data added in v0.1.1

func (a *PayloadSideChainPow) Data(version byte) []byte

func (*PayloadSideChainPow) Deserialize added in v0.1.1

func (a *PayloadSideChainPow) Deserialize(r io.Reader, version byte) error

func (*PayloadSideChainPow) Serialize added in v0.1.1

func (a *PayloadSideChainPow) Serialize(w io.Writer, 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

func (*PayloadTransferAsset) Serialize

func (a *PayloadTransferAsset) Serialize(w io.Writer, 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

func (*PayloadTransferCrossChainAsset) Serialize

func (a *PayloadTransferCrossChainAsset) Serialize(w io.Writer, version byte) error

type PayloadWithdrawFromSideChain added in v0.1.1

type PayloadWithdrawFromSideChain struct {
	BlockHeight                uint32
	GenesisBlockAddress        string
	SideChainTransactionHashes []common.Uint256
}

func (*PayloadWithdrawFromSideChain) Data added in v0.1.1

func (t *PayloadWithdrawFromSideChain) Data(version byte) []byte

func (*PayloadWithdrawFromSideChain) Deserialize added in v0.1.1

func (t *PayloadWithdrawFromSideChain) Deserialize(r io.Reader, version byte) error

func (*PayloadWithdrawFromSideChain) Serialize added in v0.1.1

func (t *PayloadWithdrawFromSideChain) Serialize(w io.Writer, version byte) error

type Program

type Program struct {
	//the contract program code,which will be run on VM or specific environment
	Code []byte

	//the program code's parameter
	Parameter []byte
}

func (*Program) Deserialize

func (p *Program) Deserialize(w io.Reader) error

Deserialize the Program

func (*Program) Serialize

func (p *Program) Serialize(w io.Writer) error

Serialize the Program

func (Program) String

func (p Program) String() string

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) IsRechargeToSideChainTx added in v0.1.1

func (tx *Transaction) IsRechargeToSideChainTx() bool

func (*Transaction) IsSideChainPowTx added in v0.1.1

func (tx *Transaction) IsSideChainPowTx() bool

func (*Transaction) IsTransferCrossChainAssetTx added in v0.1.1

func (tx *Transaction) IsTransferCrossChainAssetTx() bool

func (*Transaction) IsWithdrawFromSideChainTx added in v0.1.1

func (tx *Transaction) IsWithdrawFromSideChainTx() 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
	SideChainPow            TransactionType = 0x05
	RechargeToSideChain     TransactionType = 0x06
	WithdrawFromSideChain   TransactionType = 0x07
	TransferCrossChainAsset TransactionType = 0x08
)

func (TransactionType) Name

func (self TransactionType) Name() string

Jump to

Keyboard shortcuts

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