Documentation ¶
Index ¶
Constants ¶
const ( // MethodPriorityNormal is the normal method priority. MethodPriorityNormal = 0 // MethodPriorityCritical is the priority for methods critical to the protocol operation. MethodPriorityCritical = 255 )
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") // ErrUpgradePending is the error returned when an upgrade is pending and the transaction thus // cannot be processed right now. The submitter should retry the transaction in this case. ErrUpgradePending = errors.New(moduleName, 4, "transaction: upgrade pending") // 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 MethodMetadata ¶ added in v0.2100.0
type MethodMetadata struct {
Priority MethodPriority
}
MethodMetadata is the method metadata.
type MethodMetadataProvider ¶ added in v0.2100.0
type MethodMetadataProvider interface { // MethodMetadata returns the method metadata. MethodMetadata() MethodMetadata }
MethodMetadataProvider is the method metadata provider interface that can be implemented by method body types to provide additional method metadata.
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) IsCritical ¶ added in v0.2100.0
func (m MethodName) IsCritical() bool
IsCritical returns true if the method is critical for the operation of the protocol.
func (MethodName) Metadata ¶ added in v0.2100.0
func (m MethodName) Metadata() MethodMetadata
Metadata returns the method metadata.
func (MethodName) SanityCheck ¶
func (m MethodName) SanityCheck() error
SanityCheck performs a basic sanity check on the method name.
type MethodPriority ¶ added in v0.2100.0
type MethodPriority uint8
MethodPriority is the method handling priority.
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 OpenRawTransactions ¶ added in v0.2200.3
func OpenRawTransactions(rawTxBytes [][]byte) ([]signature.PublicKey, []*Transaction, []error)
OpenRawTransactions takes a vector of raw byte-serialized SignedTransactions, and deserializes them, returning all of the signing public key and deserialized Transaction, for the transactions that have valid signatures.
The index of each of the return values is that of the corresponding raw transaction input.
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.