transaction

package
v1.2.20 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: GPL-3.0 Imports: 16 Imported by: 18 modules, 113 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaskGuardedTransaction = uint32(1) << 1

MaskGuardedTransaction - this mask is used to verify if the flag for guarded transaction is set in the transaction option field

View Source
const MaskSignedWithHash = uint32(1)

MaskSignedWithHash - this mask is used to verify if LSB from last byte from field options from transaction is set

Variables

View Source
var (
	ErrInvalidLengthLog        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowLog          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupLog = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthTransaction        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTransaction          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTransaction = fmt.Errorf("proto: unexpected end of group")
)
View Source
var ErrNiStorageService = errors.New("nil StorageService")

ErrNilApiTransactionResult signals that a nil api transaction result has been provided

View Source
var ErrNilApiTransactionResult = errors.New("nil ApiTransactionResult")

ErrNilApiTransactionResult signals that a nil api transaction result has been provided

View Source
var ErrNilEncoder = errors.New("nil encoder")

ErrNilEncoder signals that a nil encoder has been provided

View Source
var ErrNilHasher = errors.New("nil hasher")

ErrNilHasher signals that a nil hasher has been provided

View Source
var ErrNilMarshalizer = errors.New("nil marshalizer")

ErrNilMarshalizer signals that a nil marshalizer has been provided

View Source
var ErrNilUint64ByteSliceConverter = errors.New("nil Uint64ByteSliceConverter")

ErrNilApiTransactionResult signals that a nil api transaction result has been provided

Functions

func TrimSliceHandler

func TrimSliceHandler(in []data.TransactionHandler) []data.TransactionHandler

TrimSliceHandler creates a copy of the provided slice without the excess capacity

Types

type ApiLogs

type ApiLogs struct {
	Address string    `json:"address"`
	Events  []*Events `json:"events"`
}

ApiLogs represents logs with changed fields' types in order to make it friendly for API's json

type ApiReceipt

type ApiReceipt struct {
	Value   *big.Int `json:"value"`
	SndAddr string   `json:"sender"`
	Data    string   `json:"data,omitempty"`
	TxHash  string   `json:"txHash"`
}

ApiReceipt represents a receipt with changed fields' types in order to make it friendly for API's json

type ApiSmartContractResult

type ApiSmartContractResult struct {
	Hash              string      `json:"hash,omitempty"`
	Nonce             uint64      `json:"nonce"`
	Value             *big.Int    `json:"value"`
	RcvAddr           string      `json:"receiver"`
	SndAddr           string      `json:"sender"`
	RelayerAddr       string      `json:"relayerAddress,omitempty"`
	RelayedValue      *big.Int    `json:"relayedValue,omitempty"`
	Code              string      `json:"code,omitempty"`
	Data              string      `json:"data,omitempty"`
	PrevTxHash        string      `json:"prevTxHash"`
	OriginalTxHash    string      `json:"originalTxHash"`
	GasLimit          uint64      `json:"gasLimit"`
	GasPrice          uint64      `json:"gasPrice"`
	CallType          vm.CallType `json:"callType"`
	CodeMetadata      string      `json:"codeMetadata,omitempty"`
	ReturnMessage     string      `json:"returnMessage,omitempty"`
	OriginalSender    string      `json:"originalSender,omitempty"`
	Logs              *ApiLogs    `json:"logs,omitempty"`
	Tokens            []string    `json:"tokens,omitempty"`
	ESDTValues        []string    `json:"esdtValues,omitempty"`
	Receivers         []string    `json:"receivers,omitempty"`
	ReceiversShardIDs []uint32    `json:"receiversShardIDs,omitempty"`
	Operation         string      `json:"operation,omitempty"`
	Function          string      `json:"function,omitempty"`
	IsRelayed         bool        `json:"isRelayed,omitempty"`
	IsRefund          bool        `json:"isRefund,omitempty"`
}

ApiSmartContractResult represents a smart contract result with changed fields' types in order to make it friendly for API's json

type ApiTransactionResult

