ethereum

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: Apache-2.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

alias.go holds some type aliases from go-ethereum

ecdsa.go contains some utility functions for reading and saving ECDSA keys

Index

Constants

View Source
const DefaultKeyDumpFilename = "ecdsa.json"
View Source
const DefaultTimeout = 5 * time.Second

Variables

View Source
var (
	IsHexAddress = common.IsHexAddress
	FromHex      = common.FromHex
	Wei          = params.Wei
	GWei         = params.GWei
	Ether        = params.Ether
)

Alias some helper funcs

Functions

func DecodeTransaction

func DecodeTransaction(data []byte) (*types.Transaction, error)

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

GenerateKey returns an secp256k1 key for use with Ethereum

func ReadUnsafeKeyDump

func ReadUnsafeKeyDump(location string) (*ecdsa.PrivateKey, error)

ReadUnsafeKeyDump reads a privateKeyDump from a given JSON file, and unmarshals the contents into an ecdsa.PrivateKey

func SaveUnsafeKeyDump

func SaveUnsafeKeyDump(key *ecdsa.PrivateKey, location string) error

SaveUnsafeKeyDump saves a given ecdsa.PrivateKey into a JSON file at the given location

func VerifyLock

func VerifyLock(tx *types.Transaction, contractabi string) (bool, error)

Types

type Address

type Address = common.Address

type BalanceReply

type BalanceReply struct {
	Address Address  `json:"address"`
	Amount  *big.Int `json:"amount"`
}

type BalanceRequest

type BalanceRequest struct {
	Address Address `json:"address"`
}

type CallOpts

type CallOpts = bind.CallOpts

type ChainDriver

type ChainDriver interface {
}

type ChainDriverOption

type ChainDriverOption struct {
	ContractABI     string
	ContractAddress common.Address
}

type Client

type Client = ethclient.Client

type Contract

type Contract = contract.LockRedeem

Contract is our main access point to the Ethereum smart contract we use to lock and redeem ethereum tokens

type ETHChainDriver

type ETHChainDriver struct {
	ContractAddress Address
	ContractABI     string
	// contains filtered or unexported fields
}

ETHChainDriver provides the core fields required to interact with the Ethereum network. As of this moment (2019-08-21) it should only be used by validator nodes.

func NewChainDriver

func NewChainDriver(cfg *config.EthereumChainDriverConfig, logger *log.Logger, option *ChainDriverOption) (*ETHChainDriver, error)

func (ETHChainDriver) Balance

func (acc ETHChainDriver) Balance(addr Address) (*big.Int, error)

Balance returns the current balance of the

func (*ETHChainDriver) BroadcastTx

func (acc *ETHChainDriver) BroadcastTx(tx *types.Transaction) (TransactionHash, error)

func (*ETHChainDriver) CallOpts

func (acc *ETHChainDriver) CallOpts(addr Address) *CallOpts

func (*ETHChainDriver) ChainId

func (acc *ETHChainDriver) ChainId() (*big.Int, error)

func (*ETHChainDriver) CheckFinality

func (acc *ETHChainDriver) CheckFinality(txHash TransactionHash) (*types.Receipt, error)

func (*ETHChainDriver) DecodeTransaction

func (acc *ETHChainDriver) DecodeTransaction(rawBytes []byte) (*types.Transaction, error)

func (*ETHChainDriver) GetClient

func (acc *ETHChainDriver) GetClient() *Client

func (*ETHChainDriver) GetContract

func (acc *ETHChainDriver) GetContract() *Contract

func (*ETHChainDriver) GetTransactionMessage

func (acc *ETHChainDriver) GetTransactionMessage(tx *types.Transaction) (*types.Message, error)

func (*ETHChainDriver) HasValidatorSigned

func (acc *ETHChainDriver) HasValidatorSigned(validatorAddress common.Address, recipient common.Address) (bool, error)

func (ETHChainDriver) Nonce

func (acc ETHChainDriver) Nonce(addr Address) (uint64, error)

Nonce returns the nonce to use for our next transaction

func (*ETHChainDriver) ParseRedeem

func (acc *ETHChainDriver) ParseRedeem(data []byte) (req *RedeemRequest, err error)

func (*ETHChainDriver) PrepareUnsignedETHLock

func (acc *ETHChainDriver) PrepareUnsignedETHLock(addr common.Address, lockAmount *big.Int) ([]byte, error)

func (*ETHChainDriver) SignRedeem

func (acc *ETHChainDriver) SignRedeem(fromaddr common.Address, redeemAmount *big.Int, recipient common.Address) (*Transaction, error)

func (ETHChainDriver) VerifyContract

func (acc ETHChainDriver) VerifyContract(vs []Address) (bool, error)

VerifyContract returns true if we can verify that the current contract matches the

func (*ETHChainDriver) VerifyRedeem

func (acc *ETHChainDriver) VerifyRedeem(validatorAddress common.Address, recipient common.Address) (bool, error)

type Error

type Error string
const (
	// TODO: Remove this
	ErrNotImplemented Error = "NOT_IMPLEMENTED"
	ErrNilConfig      Error = "was given nil ethereum configuration"
)

func (Error) Error

func (e Error) Error() string

type Genesis

type Genesis = core.Genesis

type LRContract

type LRContract interface {
	Lock(*big.Int) (*Transaction, error)
	Redeem(*big.Int) (*Transaction, error)
	ProposeAddValidator(Address) (*Transaction, error)
	ProposeRemoveValidator(Address) (*Transaction, error)
	IsValidator(Address) (bool, error)
	NumValidators() (uint, *Transaction, error)
	Epoch() (uint, *Transaction, error)
	DoNewEpoch() (uint, *Transaction, error)
}

TODO: embed and implement SContract is the stub implementation thereof the

type LockReply

type LockReply struct {
	Amount *big.Int `json:"amount"`
	Ok     bool     `json:"ok"`
}

type LockRequest

type LockRequest struct {
	Amount *big.Int
}

func ParseLock

func ParseLock(data []byte) (req *LockRequest, err error)

type OfflineLockRawTX

type OfflineLockRawTX struct {
	UnsignedRawTx []byte `json:"unsigned_raw_tx"`
}

type OfflineLockRequest

type OfflineLockRequest struct {
	PublicKey *ecdsa.PublicKey `json:"public_key"`
	Amount    *big.Int         `json:"amount"`
}

type OnlineLockRequest

type OnlineLockRequest struct {
	// RawTransaction of a Lock call from the user to the smart contract
	// This should be signed and RLP encoded with the ethereum address of the user
	//OLTAddress common.Address  `json:"oltAddress"`
	RawTx []byte `json:"rawTx"`
}

type RedeemRequest

type RedeemRequest struct {
	Amount *big.Int
}

func ParseRedeem

func ParseRedeem(data []byte) (req *RedeemRequest, err error)

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(access *ETHChainDriver) *Service

Returns a new Service, should be passed as an RPC handler

type SignReply

type SignReply struct {
	// contains filtered or unexported fields
}

type SignRequest

type SignRequest struct {
	// contains filtered or unexported fields
}

type TrackerName

type TrackerName = common.Hash

type TransactOpts

type TransactOpts = bind.TransactOpts

type Transaction

type Transaction = types.Transaction

type TransactionHash

type TransactionHash = common.Hash

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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