action

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingData        = codes.ProtocolError{codes.TxErrMisingData, "missing data in transaction"}
	ErrUnserializable     = codes.ProtocolError{codes.TxErrUnserializable, "unserializable tx"}
	ErrWrongTxType        = codes.ProtocolError{codes.TxErrWrongTxType, "wrong tx type"}
	ErrInvalidAmount      = codes.ProtocolError{codes.TxErrInvalidAmount, "invalid amount"}
	ErrInvalidPubkey      = codes.ProtocolError{codes.TxErrInvalidPubKey, "invalid pubkey"}
	ErrUnmatchSigner      = codes.ProtocolError{codes.TxErrUnmatchedSigner, "unmatch signers"}
	ErrInvalidSignature   = codes.ProtocolError{codes.TxErrInvalidSignature, "invalid signatures"}
	ErrInvalidFeeCurrency = codes.ProtocolError{codes.TxErrInvalidFeeCurrency, "invalid fees currency"}
	ErrInvalidFeePrice    = codes.ProtocolError{codes.TxErrInvalidFeePrice, "fee price is smaller than minimal fee"}
	ErrNotEnoughFund      = codes.ProtocolError{codes.TxErrInsufficientFunds, "not enough fund"}
	ErrGasOverflow        = codes.ProtocolError{codes.TxErrGasOverflow, "gas used exceed limit"}
	ErrInvalidExtTx       = codes.ProtocolError{codes.TxErrInvalidExtTx, "invalid external tx"}
)

Functions

func ValidateBasic added in v0.10.8

func ValidateBasic(data []byte, signerAddr []Address, signatures []Signature) error

func ValidateFee added in v0.12.0

func ValidateFee(feeOpt *fees.FeeOption, fee Fee) error

Types

type Address

type Address = keys.Address

Address an action package over Address in data/keys package

type Amount

type Amount struct {
	Currency string         `json:"currency"`
	Value    balance.Amount `json:"value"`
}

Amount is an easily serializable representation of coin. Nodes can create coin from the Amount object received over the network

func NewAmount added in v0.10.4

func NewAmount(currency string, amount balance.Amount) *Amount

New Amount creates a new amount account object

func (Amount) IsValid

func (a Amount) IsValid(list *balance.CurrencySet) bool

IsValid checks the validity of the currency and the amount string in the account object, which may be received over a network.

func (Amount) String

func (a Amount) String() string

String returns a string representation of the Amount object.

func (Amount) ToCoin

func (a Amount) ToCoin(list *balance.CurrencySet) balance.Coin

ToCoin converts an easier to transport Amount object to a Coin object in Oneledger protocol. It takes the action context to determine the currency from which to create the coin.

type Balance

type Balance = balance.Balance

Balance an action package over Balance in data/balance

type Context

type Context struct {
	Router               Router
	State                *storage.State
	Header               *abci.Header
	Accounts             accounts.Wallet
	Balances             *balance.Store
	Domains              *ons.DomainStore
	FeePool              *fees.Store
	Currencies           *balance.CurrencySet
	FeeOpt               *fees.FeeOption
	Validators           *identity.ValidatorStore
	BTCTrackers          *bitcoin.TrackerStore
	ETHTrackers          *ethereum.TrackerStore
	Logger               *log.Logger
	JobStore             *jobs.JobStore
	LockScriptStore      *bitcoin.LockScriptStore
	BTCChainType         *chaincfg.Params
	BlockCypherToken     string
	BlockCypherChainType string
}

func NewContext

func NewContext(r Router, header *abci.Header, state *storage.State,
	wallet accounts.Wallet, balances *balance.Store,
	currencies *balance.CurrencySet, feeOpt *fees.FeeOption, feePool *fees.Store,
	validators *identity.ValidatorStore, domains *ons.DomainStore,
	btcTrackers *bitcoin.TrackerStore, ethTrackers *ethereum.TrackerStore,
	jobStore *jobs.JobStore, btcChainType *chaincfg.Params, lockScriptStore *bitcoin.LockScriptStore,
	blockCypherToken, blockCypherChainType string,
	logger *log.Logger) *Context

