transactions

package
v0.162.14 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: MPL-2.0 Imports: 25 Imported by: 14

Documentation

Index

Constants

View Source
const (
	// PendingTransactionUpdate is emitted when a pending transaction is updated (added or deleted)
	EventPendingTransactionUpdate walletevent.EventType = "pending-transaction-update"
)

Variables

View Source
var (
	// ErrInvalidSendTxArgs is returned when the structure of SendTxArgs is ambigious.
	ErrInvalidSendTxArgs = errors.New("transaction arguments are invalid")
	// ErrUnexpectedArgs is returned when args are of unexpected length.
	ErrUnexpectedArgs = errors.New("unexpected args")
	//ErrInvalidTxSender is returned when selected account is different than From field.
	ErrInvalidTxSender = errors.New("transaction can only be send by its creator")
	//ErrAccountDoesntExist is sent when provided sub-account is not stored in database.
	ErrAccountDoesntExist = errors.New("account doesn't exist")
)
View Source
var ErrInvalidSignatureSize = errors.New("signature size must be 65")

ErrInvalidSignatureSize is returned if a signature is not 65 bytes to avoid panic from go-ethereum

Functions

This section is empty.

Types

type AddrLocker

type AddrLocker struct {
	// contains filtered or unexported fields
}

AddrLocker provides locks for addresses

func (*AddrLocker) LockAddr

func (l *AddrLocker) LockAddr(address types.Address)

LockAddr locks an account's mutex. This is used to prevent another tx getting the same nonce until the lock is released. The mutex prevents the (an identical nonce) from being read again during the time that the first transaction is being signed.

func (*AddrLocker) UnlockAddr

func (l *AddrLocker) UnlockAddr(address types.Address)

UnlockAddr unlocks the mutex of the given account.

type ErrBadNonce added in v0.35.0

type ErrBadNonce struct {
	// contains filtered or unexported fields
}

func (*ErrBadNonce) Error added in v0.35.0

func (e *ErrBadNonce) Error() string

type GasCalculator

type GasCalculator interface {
	ethereum.GasEstimator
	ethereum.GasPricer
}

GasCalculator provides methods for estimating and pricing gas.

type Nonce added in v0.125.0

type Nonce struct {
	// contains filtered or unexported fields
}

func NewNonce added in v0.125.0

func NewNonce() *Nonce

func (*Nonce) GetCurrent added in v0.125.0

func (n *Nonce) GetCurrent(rpcWrapper *rpcWrapper, from types.Address) (uint64, error)

func (*Nonce) Next added in v0.125.0

func (n *Nonce) Next(rpcWrapper *rpcWrapper, from types.Address) (uint64, func(inc bool, nonce uint64), error)

type PendingNonceProvider

type PendingNonceProvider interface {
	PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
}

PendingNonceProvider provides information about nonces.

type PendingTransaction added in v0.161.6

type PendingTransaction struct {
	Hash               common.Hash    `json:"hash"`
	Timestamp          uint64         `json:"timestamp"`
	Value              bigint.BigInt  `json:"value"`
	From               common.Address `json:"from"`
	To                 common.Address `json:"to"`
	Data               string         `json:"data"`
	Symbol             string         `json:"symbol"`
	GasPrice           bigint.BigInt  `json:"gasPrice"`
	GasLimit           bigint.BigInt  `json:"gasLimit"`
	Type               PendingTrxType `json:"type"`
	AdditionalData     string         `json:"additionalData"`
	ChainID            uint64         `json:"network_id"`
	MultiTransactionID int64          `json:"multi_transaction_id"`
}

type PendingTrxType added in v0.161.6

type PendingTrxType string
const (
	RegisterENS               PendingTrxType = "RegisterENS"
	ReleaseENS                PendingTrxType = "ReleaseENS"
	SetPubKey                 PendingTrxType = "SetPubKey"
	BuyStickerPack            PendingTrxType = "BuyStickerPack"
	WalletTransfer            PendingTrxType = "WalletTransfer"
	DeployCommunityToken      PendingTrxType = "DeployCommunityToken"
	AirdropCommunityToken     PendingTrxType = "AirdropCommunityToken"
	RemoteDestructCollectible PendingTrxType = "RemoteDestructCollectible"
	BurnCommunityToken        PendingTrxType = "BurnCommunityToken"
)

type SendTxArgs

type SendTxArgs struct {
	From                 types.Address   `json:"from"`
	To                   *types.Address  `json:"to"`
	Gas                  *hexutil.Uint64 `json:"gas"`
	GasPrice             *hexutil.Big    `json:"gasPrice"`
	Value                *hexutil.Big    `json:"value"`
	Nonce                *hexutil.Uint64 `json:"nonce"`
	MaxFeePerGas         *hexutil.Big    `json:"maxFeePerGas"`
	MaxPriorityFeePerGas *hexutil.Big    `json:"maxPriorityFeePerGas"`
	// We keep both "input" and "data" for backward compatibility.
	// "input" is a preferred field.
	// see `vendor/github.com/ethereum/go-ethereum/internal/ethapi/api.go:1107`
	Input types.HexBytes `json:"input"`
	Data  types.HexBytes `json:"data"`
}

