util

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: Apache-2.0 Imports: 34 Imported by: 1

Documentation

Overview

Package util contains utilities for Ethereal

Package util contains utilities for Ethereal

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountSigner

func AccountSigner(chainID *big.Int, wallet *accounts.Wallet, account *accounts.Account, passphrase string) (signerfn bind.SignerFn)

AccountSigner generates a signer using an account

func BlockHasMinerTransactions

func BlockHasMinerTransactions(block *types.Block, chainID *big.Int) bool

BlockHasMinerTransactions returns true if the block contains any transactions signed by the same account that mined the block.

func DNSDomainHash

func DNSDomainHash(domain string) (hash [32]byte)

DNSDomainHash hashes a domain name

func DNSWireFormat

func DNSWireFormat(domain string) []byte

DNSWireFormat turns a domain name in to wire format

func DNSWireFormatDomainHash

func DNSWireFormatDomainHash(domain string) (hash [32]byte)

DNSWireFormatDomainHash hashes a domain name in wire format

func GasPriceForBlocks

func GasPriceForBlocks(client *ethclient.Client, blocks int64, gasRequired uint64, verbose bool) (*big.Int, error)

GasPriceForBlocks attempts to calculate a suitable gas price for a transaction given the gas used and the number of blocks within which the transaction is desired to be included in. It does this by looking back over a number of blocks to calculate the gas price that would have been required. This generally assumes that miners are rational in their selection of transactions to include in blocks, specifically that they select the highest gas price transactions available to them. An obvious exception to this assumption is transactions generated by the miners themselves, for example by a mining pool to pay out their miners. Due to this, blocks that contain self-mined transactions are excluded. As with any algorithm that uses historic information to calculate future values there are no guarantees that the resultant value will provide the desired result; significant changes to gas price between transactions in prior blocks and those in the transaction pool can result in an over- or under-estimation of the required gas.

func IncrementSerial

func IncrementSerial(serial uint32) uint32

IncrementSerial increments a SOA serial number as per RFC 1912

func KeySigner

func KeySigner(chainID *big.Int, key *ecdsa.PrivateKey) (signerfn bind.SignerFn)

KeySigner generates a signer using a private key

func MustDecodeHexString

func MustDecodeHexString(input string) []byte

MustDecodeHexString runs hex.DecodeString() and panics on error.

func PrivateKeyForAccount

func PrivateKeyForAccount(chainID *big.Int, address common.Address, passphrase string) (*ecdsa.PrivateKey, error)

PrivateKeyForAccount returns the private key for an account

func StringToTokenValue

func StringToTokenValue(input string, decimals uint8) (output *big.Int, err error)

StringToTokenValue converts a string to a number of tokens

func TokenValueToString

func TokenValueToString(input *big.Int, decimals uint8, usePrefix bool) (output string)

TokenValueToString converts a token value to a suitable string representation

func WaitForTransaction

func WaitForTransaction(client *ethclient.Client, txHash common.Hash, limit time.Duration) bool

WaitForTransaction waits for the transaction to be mined, or for the limit to expire

Types

type Contract

type Contract struct {
	Name   string
	Abi    abi.ABI
	Binary []byte
}

Contract contains some basic information about a contract

func ParseCombinedJSON

func ParseCombinedJSON(input string, name string) (*Contract, error)

ParseCombinedJSON parses a combined JSON output of solc for a specific contract

type DepositInfo

type DepositInfo struct {
	Name                  string
	Account               string
	PublicKey             []byte
	WithdrawalCredentials []byte
	Signature             []byte
	DepositDataRoot       []byte
	DepositMessageRoot    []byte
	ForkVersion           []byte
	Amount                uint64
	Version               uint64
}

DepositInfo is a generic deposit structure.

func DepositInfoFromJSON

func DepositInfoFromJSON(input []byte) ([]*DepositInfo, error)

DepositInfoFromJSON obtains deposit info from any supported JSON format.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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