type Fee

type Fee struct {
	Price Amount `json:"price"`
	Gas   int64  `json:"gas"`
}

type Gas added in v0.12.0

type Gas = storage.Gas

Gas an action package over Gas in storage

type Msg

type Msg interface {
	// return the necessary signers for the message, should have consistent order across the network
	Signers() []Address

	Type() Type

	Tags() common.KVPairs

	Marshal() ([]byte, error)

	Unmarshal([]byte) error
}

type MsgData added in v0.10.8

type MsgData []byte

type RawTx added in v0.10.8

type RawTx struct {
	Type Type    `json:"tx_type"`
	Data MsgData `json:"tx_data"`
	Fee  Fee     `json:"fee"`
	Memo string  `json:"memo"`
}

func (*RawTx) RawBytes added in v0.10.8

func (t *RawTx) RawBytes() []byte

type Response

type Response struct {
	Data      []byte
	Log       string
	Info      string
	GasWanted int64
	GasUsed   int64
	Tags      []common.KVPair
}

func BasicFeeHandling added in v0.12.0

func BasicFeeHandling(ctx *Context, signedTx SignedTx, start Gas, size Gas, signatureCnt Gas) (bool, Response)

type Router

type Router interface {
	AddHandler(Type, Tx) error
	Handler(Type) Tx
}

Router interface supplies functionality to add a handler function and Handle a request.

func NewRouter

func NewRouter(name string) Router

NewRouter creates a new router object with given name.

type Signature

type Signature struct {
	Signer keys.PublicKey
	Signed []byte
}

func (Signature) Verify

func (s Signature) Verify(msg []byte) bool

type SignedTx added in v0.10.8

type SignedTx struct {
	RawTx
	Signatures []Signature `json:"signatures"`
}

func (*SignedTx) SignedBytes added in v0.10.8

func (t *SignedTx) SignedBytes() []byte

type Tx

type Tx interface {
	//it should be able to validate a tx by itself, non-valid tx will be reject by the node directly
	//without going to node process
	Validate(ctx *Context, signedTx SignedTx) (bool, error)

	//check tx on the first node who receives it, if process check failed, the tx will not be broadcast
	//could store a version of checked value in storage, but not implemented now
	ProcessCheck(ctx *Context, tx RawTx) (bool, Response)

	//deliver tx on the chain by changing the storage values, which should only be committed at Application
	//commit stage
	ProcessDeliver(ctx *Context, tx RawTx) (bool, Response)

	//process the charge of fees
	ProcessFee(ctx *Context, signedTx SignedTx, start Gas, size Gas) (bool, Response)
}

type Type

type Type int
const (
	SEND Type = 0x01

	//staking related transaction
	APPLYVALIDATOR Type = 0x11
	WITHDRAW       Type = 0x12

	//ons related transaction
	DOMAIN_CREATE   Type = 0x21
	DOMAIN_UPDATE   Type = 0x22
	DOMAIN_SELL     Type = 0x23
	DOMAIN_PURCHASE Type = 0x24
	DOMAIN_SEND     Type = 0x25

	BTC_LOCK                   Type = 0x81
	BTC_ADD_SIGNATURE          Type = 0x82
	BTC_BROADCAST_SUCCESS      Type = 0x83
	BTC_REPORT_FINALITY_MINT   Type = 0x84
	BTC_EXT_MINT               Type = 0x85
	BTC_REDEEM                 Type = 0x86
	BTC_FAILED_BROADCAST_RESET Type = 0x87

	//Ethereum Actions
	ETH_LOCK                 Type = 0x91
	ETH_SIGN                 Type = 0x92
	ETH_FINALITY             Type = 0x93
	ETH_MINT                 Type = 0x94
	ETH_REPORT_FINALITY_MINT Type = 0x95
	ETH_REDEEM               Type = 0x96
)

func (Type) String

func (t Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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