Documentation ¶
Index ¶
Constants ¶
const MethodSeparator = "."
MethodSeparator is the separator used to separate backend name from method name.
Variables ¶
var ( // ErrInsufficientFeeBalance is the error returned when there is insufficient // balance to pay consensus fees. ErrInsufficientFeeBalance = errors.New(moduleName, 2, "transaction: insufficient balance to pay fees") // ErrGasPriceTooLow is the error returned when the gas price is too low. ErrGasPriceTooLow = errors.New(moduleName, 3, "transaction: gas price too low") )
var ( // ErrInvalidNonce is the error returned when a nonce is invalid. ErrInvalidNonce = errors.New(moduleName, 1, "transaction: invalid nonce") // SignatureContext is the context used for signing transactions. SignatureContext = signature.NewContext("oasis-core/consensus: tx", signature.WithChainSeparation()) )
Functions ¶
This section is empty.
Types ¶
type Fee ¶
type Fee struct { // Amount is the fee amount to be paid. Amount quantity.Quantity `json:"amount"` // Gas is the maximum gas that a transaction can use. Gas Gas `json:"gas"` }
Fee is the consensus transaction fee the sender wishes to pay for operations which require a fee to be paid to validators.
func (Fee) PrettyPrint ¶ added in v0.2010.0
PrettyPrint writes a pretty-printed representation of the fee to the given writer.
func (Fee) PrettyType ¶ added in v0.2010.0
PrettyType returns a representation of Fee that can be used for pretty printing.
type MethodName ¶
type MethodName string
MethodName is a method name.
func NewMethodName ¶
func NewMethodName(module, method string, bodyType interface{}) MethodName
NewMethodName creates a new method name.
Module and method pair must be unique. If they are not, this method will panic.
func (MethodName) BodyType ¶
func (m MethodName) BodyType() interface{}
BodyType returns the registered body type associated with this method.
func (MethodName) SanityCheck ¶
func (m MethodName) SanityCheck() error
SanityCheck performs a basic sanity check on the method name.
type PrettyTransaction ¶
type PrettyTransaction struct { Nonce uint64 `json:"nonce"` Fee *Fee `json:"fee,omitempty"` Method MethodName `json:"method"` Body interface{} `json:"body,omitempty"` }
PrettyTransaction is used for pretty-printing transactions so that the actual content is displayed instead of the binary blob.
It should only be used for pretty printing.
type SignedTransaction ¶
SignedTransaction is a signed transaction.
func Sign ¶
func Sign(signer signature.Signer, tx *Transaction) (*SignedTransaction, error)
Sign signs a transaction.
func (*SignedTransaction) Hash ¶
func (s *SignedTransaction) Hash() hash.Hash
Hash returns the cryptographic hash of the encoded transaction.
func (*SignedTransaction) Open ¶
func (s *SignedTransaction) Open(tx *Transaction) error
Open first verifies the blob signature and then unmarshals the blob.
func (SignedTransaction) PrettyPrint ¶
PrettyPrint writes a pretty-printed representation of the type to the given writer.
func (SignedTransaction) PrettyType ¶
func (s SignedTransaction) PrettyType() (interface{}, error)
PrettyType returns a representation of the type that can be used for pretty printing.
type Transaction ¶
type Transaction struct { // Nonce is a nonce to prevent replay. Nonce uint64 `json:"nonce"` // Fee is an optional fee that the sender commits to pay to execute this // transaction. Fee *Fee `json:"fee,omitempty"` // Method is the method that should be called. Method MethodName `json:"method"` // Body is the method call body. Body cbor.RawMessage `json:"body,omitempty"` }
Transaction is an unsigned consensus transaction.
func NewTransaction ¶
func NewTransaction(nonce uint64, fee *Fee, method MethodName, body interface{}) *Transaction
NewTransaction creates a new transaction.
func (Transaction) PrettyPrint ¶
PrettyPrint writes a pretty-printed representation of the transaction to the given writer.
func (Transaction) PrettyPrintBody ¶
PrettyPrintBody writes a pretty-printed representation of transaction's body to the given writer.
func (*Transaction) PrettyType ¶
func (t *Transaction) PrettyType() (interface{}, error)
PrettyType returns a representation of the type that can be used for pretty printing.
func (*Transaction) SanityCheck ¶
func (t *Transaction) SanityCheck() error
SanityCheck performs a basic sanity check on the transaction.