Documentation ¶
Overview ¶
Package ethereum provides functions to assist with Ethereum related functionality
Index ¶
- Constants
- func CreateNPasswordFile(tn *testnet.TestNet, n int, password string, dest string) error
- func CreatePasswordFile(tn *testnet.TestNet, password string, dest string) error
- func ExposeAccounts(tn *testnet.TestNet, accounts []*Account)
- func ExposeEnodes(tn *testnet.TestNet, enodes []string)
- func ExtractAddresses(accs []*Account) []string
- func ExtractAddressesNoPrefix(accs []*Account) []string
- func FetchConfigParameters(tn *testnet.TestNet, outConf interface{}) error
- func GetEnodes(tn *testnet.TestNet, accounts []*Account) []string
- func GetPeers(tn *testnet.TestNet, accounts []*Account) [][]string
- func GetPreviousEnodes(tn *testnet.TestNet) []string
- func IsEthereum(tn *testnet.TestNet) bool
- func IsEthereum2(tn *testnet.TestNet) bool
- func IsEthereumClassic(tn *testnet.TestNet) bool
- func MarkAsEthereum(tn *testnet.TestNet)
- func MarkAsEthereum2(tn *testnet.TestNet)
- func MarkAsEthereumClassic(tn *testnet.TestNet)
- func RLPHexEncode(v interface{}) (string, error)
- func StoreConfigParameters(tn *testnet.TestNet, confObj interface{}) error
- func UnlockAllAccounts(tn *testnet.TestNet, accounts []*Account, password string) error
- type Account
- func CreateAccountFromHex(hexPK string) (*Account, error)
- func GenerateAccounts(accounts int) ([]*Account, error)
- func GenerateEthereumAddress() (*Account, error)
- func GetExistingAccounts(tn *testnet.TestNet) []*Account
- func ImportAccounts(hexPks []string) ([]*Account, error)
- func NewAccount(privKey *ecdsa.PrivateKey) *Account
- type BaseConfig
Constants ¶
const ( // FuncGroup is the functionality group of most ethereum nodes FuncGroup = "eth" // ProtocolGroup is the protocol group value for ethereum ProtocolGroup = "eth" // ClassicProtocolGroup is the protocol group value for ethereum classic ClassicProtocolGroup = "etc" // Eth2ProtocolGroup is the protocol group value for ethereum 2 Eth2ProtocolGroup = "et2" )
const ( //P2PPort is the standard p2p port for all the ethereum clients P2PPort = 30303 //RPCPort is the standard json rpc over http port RPCPort = 8545 //EnodeKey is the state key for enodes EnodeKey = "enodes" )
const ( //NetworkIDKey is the key for the network id NetworkIDKey = "networkId" //ChainIDKey is the key for chain id ChainIDKey = "chainId" //HomesteadBlockKey relates to the homestead block HomesteadBlockKey = "homesteadBlock" //EIP150BlockKey maps to the eip 150 block EIP150BlockKey = "eip150Block" //EIP155BlockKey maps to the eip 155 block EIP155BlockKey = "eip155Block" //EIP158BlockKey maps to the eip 158 block EIP158BlockKey = "eip158Block" )
Variables ¶
This section is empty.
Functions ¶
func CreateNPasswordFile ¶ added in v1.8.16
CreateNPasswordFile turns the process of creating a password file into a single function call, while also allowing you to specify the number of passwords in the file
func CreatePasswordFile ¶ added in v1.8.16
CreatePasswordFile turns the process of creating a password file into a single function call
func ExposeAccounts ¶ added in v1.8.16
ExposeAccounts exposes the given accounts to the external services which require this data in order to function correctly.
func ExposeEnodes ¶ added in v1.8.16
ExposeEnodes provides a simple way to expose the enode addresses of the current nodes.
func ExtractAddresses ¶
ExtractAddresses turns an array of accounts into an array of addresses
func ExtractAddressesNoPrefix ¶
ExtractAddressesNoPrefix turns an array of accounts into an array of addresses without the 0x prefix
func FetchConfigParameters ¶ added in v1.8.16
FetchConfigParameters merges the already stored config into your config object It must be given a pointer and will only fill in a limited set of fields
func GetEnodes ¶ added in v1.8.16
GetEnodes returns the enode addresses based on the nodes in the given testnet and the given accounts
func GetPeers ¶ added in v1.8.16
GetPeers is a convience function to get the enode addresses for each node that it should be peer with being exclusive of itself
func GetPreviousEnodes ¶ added in v1.8.16
GetPreviousEnodes returns the enode addresses based on the nodes in the given testnet and the given accounts
func IsEthereum ¶ added in v1.8.16
IsEthereum checks if the testnet has been flagged as being an ethereum network
func IsEthereum2 ¶ added in v1.8.16
IsEthereum2 checks if the testnet has been flagged as being an eth2.0 network
func IsEthereumClassic ¶ added in v1.8.16
IsEthereumClassic checks if the testnet has been flagged as being an ethereum classic network
func MarkAsEthereum ¶ added in v1.8.16
MarkAsEthereum marks the given testnet as ethereum
func MarkAsEthereum2 ¶ added in v1.8.16
MarkAsEthereum2 marks the given testnet as ethereum 2.0
func MarkAsEthereumClassic ¶ added in v1.8.16
MarkAsEthereumClassic marks the given testnet as ethereum classic
func RLPHexEncode ¶
RLPHexEncode converts an object into hex encoded RLP
func StoreConfigParameters ¶ added in v1.8.16
StoreConfigParameters stores the known shared ethereum parameters from your config. Allowing another compatible client to use it if needed.
Types ¶
type Account ¶
type Account struct { PrivateKey *ecdsa.PrivateKey PublicKey *ecdsa.PublicKey Address common.Address }
Account represents an ethereum account
func CreateAccountFromHex ¶
CreateAccountFromHex creates an account from a hex encoded private key
func GenerateAccounts ¶
GenerateAccounts is a convience function to generate an arbitrary number of accounts using GenerateEthereumAddress
func GenerateEthereumAddress ¶
GenerateEthereumAddress generates a new, random Ethereum account
func GetExistingAccounts ¶ added in v1.8.16
GetExistingAccounts gets the accounts stored in the testnet, without generating any new ones
func ImportAccounts ¶ added in v1.8.16
ImportAccounts creates account objects from an array of hex private keys
func NewAccount ¶
func NewAccount(privKey *ecdsa.PrivateKey) *Account
NewAccount creates an account from a SECP256K1 ECDSA private key
func (Account) HexAddress ¶
HexAddress gets the address in hex format
func (Account) HexPrivateKey ¶
HexPrivateKey gets the private key in hex format
func (Account) HexPublicKey ¶
HexPublicKey gets the public key in hex format
func (Account) MarshalJSON ¶
MarshalJSON handles the marshaling of Acount into JSON, so that the fields are exposed in their hex encodings
func (*Account) UnmarshalJSON ¶
UnmarshalJSON handles the conversion from json to account
type BaseConfig ¶ added in v1.8.16
type BaseConfig struct { ChainID int64 `json:"chainId"` Consensus string `json:"consensus"` ExtraAccounts int64 `json:"extraAccounts"` ExtraData string `json:"extraData"` GasLimit int64 `json:"gasLimit"` HomesteadBlock int64 `json:"homesteadBlock"` MaxPeers int64 `json:"maxPeers"` NetworkID int64 `json:"networkId"` Nonce string `json:"nonce"` Timestamp int64 `json:"timestamp"` EIP150Block int64 `json:"eip150Block"` EIP155Block int64 `json:"eip155Block"` EIP160Block int64 `json:"eip160Block"` Difficulty int64 `json:"difficulty"` BlockPeriodSeconds int64 `json:"blockPeriodSeconds"` Epoch int64 `json:"epoch"` InitBalance string `json:"initBalance"` ECIP1010Length int64 `json:"ecip1010Length"` MixHash string `json:"mixHash"` }
BaseConfig contains the parameters which should be shared amongst clients