transaction

package
v0.0.0-...-84d53aa Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: GPL-3.0 Imports: 16 Imported by: 8

Documentation

Index

Constants

View Source
const (
	TxOpGenesis             = "genesis"
	TxOpGenesisDistribution = "genesis_distribution"
)

genesis transaction types

View Source
const (
	TxOpTransfer            = "transfer"
	TxOpAddRecord           = "add_record"
	TxOpStake               = "stake"
	TxOpUnstake             = "unstake"
	TxOpAddCertification    = "add_certification"
	TxOpRevokeCertification = "revoke_certification"
	TxOpRegisterAlias       = "register_alias"
	TxOpDeregisterAlias     = "deregister_alias"
)

core transaction types

View Source
const (
	TxOpBecomeCandidate = "become_candidate"
	TxOpQuitCandidacy   = "quit_candidacy"
	TxOpVote            = "vote"
)

dpos transaction types

View Source
const (
	AliasLengthMinimum     = 12
	AliasLengthMaximum     = 16
	AliasCollateralMinimum = "1000000000000000000"
)

constants related to account alias

View Source
const (
	CandidateCollateralMinimum = "1000000000000000000"
	VoteMaximum                = 15
)

constants related to dpos

View Source
const (
	MaxPayloadSize = 4096
)

constants for staking and regeneration

Variables

View Source
var (
	ErrTooLargePayload          = errors.New("too large payload")
	ErrVoidTransaction          = errors.New("nothing to do with transaction")
	ErrInvalidAddress           = errors.New("invalid address")
	ErrBalanceNotEnough         = errors.New("balance is not enough")
	ErrCannotUseZeroValue       = errors.New("value should be larger than zero")
	ErrRecordHashInvalid        = errors.New("invalid record hash")
	ErrRecordAlreadyAdded       = errors.New("record hash already added")
	ErrNotFound                 = trie.ErrNotFound
	ErrCertHashInvalid          = errors.New("invalid certification hash")
	ErrCertReceivedAlreadyAdded = errors.New("hash of received cert already added")
	ErrCertIssuedAlreadyAdded   = errors.New("hash of issued cert already added")
	ErrCertAlreadyRevoked       = errors.New("cert to revoke has already been revoked")
	ErrCertAlreadyExpired       = errors.New("cert to revoke has already been expired")
	ErrCertRevokerInvalid       = errors.New("only issuer of the cert can revoke it")
	ErrAliasAlreadyTaken        = errors.New("already occupied alias")
	ErrAliasAlreadyHave         = errors.New("already have a alias name")
	ErrAliasCollateralLimit     = errors.New("not enough transaction value for alias collateral")
	ErrAliasFirstLetter         = errors.New("first letter of alias name should not be a number")
	ErrAliasInvalidChar         = errors.New("aliasname must contain only lowercase letters and numbers")
	ErrAliasLengthUnderMinimum  = errors.New("aliasname is too short")
	ErrAliasLengthExceedMaximum = errors.New("aliasname is too long ")
	ErrAliasNotExist            = errors.New("doesn't have any alias")
	ErrFailedToUnmarshalPayload = errors.New("cannot unmarshal tx payload")
	ErrFailedToMarshalPayload   = errors.New("cannot marshal tx payload to bytes")
	ErrCheckPayloadIntegrity    = errors.New("payload has invalid elements")
)

Errors related to execute transaction

View Source
var (
	ErrOverMaxVote                  = errors.New("too many vote")
	ErrDuplicateVote                = errors.New("cannot vote multiple vote for same account")
	ErrAlreadyCandidate             = errors.New("account is already a candidate")
	ErrNotCandidate                 = errors.New("account is not a candidate")
	ErrNotEnoughCandidateCollateral = errors.New("candidate collateral is not enough")
)

Errors related to dpos transactions (candidate, voting)

DefaultTxMap is default map of transactions.

Functions

func BytesToTransactionPayload

func BytesToTransactionPayload(bytes []byte, payload Payload) error

BytesToTransactionPayload convert byte slice to Payload

func NewAddCertificationTx

func NewAddCertificationTx(tx *core.Transaction) (core.ExecutableTx, error)

