Documentation ¶
Index ¶
- Variables
- func CheckBadTx(tx *Tx) error
- func SignTxContent(tx *Tx, id string, account *account.KeyPair) (*crypto.Signature, error)
- type Action
- type Receipt
- type ReceiptType
- type Status
- type StatusCode
- type ToBytesLevel
- type Tx
- func (t *Tx) CheckGas() error
- func (t *Tx) CheckSize() error
- func (t *Tx) Decode(b []byte) error
- func (t *Tx) Encode() []byte
- func (t *Tx) FromPb(tr *txpb.Tx) *Tx
- func (t *Tx) Hash() []byte
- func (t *Tx) IsCreatedBefore(ct int64) bool
- func (t *Tx) IsExpired(ct int64) bool
- func (t *Tx) String() string
- func (t *Tx) ToBytes(l ToBytesLevel) []byte
- func (t *Tx) ToPb() *txpb.Tx
- func (t *Tx) VerifySelf() error
- func (t *Tx) VerifySigner(sig *crypto.Signature) bool
- type TxReceipt
Constants ¶
This section is empty.
Variables ¶
var ( MaxExpiration = int64(90 * time.Second) ChainID uint32 )
values
Functions ¶
Types ¶
type Action ¶
type Action struct { Contract string `json:"contract"` // contract name ActionName string `json:"actionName"` // method name of contract Data string `json:"data"` // parameters of method, with json format }
Action implement
type Receipt ¶
Receipt generated when applying transaction
type ReceiptType ¶
type ReceiptType int32
ReceiptType type of single receipt
const ( // SystemDefined system receipt, recording info of calling a method SystemDefined ReceiptType = iota // UserDefined user defined receipt, usually a json string UserDefined )
type Status ¶
type Status struct { Code StatusCode Message string }
Status status of transaction execution result, including code and message
type StatusCode ¶
type StatusCode int32
StatusCode status code of transaction execution result
const ( Success StatusCode = iota ErrorGasRunOut ErrorBalanceNotEnough ErrorParamter // parameter mismatch when calling function ErrorRuntime // runtime error ErrorTimeout ErrorTxFormat // tx format errors ErrorDuplicateSetCode // more than one set code action in a tx ErrorUnknown // other errors )
tx execution result
type ToBytesLevel ¶
type ToBytesLevel int
ToBytesLevel judges which fields of tx should be written to bytes.
const ( Base ToBytesLevel = iota Publish Full )
consts
type Tx ¶
type Tx struct { Time int64 `json:"time"` Expiration int64 `json:"expiration"` GasRatio int64 `json:"gas_ratio"` GasLimit int64 `json:"gas_limit"` Delay int64 `json:"delay"` ChainID uint32 `json:"chain_id"` Actions []*Action `json:"-"` Signers []string `json:"-"` Signs []*crypto.Signature `json:"-"` Publisher string `json:"-"` PublishSigns []*crypto.Signature `json:"-"` ReferredTx []byte `json:"referred_tx"` AmountLimit []*contract.Amount `json:"amountLimit"` Reserved []byte `json:"reserved"` // contains filtered or unexported fields }
Tx Transaction structure
func NewTx ¶
func NewTx(actions []*Action, signers []string, gasLimit, gasRatio, expiration, delay int64, chainID uint32) *Tx
NewTx return a new Tx
func (*Tx) IsCreatedBefore ¶
IsCreatedBefore checks whether the transaction time is valid compared to the given time ct. ct may be time.Now().UnixNano() or block head time.
func (*Tx) IsExpired ¶
IsExpired checks whether the transaction is expired compared to the given time ct.
func (*Tx) VerifySelf ¶
VerifySelf verify tx's signature and some base fields.
type TxReceipt ¶
type TxReceipt struct { TxHash []byte GasUsage int64 RAMUsage map[string]int64 Status *Status Returns []string Receipts []*Receipt }
TxReceipt Transaction Receipt
func NewTxReceipt ¶
NewTxReceipt generate tx receipt for a tx hash