ethereum

package
v1.8.16 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package ethereum provides functions to assist with Ethereum related functionality

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
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

func CreateNPasswordFile(tn *testnet.TestNet, n int, password string, dest string) error

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

func CreatePasswordFile(tn *testnet.TestNet, password string, dest string) error

CreatePasswordFile turns the process of creating a password file into a single function call

func ExposeAccounts added in v1.8.16

func ExposeAccounts(tn *testnet.TestNet, accounts []*Account)

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

func ExposeEnodes(tn *testnet.TestNet, enodes []string)

ExposeEnodes provides a simple way to expose the enode addresses of the current nodes.

func ExtractAddresses

func ExtractAddresses(accs []*Account) []string

ExtractAddresses turns an array of accounts into an array of addresses

func ExtractAddressesNoPrefix

func ExtractAddressesNoPrefix(accs []*Account) []string

ExtractAddressesNoPrefix turns an array of accounts into an array of addresses without the 0x prefix

func FetchConfigParameters added in v1.8.16

func FetchConfigParameters(tn *testnet.TestNet, outConf interface{}) error

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

func GetEnodes(tn *testnet.TestNet, accounts []*Account) []string

GetEnodes returns the enode addresses based on the nodes in the given testnet and the given accounts

func GetPeers added in v1.8.16

func GetPeers(tn *testnet.TestNet, accounts []*Account) [][]string

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

func GetPreviousEnodes(tn *testnet.TestNet) []string

GetPreviousEnodes returns the enode addresses based on the nodes in the given testnet and the given accounts

func IsEthereum added in v1.8.16

func IsEthereum(tn *testnet.TestNet) bool

IsEthereum checks if the testnet has been flagged as being an ethereum network

func IsEthereum2 added in v1.8.16

func IsEthereum2(tn *testnet.TestNet) bool

IsEthereum2 checks if the testnet has been flagged as being an eth2.0 network

func IsEthereumClassic added in v1.8.16

func IsEthereumClassic(tn *testnet.TestNet) bool

IsEthereumClassic checks if the testnet has been flagged as being an ethereum classic network

func MarkAsEthereum added in v1.8.16

func MarkAsEthereum(tn *testnet.TestNet)

MarkAsEthereum marks the given testnet as ethereum

func MarkAsEthereum2 added in v1.8.16

func MarkAsEthereum2(tn *testnet.TestNet)

MarkAsEthereum2 marks the given testnet as ethereum 2.0

func MarkAsEthereumClassic added in v1.8.16

func MarkAsEthereumClassic(tn *testnet.TestNet)

MarkAsEthereumClassic marks the given testnet as ethereum classic

func RLPHexEncode

func RLPHexEncode(v interface{}) (string, error)

RLPHexEncode converts an object into hex encoded RLP

func StoreConfigParameters added in v1.8.16

func StoreConfigParameters(tn *testnet.TestNet, confObj interface{}) error

StoreConfigParameters stores the known shared ethereum parameters from your config. Allowing another compatible client to use it if needed.

func UnlockAllAccounts added in v1.8.16

func UnlockAllAccounts(tn *testnet.TestNet, accounts []*Account, password string) error

UnlockAllAccounts calls personal_unlockAccount for each account on every node, using the given password

Types

type Account

type Account struct {
	PrivateKey *ecdsa.PrivateKey
	PublicKey  *ecdsa.PublicKey
	Address    common.Address
}

Account represents an ethereum account

func CreateAccountFromHex

func CreateAccountFromHex(hexPK string) (*Account, error)

CreateAccountFromHex creates an account from a hex encoded private key

func GenerateAccounts

func GenerateAccounts(accounts int) ([]*Account, error)

GenerateAccounts is a convience function to generate an arbitrary number of accounts using GenerateEthereumAddress

func GenerateEthereumAddress

func GenerateEthereumAddress() (*Account, error)

GenerateEthereumAddress generates a new, random Ethereum account

func GetExistingAccounts added in v1.8.16

func GetExistingAccounts(tn *testnet.TestNet) []*Account

GetExistingAccounts gets the accounts stored in the testnet, without generating any new ones

func ImportAccounts added in v1.8.16

func ImportAccounts(hexPks []string) ([]*Account, error)

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

func (acc Account) HexAddress() string

HexAddress gets the address in hex format

func (Account) HexPrivateKey

func (acc Account) HexPrivateKey() string

HexPrivateKey gets the private key in hex format

func (Account) HexPublicKey

func (acc Account) HexPublicKey() string

HexPublicKey gets the public key in hex format

func (Account) MarshalJSON

func (acc Account) MarshalJSON() ([]byte, error)

MarshalJSON handles the marshaling of Acount into JSON, so that the fields are exposed in their hex encodings

func (*Account) UnmarshalJSON

func (acc *Account) UnmarshalJSON(data []byte) error

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

Jump to

Keyboard shortcuts

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