NewAddCertificationTx returns AddCertificationTx

func NewAddRecordTx

func NewAddRecordTx(tx *core.Transaction) (core.ExecutableTx, error)

NewAddRecordTx returns AddRecordTx

func NewBecomeCandidateTx

func NewBecomeCandidateTx(tx *core.Transaction) (core.ExecutableTx, error)

NewBecomeCandidateTx returns BecomeCandidateTx

func NewDeregisterAliasTx

func NewDeregisterAliasTx(tx *core.Transaction) (core.ExecutableTx, error)

NewDeregisterAliasTx returns RegisterAliasTx

func NewGenesisDistributionTx

func NewGenesisDistributionTx(tx *core.Transaction) (core.ExecutableTx, error)

NewGenesisDistributionTx returns GenesisDistributionTx.

func NewGenesisTx

func NewGenesisTx(tx *core.Transaction) (core.ExecutableTx, error)

NewGenesisTx return GenesisTx.

func NewQuitCandidateTx

func NewQuitCandidateTx(tx *core.Transaction) (core.ExecutableTx, error)

NewQuitCandidateTx returns QuitCandidateTx

func NewRegisterAliasTx

func NewRegisterAliasTx(tx *core.Transaction) (core.ExecutableTx, error)

NewRegisterAliasTx returns RegisterAliasTx

func NewRevokeCertificationTx

func NewRevokeCertificationTx(tx *core.Transaction) (core.ExecutableTx, error)

NewRevokeCertificationTx returns RevokeCertificationTx

func NewStakeTx

func NewStakeTx(tx *core.Transaction) (core.ExecutableTx, error)

NewStakeTx returns NewTx

func NewTransferTx

func NewTransferTx(tx *core.Transaction) (core.ExecutableTx, error)

NewTransferTx returns TransferTx

func NewUnstakeTx

func NewUnstakeTx(tx *core.Transaction) (core.ExecutableTx, error)

NewUnstakeTx returns UnstakeTx

func NewVoteTx

func NewVoteTx(tx *core.Transaction) (core.ExecutableTx, error)

NewVoteTx returns VoteTx

Types

type AddCertificationPayload

type AddCertificationPayload struct {
	IssueTime       int64
	ExpirationTime  int64
	CertificateHash []byte
}

AddCertificationPayload is payload type for AddCertificationTx

func (*AddCertificationPayload) FromBytes

func (payload *AddCertificationPayload) FromBytes(b []byte) error

FromBytes converts bytes to payload.

func (*AddCertificationPayload) ToBytes

func (payload *AddCertificationPayload) ToBytes() ([]byte, error)

ToBytes returns marshaled AddCertificationPayload

type AddCertificationTx

type AddCertificationTx struct {
	*core.Transaction
	Issuer          common.Address
	Certified       common.Address
	CertificateHash []byte
	IssueTime       int64
	ExpirationTime  int64
	// contains filtered or unexported fields
}

AddCertificationTx is a structure for adding certification

func (*AddCertificationTx) Bandwidth

func (tx *AddCertificationTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*AddCertificationTx) Execute

func (tx *AddCertificationTx) Execute(b *core.Block) error

Execute AddCertificationTx

func (*AddCertificationTx) PointChange

func (tx *AddCertificationTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*AddCertificationTx) RecoverFrom