SendTxArgs represents the arguments to submit a new transaction into the transaction pool. This struct is based on go-ethereum's type in internal/ethapi/api.go, but we have freedom over the exact layout of this struct.

func (SendTxArgs) GetInput

func (args SendTxArgs) GetInput() types.HexBytes

GetInput returns either Input or Data field's value dependent on what is filled.

func (SendTxArgs) IsDynamicFeeTx added in v0.82.0

func (args SendTxArgs) IsDynamicFeeTx() bool

IsDynamicFeeTx checks whether dynamic fee parameters are set for the tx

func (SendTxArgs) ToTransactOpts added in v0.93.2

func (args SendTxArgs) ToTransactOpts(signerFn bind.SignerFn) *bind.TransactOpts

func (SendTxArgs) Valid

func (args SendTxArgs) Valid() bool

Valid checks whether this structure is filled in correctly.

type TransactionManager added in v0.161.6

type TransactionManager struct {
	// contains filtered or unexported fields
}

func NewTransactionManager added in v0.161.6

func NewTransactionManager(db *sql.DB, pendingTxEvent rpcfilters.ChainEvent, eventFeed *event.Feed) *TransactionManager

func (*TransactionManager) AddPending added in v0.161.6

func (tm *TransactionManager) AddPending(transaction *PendingTransaction) error

func (*TransactionManager) GetAllPending added in v0.161.6

func (tm *TransactionManager) GetAllPending(chainIDs []uint64) ([]*PendingTransaction, error)

func (*TransactionManager) GetPendingByAddress added in v0.161.6

func (tm *TransactionManager) GetPendingByAddress(chainIDs []uint64, address common.Address) ([]*PendingTransaction, error)

func (*TransactionManager) GetPendingEntry added in v0.161.6

func (tm *TransactionManager) GetPendingEntry(chainID uint64, hash common.Hash) (*PendingTransaction, error)

GetPendingEntry returns sql.ErrNoRows if no pending transaction is found for the given identity TODO: consider using address also in case we expect to have also for the receiver

func (*TransactionManager) Start added in v0.161.6

func (tm *TransactionManager) Start() error

func (*TransactionManager) Stop added in v0.161.6

func (tm *TransactionManager) Stop()

func (*TransactionManager) Watch added in v0.161.6

func (tm *TransactionManager) Watch(ctx context.Context, transactionHash common.Hash, client *chain.ClientWithFallback) error

type Transactor

type Transactor struct {
	// contains filtered or unexported fields
}

Transactor validates, signs transactions. It uses upstream to propagate transactions to the Ethereum network.

func NewTransactor

func NewTransactor() *Transactor

NewTransactor returns a new Manager.

func (*Transactor) HashTransaction added in v0.35.0

func (t *Transactor) HashTransaction(args SendTxArgs) (validatedArgs SendTxArgs, hash types.Hash, err error)

func (*Transactor) NetworkID added in v0.161.6

func (t *Transactor) NetworkID() uint64

func (*Transactor) NextNonce added in v0.125.0

func (t *Transactor) NextNonce(rpcClient *rpc.Client, chainID uint64, from types.Address) (uint64, func(inc bool, n uint64), error)

func (*Transactor) SendTransaction

func (t *Transactor) SendTransaction(sendArgs SendTxArgs, verifiedAccount *account.SelectedExtKey) (hash types.Hash, err error)

SendTransaction is an implementation of eth_sendTransaction. It queues the tx to the sign queue.

func (*Transactor) SendTransactionWithChainID added in v0.101.1

func (t *Transactor) SendTransactionWithChainID(chainID uint64, sendArgs SendTxArgs, verifiedAccount *account.SelectedExtKey) (hash types.Hash, err error)

func (*Transactor) SendTransactionWithSignature added in v0.35.0

func (t *Transactor) SendTransactionWithSignature(args SendTxArgs, sig []byte) (hash types.Hash, err error)

SendTransactionWithSignature receive a transaction and a signature, serialize them together and propage it to the network. It's different from eth_sendRawTransaction because it receives a signature and not a serialized transaction with signature. Since the transactions is already signed, we assume it was validated and used the right nonce.

func (*Transactor) SetNetworkID

func (t *Transactor) SetNetworkID(networkID uint64)

SetNetworkID selects a correct network.

func (*Transactor) SetRPC

func (t *Transactor) SetRPC(rpcClient *rpc.Client, timeout time.Duration)

SetRPC sets RPC params, a client and a timeout

Directories

Path Synopsis
Package fake is a generated GoMock package.
Package fake is a generated GoMock package.

Jump to

Keyboard shortcuts

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