eth

package
v4.14.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	locker.Locker
	// contains filtered or unexported fields
}

Account is an Ethereum account, with one address.

func NewAccount

func NewAccount(
	accountCoin *Coin,
	dbFolder string,
	code string,
	name string,
	getSigningConfiguration func() (*signing.Configuration, error),
	keystores *keystore.Keystores,
	getNotifier func(*signing.Configuration) accounts.Notifier,
	onEvent func(accounts.Event),
	log *logrus.Entry,
	rateUpdater *rates.RateUpdater,
) *Account

NewAccount creates a new account.

func (*Account) Balance

func (account *Account) Balance() (*accounts.Balance, error)

Balance implements accounts.Interface.

func (*Account) CanVerifyAddresses

func (account *Account) CanVerifyAddresses() (bool, bool, error)

CanVerifyAddresses implements accounts.Interface.

func (*Account) Close

func (account *Account) Close()

Close implements accounts.Interface.

func (*Account) Code

func (account *Account) Code() string

Code implements accounts.Interface.

func (*Account) Coin

func (account *Account) Coin() coin.Coin

Coin implements accounts.Interface.

func (*Account) ConvertToLegacyAddress

func (account *Account) ConvertToLegacyAddress(string) (btcutil.Address, error)

ConvertToLegacyAddress implements accounts.Interface.

func (*Account) FatalError

func (account *Account) FatalError() bool

FatalError implements accounts.Interface.

func (*Account) FeeTargets

func (account *Account) FeeTargets() ([]accounts.FeeTarget, accounts.FeeTargetCode)

FeeTargets implements accounts.Interface.

func (*Account) GetUnusedReceiveAddresses

func (account *Account) GetUnusedReceiveAddresses() []accounts.Address

GetUnusedReceiveAddresses implements accounts.Interface.

func (*Account) Info

func (account *Account) Info() *accounts.Info

Info implements accounts.Interface.

func (*Account) Initialize

func (account *Account) Initialize() error

Initialize implements accounts.Interface.

func (*Account) Initialized

func (account *Account) Initialized() bool

Initialized implements accounts.Interface.

func (*Account) Keystores

func (account *Account) Keystores() *keystore.Keystores

Keystores implements accounts.Interface.

func (*Account) Name

func (account *Account) Name() string

Name implements accounts.Interface.

func (*Account) Notifier

func (account *Account) Notifier() accounts.Notifier

Notifier implements accounts.Interface.

func (*Account) Offline

func (account *Account) Offline() bool

Offline implements accounts.Interface.

func (*Account) RateUpdater

func (account *Account) RateUpdater() *rates.RateUpdater

RateUpdater implement accounts.Interface, currently just returning a dummy value

func (*Account) SendTx

func (account *Account) SendTx(
	recipientAddress string,
	amount coin.SendAmount,
	_ accounts.FeeTargetCode,
	_ map[wire.OutPoint]struct{},
	data []byte) error

SendTx implements accounts.Interface.

func (*Account) Transactions

func (account *Account) Transactions() ([]accounts.Transaction, error)

Transactions implements accounts.Interface.

func (*Account) TxProposal

func (account *Account) TxProposal(
	recipientAddress string,
	amount coin.SendAmount,
	_ accounts.FeeTargetCode,
	_ map[wire.OutPoint]struct{},
	data []byte) (coin.Amount, coin.Amount, coin.Amount, error)

TxProposal implements accounts.Interface.

func (*Account) VerifyAddress

func (account *Account) VerifyAddress(addressID string) (bool, error)

VerifyAddress implements accounts.Interface.

type Address

type Address struct {
	common.Address
}

Address holds an Ethereum address and implements coin.Address.

func (Address) EncodeForHumans

func (address Address) EncodeForHumans() string

EncodeForHumans implements coin.Address.

func (Address) ID

func (address Address) ID() string

ID implements coin.Address.

type Coin

type Coin struct {
	observable.Implementation
	// contains filtered or unexported fields
}

Coin models an Ethereum coin.

func NewCoin

func NewCoin(
	code string,
	unit string,
	feeUnit string,
	net *params.ChainConfig,
	blockExplorerTxPrefix string,
	makeTransactionsSource TransactionsSourceMaker,
	nodeURL string,
	erc20Token *erc20.Token,
	socksProxy socksproxy.SocksProxy,
) *Coin

NewCoin creates a new coin with the given parameters. makeTransactionsSource: provide `TransactionsSourceNone` or `TransactionsSourceEtherScan()`. For erc20 tokens, provide erc20Token using NewERC20Token() (otherwise keep nil).

func (*Coin) BlockExplorerTransactionURLPrefix

func (coin *Coin) BlockExplorerTransactionURLPrefix() string

BlockExplorerTransactionURLPrefix implements coin.Coin.

func (*Coin) Code

func (coin *Coin) Code() string

Code implements coin.Coin.

func (*Coin) Decimals

func (coin *Coin) Decimals(isFee bool) uint

Decimals implements coin.Coin.

func (*Coin) ERC20Token

func (coin *Coin) ERC20Token() *erc20.Token

ERC20Token returns nil for a normal Ethereum coin, or the erc20 token details for an erc20 token.

func (*Coin) FormatAmount

func (coin *Coin) FormatAmount(amount coin.Amount, isFee bool) string

FormatAmount implements coin.Coin.

func (*Coin) Initialize

func (coin *Coin) Initialize()

Initialize implements coin.Coin.

func (*Coin) Net

func (coin *Coin) Net() *params.ChainConfig

Net returns the network (mainnet, testnet, etc.).

func (*Coin) SmallestUnit

func (coin *Coin) SmallestUnit() string

SmallestUnit implements coin.Coin.

func (*Coin) String

func (coin *Coin) String() string

func (*Coin) ToUnit

func (coin *Coin) ToUnit(amount coin.Amount, isFee bool) float64

ToUnit implements coin.Coin.

func (*Coin) TransactionsSource

func (coin *Coin) TransactionsSource() TransactionsSource

TransactionsSource returns an instance of TransactionsSource.

func (*Coin) Unit

func (coin *Coin) Unit(isFee bool) string

Unit implements coin.Coin.

type TransactionsSource

type TransactionsSource interface {
	Transactions(address common.Address, endBlock *big.Int, erc20Token *erc20.Token) (
		[]accounts.Transaction, error)
}

TransactionsSource source of Ethereum transactions. An additional source for this is needed as a normal ETH full node does not expose an API endpoint to get transactions per address.

type TransactionsSourceMaker

type TransactionsSourceMaker func() TransactionsSource

TransactionsSourceMaker creates a transaction source.

var TransactionsSourceNone TransactionsSourceMaker = func() TransactionsSource { return nil }

TransactionsSourceNone is used if no transactions source should be used.

func TransactionsSourceEtherScan

func TransactionsSourceEtherScan(etherScanURL string, socksProxy socksproxy.SocksProxy) TransactionsSourceMaker

TransactionsSourceEtherScan creates a etherscan transactions source maker.

type TxProposal

type TxProposal struct {
	Coin coin.Coin
	Tx   *types.Transaction
	Fee  *big.Int
	// Value can be the same as Tx.Value(), but in case of e.g. ERC20, tx.Value() is zero, while the
	// Token value is encoded in the contract input data.
	Value *big.Int
	// Signer contains the sighash algo, which depends on the block number.
	Signer types.Signer
	// KeyPath is the location of this account's address/pubkey/privkey.
	Keypath signing.AbsoluteKeypath
}

TxProposal holds all info needed to create and sign a transacstion.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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