type ApiTransactionResult struct {
	Tx                                data.TransactionHandler   `json:"-"`
	Type                              string                    `json:"type"`
	ProcessingTypeOnSource            string                    `json:"processingTypeOnSource,omitempty"`
	ProcessingTypeOnDestination       string                    `json:"processingTypeOnDestination,omitempty"`
	Hash                              string                    `json:"hash,omitempty"`
	HashBytes                         []byte                    `json:"-"`
	Nonce                             uint64                    `json:"nonce"`
	Round                             uint64                    `json:"round"`
	Epoch                             uint32                    `json:"epoch"`
	Value                             string                    `json:"value,omitempty"`
	Receiver                          string                    `json:"receiver,omitempty"`
	Sender                            string                    `json:"sender,omitempty"`
	SenderUsername                    []byte                    `json:"senderUsername,omitempty"`
	ReceiverUsername                  []byte                    `json:"receiverUsername,omitempty"`
	GasPrice                          uint64                    `json:"gasPrice,omitempty"`
	GasLimit                          uint64                    `json:"gasLimit,omitempty"`
	GasUsed                           uint64                    `json:"gasUsed,omitempty"`
	Data                              []byte                    `json:"data,omitempty"`
	CodeMetadata                      []byte                    `json:"codeMetadata,omitempty"`
	Code                              string                    `json:"code,omitempty"`
	PreviousTransactionHash           string                    `json:"previousTransactionHash,omitempty"`
	OriginalTransactionHash           string                    `json:"originalTransactionHash,omitempty"`
	ReturnMessage                     string                    `json:"returnMessage,omitempty"`
	OriginalSender                    string                    `json:"originalSender,omitempty"`
	Signature                         string                    `json:"signature,omitempty"`
	SourceShard                       uint32                    `json:"sourceShard"`
	DestinationShard                  uint32                    `json:"destinationShard"`
	BlockNonce                        uint64                    `json:"blockNonce,omitempty"`
	BlockHash                         string                    `json:"blockHash,omitempty"`
	NotarizedAtSourceInMetaNonce      uint64                    `json:"notarizedAtSourceInMetaNonce,omitempty"`
	NotarizedAtSourceInMetaHash       string                    `json:"NotarizedAtSourceInMetaHash,omitempty"`
	NotarizedAtDestinationInMetaNonce uint64                    `json:"notarizedAtDestinationInMetaNonce,omitempty"`
	NotarizedAtDestinationInMetaHash  string                    `json:"notarizedAtDestinationInMetaHash,omitempty"`
	MiniBlockType                     string                    `json:"miniblockType,omitempty"`
	MiniBlockHash                     string                    `json:"miniblockHash,omitempty"`
	HyperblockNonce                   uint64                    `json:"hyperblockNonce,omitempty"`
	HyperblockHash                    string                    `json:"hyperblockHash,omitempty"`
	Timestamp                         int64                     `json:"timestamp,omitempty"`
	Receipt                           *ApiReceipt               `json:"receipt,omitempty"`
	SmartContractResults              []*ApiSmartContractResult `json:"smartContractResults,omitempty"`
	Logs                              *ApiLogs                  `json:"logs,omitempty"`
	Status                            TxStatus                  `json:"status,omitempty"`
	Tokens                            []string                  `json:"tokens,omitempty"`
	ESDTValues                        []string                  `json:"esdtValues,omitempty"`
	Receivers                         []string                  `json:"receivers,omitempty"`
	ReceiversShardIDs                 []uint32                  `json:"receiversShardIDs,omitempty"`
	Operation                         string                    `json:"operation,omitempty"`
	Function                          string                    `json:"function,omitempty"`
	InitiallyPaidFee                  string                    `json:"initiallyPaidFee,omitempty"`
	Fee                               string                    `json:"fee,omitempty"`
	IsRelayed                         bool                      `json:"isRelayed,omitempty"`
	IsRefund                          bool                      `json:"isRefund,omitempty"`
	CallType                          string                    `json:"callType,omitempty"`
	RelayerAddress                    string                    `json:"relayerAddress,omitempty"`
	RelayedValue                      string                    `json:"relayedValue,omitempty"`
	ChainID                           string                    `json:"chainID,omitempty"`
	Version                           uint32                    `json:"version,omitempty"`
	Options                           uint32                    `json:"options"`
	GuardianAddr                      string                    `json:"guardian,omitempty"`
	GuardianSignature                 string                    `json:"guardianSignature,omitempty"`
}

ApiTransactionResult is the data transfer object which will be returned on the get transaction by hash endpoint

type CostResponse

type CostResponse struct {
	GasUnits             uint64                             `json:"txGasUnits"`
	ReturnMessage        string                             `json:"returnMessage"`
	SmartContractResults map[string]*ApiSmartContractResult `json:"smartContractResults"`
	Logs                 *ApiLogs                           `json:"logs,omitempty"`
}

CostResponse is structure used to return the transaction cost in gas units

type Event

