Documentation ¶
Index ¶
- Constants
- Variables
- func IsParityQueriedReceiptTooEarly(e error) bool
- type Client
- type GethClient
- type Impl
- func (client *Impl) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (client *Impl) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (client *Impl) Call(result interface{}, method string, args ...interface{}) error
- func (client *Impl) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
- func (client *Impl) ChainID(ctx context.Context) (*big.Int, error)
- func (client *Impl) Dial(ctx context.Context) error
- func (client *Impl) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
- func (client *Impl) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
- func (client *Impl) HeaderByNumber(ctx context.Context, number *big.Int) (*models.Head, error)
- func (client *Impl) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (client *Impl) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (client *Impl) SendRawTx(bytes []byte) (common.Hash, error)
- func (client *Impl) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (client *Impl) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (client *Impl) SubscribeNewHead(ctx context.Context, ch chan<- *models.Head) (ethereum.Subscription, error)
- func (client *Impl) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (client *Impl) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- type KeyStore
- func (ks *KeyStore) Delete(address common.Address) error
- func (ks *KeyStore) Export(address common.Address, newPassword string) ([]byte, error)
- func (ks *KeyStore) GetAccountByAddress(address common.Address) (accounts.Account, error)
- func (ks *KeyStore) GetAccounts() []accounts.Account
- func (ks *KeyStore) HasAccountWithAddress(address common.Address) bool
- func (ks *KeyStore) HasAccounts() bool
- func (ks *KeyStore) Import(keyJSON []byte, oldPassword string) (accounts.Account, error)
- func (ks *KeyStore) NewAccount() (accounts.Account, error)
- func (ks *KeyStore) SignTx(account accounts.Account, tx *ethTypes.Transaction, chainID *big.Int) (*ethTypes.Transaction, error)
- func (ks *KeyStore) Unlock(password string) error
- type KeyStoreInterface
- type RPCClient
- type ScryptConfigReader
- type ScryptParams
- type SendError
- func (s *SendError) Error() string
- func (s *SendError) Fatal() bool
- func (s *SendError) IsInsufficientEth() bool
- func (s *SendError) IsNonceTooLowError() bool
- func (s *SendError) IsReplacementUnderpriced() bool
- func (s *SendError) IsTemporarilyUnderpriced() bool
- func (s *SendError) IsTerminallyUnderpriced() bool
- func (s *SendError) IsTransactionAlreadyInMempool() bool
- func (s *SendError) StrPtr() *string
- type Subscription
Constants ¶
const ( FastN = 2 FastP = 1 )
const EthereumMessageHashPrefix = "\x19Ethereum Signed Message:\n32"
EthereumMessageHashPrefix is a Geth-originating message prefix that seeks to prevent arbitrary message data to be representable as a valid Ethereum transaction For more information, see: https://github.com/ethereum/go-ethereum/issues/3731
Variables ¶
var DefaultScryptParams = ScryptParams{N: keystore.StandardScryptN, P: keystore.StandardScryptP}
DefaultScryptParams is for use in production. It used geth's standard level of encryption and is relatively expensive to decode. Avoid using this in tests.
var ErrKeyStoreLocked = errors.New("keystore is locked (HINT: did you forget to call keystore.Unlock?)")
var FastScryptParams = ScryptParams{N: FastN, P: FastP}
FastScryptParams is for use in tests, where you don't want to wear out your CPU with expensive key derivations, do not use it in production, or your encrypted keys will be easy to brute-force!
Functions ¶
func IsParityQueriedReceiptTooEarly ¶
Parity can return partially hydrated Log entries if you query a receipt while the transaction is still in the mempool. Go-ethereum's built-in client raises an error since this is a required field. There is no easy way to ignore the error or pass in a custom struct, so we use this hack to detect it instead.
Types ¶
type Client ¶
type Client interface { GethClient Dial(ctx context.Context) error Close() SendRawTx(bytes []byte) (common.Hash, error) Call(result interface{}, method string, args ...interface{}) error CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error HeaderByNumber(ctx context.Context, n *big.Int) (*models.Head, error) SubscribeNewHead(ctx context.Context, ch chan<- *models.Head) (ethereum.Subscription, error) }
Client is the interface used to interact with an ethereum node.
type GethClient ¶
type GethClient interface { ChainID(ctx context.Context) (*big.Int, error) SendTransaction(ctx context.Context, tx *types.Transaction) error PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) EstimateGas(ctx context.Context, call ethereum.CallMsg) (uint64, error) SuggestGasPrice(ctx context.Context) (*big.Int, error) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error) }
GethClient is an interface that represents go-ethereum's own ethclient https://github.com/ethereum/go-ethereum/blob/master/ethclient/ethclient.go
type Impl ¶
type Impl struct { GethClient RPCClient SecondaryGethClients []GethClient SecondaryRPCClients []RPCClient // contains filtered or unexported fields }
Impl implements the ethereum Client interface using a CallerSubscriber instance.
func (*Impl) BlockByNumber ¶
func (*Impl) CallContext ¶
func (*Impl) EstimateGas ¶
func (*Impl) FilterLogs ¶
func (*Impl) HeaderByNumber ¶
func (*Impl) PendingCodeAt ¶
func (*Impl) PendingNonceAt ¶
func (*Impl) SendTransaction ¶
SendTransaction also uses the secondary HTTP RPC URL if set
func (*Impl) SubscribeFilterLogs ¶
func (client *Impl) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
func (*Impl) SubscribeNewHead ¶
func (*Impl) SuggestGasPrice ¶
func (*Impl) TransactionReceipt ¶
func (client *Impl) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionReceipt wraps the GethClient's `TransactionReceipt` method so that we can ignore the error that arises when we're talking to a Parity node that has no receipt yet.
type KeyStore ¶
KeyStore manages a key storage directory on disk.
func NewInsecureKeyStore ¶
NewInsecureKeyStore creates an *INSECURE* keystore for the given directory. NOTE: Should only be used for testing!
func NewKeyStore ¶
func NewKeyStore(keyDir string, scryptParams ScryptParams) *KeyStore
NewKeyStore creates a keystore for the given directory.
func (*KeyStore) GetAccountByAddress ¶
GetAccountByAddress returns the account matching the address provided, or an error if it is missing
func (*KeyStore) GetAccounts ¶
GetAccounts returns all accounts
func (*KeyStore) HasAccountWithAddress ¶
func (*KeyStore) HasAccounts ¶
HasAccounts returns true if there are accounts located at the keystore directory.
func (*KeyStore) NewAccount ¶
NewAccount adds an account to the keystore
type KeyStoreInterface ¶
type KeyStoreInterface interface { Unlock(password string) error Accounts() []accounts.Account Wallets() []accounts.Wallet HasAccounts() bool HasAccountWithAddress(common.Address) bool NewAccount() (accounts.Account, error) Import(keyJSON []byte, oldPassword string) (accounts.Account, error) Export(address common.Address, newPassword string) ([]byte, error) Delete(address common.Address) error GetAccounts() []accounts.Account GetAccountByAddress(common.Address) (accounts.Account, error) SignTx(account accounts.Account, tx *ethTypes.Transaction, chainID *big.Int) (*ethTypes.Transaction, error) }
type RPCClient ¶
type RPCClient interface { Call(result interface{}, method string, args ...interface{}) error CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error BatchCallContext(ctx context.Context, b []rpc.BatchElem) error EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (ethereum.Subscription, error) Close() }
RPCClient is an interface that represents go-ethereum's own rpc.Client. https://github.com/ethereum/go-ethereum/blob/master/rpc/client.go
type ScryptConfigReader ¶
type ScryptConfigReader interface {
InsecureFastScrypt() bool
}
type ScryptParams ¶
type ScryptParams struct{ N, P int }
func GetScryptParams ¶
func GetScryptParams(config ScryptConfigReader) ScryptParams
type SendError ¶
type SendError struct {
// contains filtered or unexported fields
}
fatal means this transaction can never be accepted even with a different nonce or higher gas price
func NewFatalSendError ¶
func NewFatalSendErrorS ¶
func NewSendError ¶
func NewSendErrorS ¶
func (*SendError) Fatal ¶
Fatal indicates whether the error should be considered fatal or not Fatal errors mean that no matter how many times the send is retried, no node will ever accept it
func (*SendError) IsInsufficientEth ¶
func (*SendError) IsNonceTooLowError ¶
func (*SendError) IsReplacementUnderpriced ¶
IsReplacementUnderpriced indicates that a transaction already exists in the mempool with this nonce but a different gas price or payload
func (*SendError) IsTemporarilyUnderpriced ¶
func (*SendError) IsTerminallyUnderpriced ¶
IsTerminallyUnderpriced indicates that this transaction is so far underpriced the node won't even accept it in the first place
func (*SendError) IsTransactionAlreadyInMempool ¶
Geth/parity returns this error if the transaction is already in the node's mempool
type Subscription ¶
type Subscription interface { Err() <-chan error Unsubscribe() }
Subscription is an interface for mock generation. It is identical to `ethereum.Subscription`.