transactions

package
v0.110.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MPL-2.0 Imports: 17 Imported by: 14

Documentation

Index

Constants

This section is empty.

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 PendingNonceProvider

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

PendingNonceProvider provides information about nonces.

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 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) 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