type Event struct {
	Address        []byte   `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"`
	Identifier     []byte   `protobuf:"bytes,2,opt,name=Identifier,proto3" json:"identifier"`
	Topics         [][]byte `protobuf:"bytes,3,rep,name=Topics,proto3" json:"topics"`
	Data           []byte   `protobuf:"bytes,4,opt,name=Data,proto3" json:"data"`
	AdditionalData [][]byte `protobuf:"bytes,5,rep,name=AdditionalData,proto3" json:"additionalData"`
}

Event holds all the data needed for an event structure

func (*Event) Descriptor

func (*Event) Descriptor() ([]byte, []int)

func (*Event) Equal

func (this *Event) Equal(that interface{}) bool

func (*Event) GetAdditionalData added in v1.2.14

func (m *Event) GetAdditionalData() [][]byte

func (*Event) GetAddress

func (m *Event) GetAddress() []byte

func (*Event) GetData

func (m *Event) GetData() []byte

func (*Event) GetIdentifier

func (m *Event) GetIdentifier() []byte

func (*Event) GetTopics

func (m *Event) GetTopics() [][]byte

func (*Event) GoString

func (this *Event) GoString() string

func (*Event) IsInterfaceNil

func (e *Event) IsInterfaceNil() bool

IsInterfaceNil verifies if underlying object is nil

func (*Event) Marshal

func (m *Event) Marshal() (dAtA []byte, err error)

func (*Event) MarshalTo

func (m *Event) MarshalTo(dAtA []byte) (int, error)

func (*Event) MarshalToSizedBuffer

func (m *Event) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) Reset

func (m *Event) Reset()

func (*Event) Size

func (m *Event) Size() (n int)

func (*Event) String

func (this *Event) String() string

func (*Event) Unmarshal

func (m *Event) Unmarshal(dAtA []byte) error

func (*Event) XXX_DiscardUnknown

func (m *Event) XXX_DiscardUnknown()

func (*Event) XXX_Marshal

func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Event) XXX_Merge

func (m *Event) XXX_Merge(src proto.Message)

func (*Event) XXX_Size

func (m *Event) XXX_Size() int

func (*Event) XXX_Unmarshal

func (m *Event) XXX_Unmarshal(b []byte) error

type Events

type Events struct {
	Address        string   `json:"address"`
	Identifier     string   `json:"identifier"`
	Topics         [][]byte `json:"topics"`
	Data           []byte   `json:"data"`
	AdditionalData [][]byte `json:"additionalData"`
}

Events represents the events generated by a transaction with changed fields' types in order to make it friendly for API's json

type FrontendTransaction

type FrontendTransaction struct {
	Nonce             uint64 `json:"nonce"`
	Value             string `json:"value"`
	Receiver          string `json:"receiver"`
	Sender            string `json:"sender"`
	SenderUsername    []byte `json:"senderUsername,omitempty"`
	ReceiverUsername  []byte `json:"receiverUsername,omitempty"`
	GasPrice          uint64 `json:"gasPrice"`
	GasLimit          uint64 `json:"gasLimit"`
	Data              []byte `json:"data,omitempty"`
	Signature         string `json:"signature,omitempty"`
	ChainID           string `json:"chainID"`
	Version           uint32 `json:"version"`
	Options           uint32 `json:"options,omitempty"`
	GuardianAddr      string `json:"guardian,omitempty"`
	GuardianSignature string `json:"guardianSignature,omitempty"`
}

FrontendTransaction represents the DTO used in transaction signing/validation.

type Log

type Log struct {
	Address []byte   `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"`
	Events  []*Event `protobuf:"bytes,2,rep,name=Events,proto3" json:"events"`
}

Log holds all the data needed for a log structure

func (*Log) Descriptor

func (*Log) Descriptor() ([]byte, []int)

func (*Log) Equal

func (this *Log) Equal(that interface{}) bool

func (*Log) GetAddress

func (m *Log) GetAddress() []byte

func (*Log) GetEvents

func (m *Log) GetEvents() []*Event

func (*Log) GetLogEvents

func (l *Log) GetLogEvents() []data.EventHandler

GetLogEvents returns the interface for the underlying events of the log structure

func (*Log) GoString

func (this *Log) GoString() string

func (*Log) IsInterfaceNil

func (l *Log) IsInterfaceNil() bool

IsInterfaceNil verifies if underlying object is nil

func (*Log) Marshal

func (m *Log) Marshal() (dAtA []byte, err error)

func (*Log) MarshalTo

func (m *Log) MarshalTo(dAtA []byte) (int, error)

func (*Log) MarshalToSizedBuffer

func (m *Log) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Log) ProtoMessage

func (*Log) ProtoMessage()

func (*Log) Reset

func (m *Log) Reset()

func (*Log) Size

func (m *Log) Size() (n int)

func (*Log) String