func (tx *AddCertificationTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type AddRecordPayload

type AddRecordPayload struct {
	RecordHash []byte
}

AddRecordPayload is payload type for TxOpAddRecord

func (*AddRecordPayload) FromBytes

func (payload *AddRecordPayload) FromBytes(b []byte) error

FromBytes converts bytes to payload.

func (*AddRecordPayload) ToBytes

func (payload *AddRecordPayload) ToBytes() ([]byte, error)

ToBytes returns marshaled AddRecordPayload

type AddRecordTx

type AddRecordTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

AddRecordTx is a structure for adding record

func (*AddRecordTx) Bandwidth

func (tx *AddRecordTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*AddRecordTx) Execute

func (tx *AddRecordTx) Execute(b *core.Block) error

Execute AddRecordTx

func (*AddRecordTx) PointChange

func (tx *AddRecordTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*AddRecordTx) RecoverFrom

func (tx *AddRecordTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type BecomeCandidatePayload

type BecomeCandidatePayload struct {
	URL string
}

BecomeCandidatePayload is payload type for BecomeCandidate

func (*BecomeCandidatePayload) FromBytes

func (payload *BecomeCandidatePayload) FromBytes(b []byte) error

FromBytes converts bytes to payload.

func (*BecomeCandidatePayload) ToBytes

func (payload *BecomeCandidatePayload) ToBytes() ([]byte, error)

ToBytes returns marshaled BecomeCandidatePayload

type BecomeCandidateTx

type BecomeCandidateTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

BecomeCandidateTx is a structure for quiting cadidate

func (*BecomeCandidateTx) Bandwidth

func (tx *BecomeCandidateTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*BecomeCandidateTx) Execute

func (tx *BecomeCandidateTx) Execute(b *core.Block) error

Execute NewBecomeCandidateTx

func (*BecomeCandidateTx) PointChange

func (tx *BecomeCandidateTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*BecomeCandidateTx) RecoverFrom

func (tx *BecomeCandidateTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type DefaultPayload

type DefaultPayload struct {
	Message string
}

DefaultPayload is payload type for any type of message

func (*DefaultPayload) FromBytes

func (payload *DefaultPayload) FromBytes(b []byte) error

FromBytes converts bytes to payload.

func (*DefaultPayload) ToBytes

func (payload *DefaultPayload) ToBytes() ([]byte, error)

ToBytes returns marshaled DefaultPayload

type DeregisterAliasTx

type DeregisterAliasTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

DeregisterAliasTx is a structure for deregister alias

func (*DeregisterAliasTx) Bandwidth

func (tx *DeregisterAliasTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*DeregisterAliasTx) Execute

func (tx *DeregisterAliasTx) Execute(b *core.Block) error

Execute DeregisterAliasTx

func (*DeregisterAliasTx) PointChange

func (tx *DeregisterAliasTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*DeregisterAliasTx) RecoverFrom

func (tx *DeregisterAliasTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type GenesisDistributionTx

type GenesisDistributionTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

GenesisDistributionTx represents genesis distribution transaction in executable form.

func (*GenesisDistributionTx) Bandwidth

func (tx *GenesisDistributionTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*GenesisDistributionTx) Execute

func (tx *GenesisDistributionTx) Execute(b *core.Block) error

Execute GenesisDistributionTx.

func (*GenesisDistributionTx) PointChange

func (tx *GenesisDistributionTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*GenesisDistributionTx) RecoverFrom

func (tx *GenesisDistributionTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type GenesisTx

type GenesisTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

GenesisTx represents genesis transaction in executable form.

func (*GenesisTx) Bandwidth

func (tx *GenesisTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*GenesisTx) Execute

func (tx *GenesisTx) Execute(b *core.Block) error

Execute GenesisTx.

func (*GenesisTx) PointChange

func (tx *GenesisTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*GenesisTx) RecoverFrom

func (tx *GenesisTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type Payload

type Payload interface {
	FromBytes(b []byte) error
	ToBytes() ([]byte, error)
}

Payload is an interface of transaction payload.

type QuitCandidateTx

type QuitCandidateTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

QuitCandidateTx is a structure for quiting candidate

func (*QuitCandidateTx) Bandwidth

func (tx *QuitCandidateTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*QuitCandidateTx) Execute

func (tx *QuitCandidateTx) Execute(b *core.Block) error

Execute QuitCandidateTx

func (*QuitCandidateTx) PointChange

func (tx *QuitCandidateTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*QuitCandidateTx) RecoverFrom

func (tx *QuitCandidateTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type RegisterAliasPayload

type RegisterAliasPayload struct {
	AliasName string
}

RegisterAliasPayload is payload type for register alias

func (*RegisterAliasPayload) FromBytes

func (payload *RegisterAliasPayload) FromBytes(b []byte) error

FromBytes converts bytes to payload.

func (*RegisterAliasPayload) ToBytes

func (payload *RegisterAliasPayload) ToBytes() ([]byte, error)

ToBytes returns marshaled DefaultPayload

type RegisterAliasTx

type RegisterAliasTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

RegisterAliasTx is a structure for register alias

func (*RegisterAliasTx) Bandwidth

func (tx *RegisterAliasTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*RegisterAliasTx) Execute

func (tx *RegisterAliasTx) Execute(b *core.Block) error

Execute RegisterAliasTx

func (*RegisterAliasTx) PointChange

func (tx *RegisterAliasTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*RegisterAliasTx) RecoverFrom

func (tx *RegisterAliasTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type RevokeCertificationPayload

type RevokeCertificationPayload struct {
	CertificateHash []byte
}

RevokeCertificationPayload is payload type for RevokeCertificationTx

func (*RevokeCertificationPayload) FromBytes

func (payload *RevokeCertificationPayload) FromBytes(b []byte) error

FromBytes converts bytes to payload.

func (*RevokeCertificationPayload) ToBytes

func (payload *RevokeCertificationPayload) ToBytes() ([]byte, error)

ToBytes returns marshaled RevokeCertificationPayload

type RevokeCertificationTx

type RevokeCertificationTx struct {
	*core.Transaction
	Revoker         common.Address
	CertificateHash []byte
	// contains filtered or unexported fields
}

RevokeCertificationTx is a structure for revoking certification

func (*RevokeCertificationTx) Bandwidth

func (tx *RevokeCertificationTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*RevokeCertificationTx) Execute

func (tx *RevokeCertificationTx) Execute(b *core.Block) error

Execute RevokeCertificationTx

func (*RevokeCertificationTx) PointChange

func (tx *RevokeCertificationTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*RevokeCertificationTx) RecoverFrom

func (tx *RevokeCertificationTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type StakeTx

type StakeTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

StakeTx is a structure for staking med

func (*StakeTx) Bandwidth

func (tx *StakeTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*StakeTx) Execute

func (tx *StakeTx) Execute(b *core.Block) error

Execute StakeTx

func (*StakeTx) PointChange

func (tx *StakeTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*StakeTx) RecoverFrom

func (tx *StakeTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type TransferTx

type TransferTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

TransferTx is a structure for sending MED

func (*TransferTx) Bandwidth

func (tx *TransferTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*TransferTx) Execute

func (tx *TransferTx) Execute(b *core.Block) error

Execute TransferTx

func (*TransferTx) PointChange

func (tx *TransferTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*TransferTx) RecoverFrom

func (tx *TransferTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type UnstakeTx

type UnstakeTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

UnstakeTx is a structure for unstaking med

func (*UnstakeTx) Bandwidth

func (tx *UnstakeTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*UnstakeTx) Execute

func (tx *UnstakeTx) Execute(b *core.Block) error

Execute UnstakeTx

func (*UnstakeTx) PointChange

func (tx *UnstakeTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*UnstakeTx) RecoverFrom

func (tx *UnstakeTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

type VotePayload

type VotePayload struct {
	CandidateIDs [][]byte
}

VotePayload is payload type for VoteTx

func (*VotePayload) FromBytes

func (payload *VotePayload) FromBytes(b []byte) error

FromBytes converts bytes to payload.

func (*VotePayload) ToBytes

func (payload *VotePayload) ToBytes() ([]byte, error)

ToBytes returns marshaled RevokeCertificationPayload

type VoteTx

type VoteTx struct {
	*core.Transaction
	// contains filtered or unexported fields
}

VoteTx is a structure for voting

func (*VoteTx) Bandwidth

func (tx *VoteTx) Bandwidth() *common.Bandwidth

Bandwidth returns bandwidth.

func (*VoteTx) Execute

func (tx *VoteTx) Execute(b *core.Block) error

Execute VoteTx

func (*VoteTx) PointChange

func (tx *VoteTx) PointChange() (neg bool, abs *util.Uint128)

PointChange returns account's point change when applying this transaction.

func (*VoteTx) RecoverFrom

func (tx *VoteTx) RecoverFrom() (common.Address, error)

RecoverFrom returns from account's address.

Jump to

Keyboard shortcuts

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