func (this *Log) String() string

func (*Log) Unmarshal

func (m *Log) Unmarshal(dAtA []byte) error

func (*Log) XXX_DiscardUnknown

func (m *Log) XXX_DiscardUnknown()

func (*Log) XXX_Marshal

func (m *Log) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Log) XXX_Merge

func (m *Log) XXX_Merge(src proto.Message)

func (*Log) XXX_Size

func (m *Log) XXX_Size() int

func (*Log) XXX_Unmarshal

func (m *Log) XXX_Unmarshal(b []byte) error

type SimulationResults added in v1.2.8

type SimulationResults struct {
	Hash       string                             `json:"hash,omitempty"`
	FailReason string                             `json:"failReason,omitempty"`
	Status     TxStatus                           `json:"status,omitempty"`
	ScResults  map[string]*ApiSmartContractResult `json:"scResults,omitempty"`
	Receipts   map[string]*ApiReceipt             `json:"receipts,omitempty"`
	Logs       *ApiLogs                           `json:"logs,omitempty"`
}

SimulationResults is the data transfer object which will hold results for simulating a transaction's execution

type StatusComputerHandler

type StatusComputerHandler interface {
	ComputeStatusWhenInStorageKnowingMiniblock(miniblockType block.Type, tx *ApiTransactionResult) (TxStatus, error)
	ComputeStatusWhenInStorageNotKnowingMiniblock(destinationShard uint32, tx *ApiTransactionResult) (TxStatus, error)
	SetStatusIfIsRewardReverted(
		tx *ApiTransactionResult,
		miniblockType block.Type,
		headerNonce uint64,
		headerHash []byte,
	) (bool, error)
}

StatusComputerHandler computes a transaction status

type Transaction

type Transaction struct {
	Nonce             uint64        `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"`
	Value             *math_big.Int `` /* 136-byte string literal not displayed */
	RcvAddr           []byte        `protobuf:"bytes,3,opt,name=RcvAddr,proto3" json:"receiver"`
	RcvUserName       []byte        `protobuf:"bytes,4,opt,name=RcvUserName,proto3" json:"rcvUserName,omitempty"`
	SndAddr           []byte        `protobuf:"bytes,5,opt,name=SndAddr,proto3" json:"sender"`
	SndUserName       []byte        `protobuf:"bytes,6,opt,name=SndUserName,proto3" json:"sndUserName,omitempty"`
	GasPrice          uint64        `protobuf:"varint,7,opt,name=GasPrice,proto3" json:"gasPrice,omitempty"`
	GasLimit          uint64        `protobuf:"varint,8,opt,name=GasLimit,proto3" json:"gasLimit,omitempty"`
	Data              []byte        `protobuf:"bytes,9,opt,name=Data,proto3" json:"data,omitempty"`
	ChainID           []byte        `protobuf:"bytes,10,opt,name=ChainID,proto3" json:"chainID"`
	Version           uint32        `protobuf:"varint,11,opt,name=Version,proto3" json:"version"`
	Signature         []byte        `protobuf:"bytes,12,opt,name=Signature,proto3" json:"signature,omitempty"`
	Options           uint32        `protobuf:"varint,13,opt,name=Options,proto3" json:"options,omitempty"`
	GuardianAddr      []byte        `protobuf:"bytes,14,opt,name=GuardianAddr,proto3" json:"guardian,omitempty"`
	GuardianSignature []byte        `protobuf:"bytes,15,opt,name=GuardianSignature,proto3" json:"guardianSignature,omitempty"`
}

Transaction holds all the data needed for a value transfer or SC call

func TrimSlicePtr

func TrimSlicePtr(in []*Transaction) []*Transaction

TrimSlicePtr creates a copy of the provided slice without the excess capacity

func (*Transaction) CheckIntegrity

func (tx *Transaction) CheckIntegrity() error

CheckIntegrity checks for not nil fields and negative value

func (*Transaction) Descriptor

func (*Transaction) Descriptor() ([]byte, []int)

func (*Transaction) Equal

func (this *Transaction) Equal(that interface{}) bool

func (*Transaction) GetChainID

func (m *Transaction) GetChainID() []byte

func (*Transaction) GetData

func (m *Transaction) GetData() []byte

func (*Transaction) GetDataForSigning

func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.Marshaller, hasher data.Hasher) ([]byte, error)

GetDataForSigning returns the serialized transaction having an empty signature field

func (*Transaction) GetGasLimit

func (m *Transaction) GetGasLimit() uint64

func (*Transaction) GetGasPrice

func (m *Transaction) GetGasPrice() uint64

func (*Transaction) GetGuardianAddr added in v1.1.36

func (m *Transaction) GetGuardianAddr() []byte

func (*Transaction) GetGuardianSignature added in v1.1.36

func (m *Transaction) GetGuardianSignature() []byte

func (*Transaction) GetNonce

func (m *Transaction) GetNonce() uint64

func (*Transaction) GetOptions

func (m *Transaction) GetOptions() uint32

func (*Transaction) GetRcvAddr

func (m *Transaction) GetRcvAddr() []byte

func (*Transaction) GetRcvUserName

func (m *Transaction) GetRcvUserName() []byte

func (*Transaction) GetSignature

func (m *Transaction) GetSignature() []byte

func (*Transaction) GetSndAddr

func (m *Transaction) GetSndAddr() []byte

func (*Transaction) GetSndUserName

func (m *Transaction) GetSndUserName() []byte

func (*Transaction) GetValue

func (m *Transaction) GetValue() *math_big.Int

func (*Transaction) GetVersion

func (m *Transaction) GetVersion() uint32

func (*Transaction) GoString

func (this *Transaction) GoString() string

func (*Transaction) HasOptionGuardianSet added in v1.1.36

func (tx *Transaction) HasOptionGuardianSet() bool

HasOptionGuardianSet returns true if the guarded transaction option is set

func (*Transaction) HasOptionHashSignSet added in v1.1.36

func (tx *Transaction) HasOptionHashSignSet() bool

HasOptionHashSignSet returns true if the signed with hash option is set

func (*Transaction) IsInterfaceNil

func (tx *Transaction) IsInterfaceNil() bool

IsInterfaceNil verifies if underlying object is nil

func (*Transaction) Marshal

func (m *Transaction) Marshal() (dAtA []byte, err error)

func (*Transaction) MarshalTo

func (m *Transaction) MarshalTo(dAtA []byte) (int, error)

func (*Transaction) MarshalToSizedBuffer

func (m *Transaction) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Transaction) ProtoMessage

func (*Transaction) ProtoMessage()

func (*Transaction) Reset

func (m *Transaction) Reset()

func (*Transaction) SetData

func (tx *Transaction) SetData(data []byte)

SetData sets the data of the transaction

func (*Transaction) SetRcvAddr

func (tx *Transaction) SetRcvAddr(addr []byte)

SetRcvAddr sets the receiver address of the transaction

func (*Transaction) SetSndAddr

func (tx *Transaction) SetSndAddr(addr []byte)

SetSndAddr sets the sender address of the transaction

func (*Transaction) SetValue

func (tx *Transaction) SetValue(value *big.Int)

SetValue sets the value of the transaction

func (*Transaction) Size

func (m *Transaction) Size() (n int)

func (*Transaction) String

func (this *Transaction) String() string

func (*Transaction) Unmarshal

func (m *Transaction) Unmarshal(dAtA []byte) error

func (*Transaction) XXX_DiscardUnknown

func (m *Transaction) XXX_DiscardUnknown()

func (*Transaction) XXX_Marshal

func (m *Transaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Transaction) XXX_Merge

func (m *Transaction) XXX_Merge(src proto.Message)

func (*Transaction) XXX_Size

func (m *Transaction) XXX_Size() int

func (*Transaction) XXX_Unmarshal

func (m *Transaction) XXX_Unmarshal(b []byte) error

type TxStatus

type TxStatus string

TxStatus is the status of a transaction

const (
	// TxStatusPending = received and maybe executed on source shard, but not on destination shard
	TxStatusPending TxStatus = "pending"
	// TxStatusSuccess = received and executed
	TxStatusSuccess TxStatus = "success"
	// TxStatusFail = received and executed with error
	TxStatusFail TxStatus = "fail"
	// TxStatusInvalid = considered invalid
	TxStatusInvalid TxStatus = "invalid"
	// TxStatusRewardReverted represents the identifier for a reverted reward transaction
	TxStatusRewardReverted TxStatus = "reward-reverted"
)

func (TxStatus) String

func (tx TxStatus) String() string

String returns the string representation of the status

type TxType

type TxType string

TxType represents a transaction type

const (
	// TxTypeNormal represents the identifier for a regular transaction
	TxTypeNormal TxType = "normal"

	// TxTypeUnsigned represents the identifier for a unsigned transaction
	TxTypeUnsigned TxType = "unsigned"

	// TxTypeReward represents the identifier for a reward transaction
	TxTypeReward TxType = "reward"

	// TxTypeInvalid represents the identifier for an invalid transaction
	TxTypeInvalid TxType = "invalid"
)

Jump to

Keyboard shortcuts

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