eth

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 33 Imported by: 1 module, 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

Voting APIs follow livepeer/go-livepeer/eth/client.go: poll voting by Nico Vergauwen (994f4c0e5a755717f47feab1a397c74307cef8ef) and proposal voting by Rick Staa (89d9ebc7fff0004aab11bbb733035327da7b2e1b).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAccount

func CreateAccount(dir string, password *string, passwordFile string) (ethcommon.Address, error)

CreateAccount saves a fresh account in the shared keystore directory.

func CreateKeystore

func CreateKeystore(keystorePath string, password *string, passwordPath string) (ethcommon.Address, error)

CreateKeystore generates an account and writes an owner-only encrypted geth keystore. The parent directory must exist; an existing path is never replaced. Password sources follow the same exact-byte rules as OpenKeystore.

func DecimalUnits

func DecimalUnits(value *big.Int, places int) string

DecimalUnits formats integer units exactly, without floating-point arithmetic.

func HexSignature

func HexSignature(sig []byte) string

func SelectKeystore

func SelectKeystore(dir, explicit string, account *ethcommon.Address) (string, ethcommon.Address, error)

SelectKeystore selects metadata without unlocking a key. An explicit file bypasses directory discovery; its address is checked again after decryption.

func ValidAddress

func ValidAddress(address string) bool

Types

type AccountInspection

type AccountInspection struct {
	BlockSnapshot
	Address      common.Address `json:"address"`
	BalanceWei   string         `json:"balance_wei"`
	LPTBalance   string         `json:"lpt_balance_base_units"`
	PendingNonce uint64         `json:"pending_nonce"`
}

type BlockSnapshot

type BlockSnapshot struct {
	BlockNumber string      `json:"block_number"`
	BlockHash   common.Hash `json:"block_hash"`
}

type ChainSnapshot

type ChainSnapshot struct {
	Block     *big.Int // Protocol L1 block, including on Arbitrum.
	Round     *big.Int // Last initialized round.
	RoundHash ethcommon.Hash
	// contains filtered or unexported fields
}

type Confirmation

type Confirmation struct {
	Hash     common.Hash   `json:"transaction_hash"`
	Block    uint64        `json:"confirmed_block"`
	Attempts []common.Hash `json:"attempt_hashes"`
}

type Contracts

type Contracts struct {
	RPC        *RPC
	Controller ethcommon.Address

	MaxFeePerGas *big.Int // Optional ceiling in wei per gas.
	// contains filtered or unexported fields
}

Contracts adapts upstream bindings to explicit transaction planning and canonical payment snapshots. Protocol addresses come from the Controller; Poll and price-feed addresses are explicit caller inputs.

func NewContracts

func NewContracts(rpc *RPC, controller ethcommon.Address) (*Contracts, error)

func OpenContracts

func OpenContracts(rpc *RPC, controller string) (*Contracts, error)

func (*Contracts) Broadcast

func (c *Contracts) Broadcast(ctx context.Context, tx SignedTransaction) error

Broadcast sends these exact signed bytes once. Always retain the local hash: any transport error can occur after the node has accepted the transaction.

func (*Contracts) Call

func (c *Contracts) Call(ctx context.Context, name string, address ethcommon.Address, method string, args ...any) ([]any, error)

func (*Contracts) CallAt

func (c *Contracts) CallAt(ctx context.Context, block any, name string, address ethcommon.Address, method string, args ...any) ([]any, error)

func (*Contracts) ChangeDelegate

func (c *Contracts) ChangeDelegate(ctx context.Context, from, to common.Address) (TransactionPlan, error)

func (*Contracts) ChangeDelegateWithOptions

func (c *Contracts) ChangeDelegateWithOptions(ctx context.Context, from, to common.Address, options FeeOptions) (TransactionPlan, error)

func (*Contracts) Fees

func (c *Contracts) Fees(ctx context.Context, initialTip *big.Int) (FeeInspection, error)

func (*Contracts) GetRewardCaller

func (c *Contracts) GetRewardCaller(ctx context.Context, target common.Address) (common.Address, error)

func (*Contracts) Inspect

func (c *Contracts) Inspect(ctx context.Context) (*Inspection, error)

func (*Contracts) InspectFees

func (c *Contracts) InspectFees(ctx context.Context, initialTip *big.Int) (FeeInspection, error)

InspectFees also reports the RPC suggestion when an explicit tip is selected.

func (*Contracts) Pack

func (c *Contracts) Pack(name, method string, args ...any) ([]byte, error)

func (*Contracts) PlanContract

func (c *Contracts) PlanContract(ctx context.Context, from common.Address, name, method string, value *big.Int, args ...any) (TransactionPlan, error)

PlanContract simulates and estimates a retained operation without signing or broadcasting. Staking operations reuse upstream pool-position preparation.

func (*Contracts) PlanContractWithOptions

func (c *Contracts) PlanContractWithOptions(ctx context.Context, from common.Address, name, method string, value *big.Int, options FeeOptions, args ...any) (TransactionPlan, error)

func (*Contracts) PlanTransaction

func (c *Contracts) PlanTransaction(ctx context.Context, from, to ethcommon.Address, data []byte, value *big.Int) (TransactionPlan, error)

PlanTransaction simulates a state change and estimates gas before any signing.

func (*Contracts) PlanTransactionWithOptions

func (c *Contracts) PlanTransactionWithOptions(ctx context.Context, from, to ethcommon.Address, data []byte, value *big.Int, options FeeOptions) (TransactionPlan, error)

func (*Contracts) Prepare

func (c *Contracts) Prepare(ctx context.Context, plan TransactionPlan, key *Key, chainID *big.Int) (SignedTransaction, error)

Prepare performs reads and signing only; callers can durably save the identity before the first possible broadcast.

func (*Contracts) PrepareAndStore

func (c *Contracts) PrepareAndStore(ctx context.Context, plan TransactionPlan, key *Key, chainID *big.Int, save func(SignedTransaction) error) (SignedTransaction, error)

PrepareAndStore holds the transaction account's nonce reservation through persistence. Save must durably store the identity without broadcasting it or calling back into this client's nonce methods. A failed save does not consume a nonce.

func (*Contracts) ProposalVote

func (c *Contracts) ProposalVote(ctx context.Context, from common.Address, proposal *big.Int, choice lpTypes.ProposalVoteChoice) (TransactionPlan, error)

func (*Contracts) ProposalVoteWithReason

func (c *Contracts) ProposalVoteWithReason(ctx context.Context, from common.Address, proposal *big.Int, choice lpTypes.ProposalVoteChoice, reason string) (TransactionPlan, error)

func (*Contracts) Resolve

func (c *Contracts) Resolve(ctx context.Context, name string) (ethcommon.Address, error)

func (*Contracts) ResolveAt

func (c *Contracts) ResolveAt(ctx context.Context, block any, name string) (ethcommon.Address, error)

func (*Contracts) RewardForTranscoder

func (c *Contracts) RewardForTranscoder(ctx context.Context, from, target common.Address) (TransactionPlan, error)

func (*Contracts) SetNonceFloor

func (c *Contracts) SetNonceFloor(address ethcommon.Address, floor uint64)

SetNonceFloor includes identities already durably saved by a caller. Local reservations cannot coordinate another process using the same signing key.

func (*Contracts) SetRewardCaller

func (c *Contracts) SetRewardCaller(ctx context.Context, from, caller common.Address) (TransactionPlan, error)

Reward-caller APIs follow Rick Staa's go-livepeer/eth/client.go LIP-118 support (a31522e08b3e7c953a3bba51e7be6d79b4bf5c8c).

func (*Contracts) Submit

func (c *Contracts) Submit(ctx context.Context, plan TransactionPlan, key *Key, chainID *big.Int) (ethcommon.Hash, error)

func (*Contracts) Vote

func (c *Contracts) Vote(ctx context.Context, from, poll common.Address, choice lpTypes.VoteChoice) (TransactionPlan, error)

Vote plans a vote on the explicitly selected Poll contract.

func (*Contracts) WaitConfirmation

func (c *Contracts) WaitConfirmation(ctx context.Context, first SignedTransaction, key *Key, options WaitOptions, beforeBroadcast func(SignedTransaction, TransactionPlan) error) (Confirmation, error)

WaitConfirmation retains the signed identity and watches every attempt. The callback runs before each replacement broadcast, allowing callers to report its hash and resolved fees even if a send has an uncertain outcome.

func (*Contracts) WaitReceipt

func (c *Contracts) WaitReceipt(ctx context.Context, hash ethcommon.Hash) (uint64, error)

WaitReceipt waits for one confirmed receipt and reports reverted transactions.

func (*Contracts) WeiPerUSD

func (c *Contracts) WeiPerUSD(ctx context.Context, feed ethcommon.Address, maxAge time.Duration) (*big.Rat, time.Time, error)

WeiPerUSD reads an operator-selected Chainlink-compatible ETH/USD feed. It returns the last instant at which that observation may price new sessions. Feed access follows Victor Elias's go-livepeer/eth/pricefeed.go (ef5d78922e08d8b815814df419d03e0561c1e974); canonical reads and freshness checks are implemented here.

type ContractsInspection

type ContractsInspection struct {
	BlockSnapshot
	Addresses map[string]common.Address `json:"addresses"`
}

type FeeInspection

type FeeInspection struct {
	BlockSnapshot
	BaseFeeWei      string  `json:"base_fee_per_gas_wei"`
	SuggestedTipWei *string `json:"suggested_priority_fee_per_gas_wei"`
	TipCapWei       string  `json:"max_priority_fee_per_gas_wei"`
	FeeCapWei       string  `json:"calculated_fee_cap_wei"`
	CeilingWei      *string `json:"fee_ceiling_wei"`
}

type FeeOptions

type FeeOptions struct {
	GasLimit    uint64
	PriorityFee *big.Int
}

FeeOptions applies to one transaction. A zero gas limit requests estimation.

type Inspection

type Inspection struct {
	BlockNumber string      `json:"block_number"`
	BlockHash   common.Hash `json:"block_hash"`
	// contains filtered or unexported fields
}

Inspection pins all state and Controller lookups to one canonical block hash. Pending nonces are deliberately read from the transaction pool.

func (*Inspection) Account

func (s *Inspection) Account(ctx context.Context, address common.Address) (AccountInspection, error)

func (*Inspection) Addresses

func (s *Inspection) Addresses(ctx context.Context) (ContractsInspection, error)

func (*Inspection) Call

func (s *Inspection) Call(ctx context.Context, name, method string, args ...any) ([]any, error)

func (*Inspection) Locks

func (s *Inspection) Locks(ctx context.Context, address common.Address, query LockQuery) (LocksInspection, error)

func (*Inspection) Orchestrator

func (s *Inspection) Orchestrator(ctx context.Context, address common.Address) (OrchestratorInspection, error)

func (*Inspection) Pool

func (s *Inspection) Pool(ctx context.Context, activeOnly bool) (PoolInspection, error)

func (*Inspection) Protocol

func (s *Inspection) Protocol(ctx context.Context) (ProtocolInspection, error)

func (*Inspection) Resolve

func (s *Inspection) Resolve(ctx context.Context, name string) (common.Address, error)

func (*Inspection) Round

func (s *Inspection) Round(ctx context.Context) (RoundInspection, error)

func (*Inspection) Snapshot

func (s *Inspection) Snapshot() BlockSnapshot

func (*Inspection) Stake

func (s *Inspection) Stake(ctx context.Context, address common.Address) (StakeInspection, error)

func (*Inspection) TicketBroker

func (s *Inspection) TicketBroker(ctx context.Context, address common.Address) (TicketBrokerInspection, error)

type Key

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

Key is a local Ethereum signer. The key material never crosses the JSON-RPC boundary and is not included in command output or errors.

func OpenAccount

func OpenAccount(dir, path string, password *string, passwordFile string, account *ethcommon.Address) (*Key, error)

OpenAccount discovers an account and verifies its metadata against the decrypted key.

func OpenKeystore

func OpenKeystore(keystorePath string, password *string, passwordPath string) (key *Key, err error)

OpenKeystore unlocks an encrypted geth account using password, or passwordPath if password is nil. Any supplied password file must be owner-only.

func OpenKeystoreFile

func OpenKeystoreFile(keystorePath, passwordPath string) (*Key, error)

OpenKeystoreFile unlocks one encrypted geth account file. Password files use exact bytes, including whitespace; neither input is included in diagnostics.

func (*Key) Address

func (k *Key) Address() ethcommon.Address

func (*Key) SignHash

func (k *Key) SignHash(hash []byte) ([]byte, error)

Hash signing follows Yondon Fu's go-livepeer/eth/accountmanager.go signHash (97a014cb692a736a853f7ebb396e9cbada5408a6).

func (*Key) SignMessage

func (k *Key) SignMessage(message []byte) ([]byte, error)

Ethereum message signing and the 27/28 convention follow Yondon Fu's go-livepeer/eth/accountmanager.go (3b52399fc7b9177460864207a68eb9f3d2f4ee57).

type LockInspection

type LockInspection struct {
	ID            string `json:"id"`
	Amount        string `json:"amount_base_units"`
	WithdrawRound string `json:"withdraw_round"`
	Withdrawable  bool   `json:"withdrawable"`
}

type LockQuery

type LockQuery struct {
	FromID               *big.Int
	Limit                uint64
	Withdrawable, Locked bool
}

type LocksInspection

type LocksInspection struct {
	BlockSnapshot
	Address    common.Address   `json:"address"`
	Locks      []LockInspection `json:"locks"`
	NextFromID *string          `json:"next_from_id"`
}

type OrchestratorInspection

type OrchestratorInspection struct {
	BlockSnapshot
	Address         common.Address `json:"address"`
	Registered      bool           `json:"registered"`
	Active          bool           `json:"active"`
	DelegatedStake  string         `json:"delegated_stake_base_units"`
	RewardCut       string         `json:"reward_cut_percent"`
	FeeCut          string         `json:"fee_cut_percent"`
	ServiceURI      string         `json:"service_uri"`
	LastRewardRound string         `json:"last_reward_round"`
	RewardCaller    common.Address `json:"reward_caller"`
}

type PaymentChain

type PaymentChain struct{ Contracts *Contracts }

PaymentChain adapts the retained Livepeer contracts to pm's narrow chain interface. Ethereum contract reads and redemption stay in eth.

func (PaymentChain) IsActive

func (c PaymentChain) IsActive(ctx context.Context, recipient ethcommon.Address) (bool, error)

func (PaymentChain) IsActiveAt

func (c PaymentChain) IsActiveAt(ctx context.Context, recipient ethcommon.Address, snapshot ChainSnapshot) (bool, error)

func (PaymentChain) PrepareRedemption

func (c PaymentChain) PrepareRedemption(ctx context.Context, redeemer *Key, chainID *big.Int, t RedeemTicket) (SignedTransaction, error)

func (PaymentChain) PrepareRedemptionAndStore

func (c PaymentChain) PrepareRedemptionAndStore(ctx context.Context, redeemer *Key, chainID *big.Int, t RedeemTicket, save func(SignedTransaction) error) (SignedTransaction, error)

PrepareRedemptionAndStore reserves the nonce only after the caller saves the signed redemption identity, before any possible broadcast.

func (PaymentChain) Receipt

func (c PaymentChain) Receipt(ctx context.Context, hash ethcommon.Hash) (confirmed, reverted bool, err error)

Receipt reports a submitted redemption without retrying or resubmitting it.

func (PaymentChain) Redeem

func (c PaymentChain) Redeem(ctx context.Context, redeemer *Key, chainID *big.Int, t RedeemTicket) (ethcommon.Hash, error)

func (PaymentChain) SenderInfo

func (c PaymentChain) SenderInfo(ctx context.Context, sender, recipient ethcommon.Address) (SenderInfo, error)

func (PaymentChain) Snapshot

func (c PaymentChain) Snapshot(ctx context.Context) (ChainSnapshot, error)

type PoolInspection

type PoolInspection struct {
	BlockSnapshot
	Orchestrators []OrchestratorInspection `json:"orchestrators"`
}

type ProtocolInspection

type ProtocolInspection struct {
	BlockSnapshot
	Paused            bool   `json:"paused"`
	PoolLimit         string `json:"pool_limit"`
	RoundLength       string `json:"round_length"`
	RoundLockAmount   string `json:"round_lock_amount"`
	UnbondingPeriod   string `json:"unbonding_period"`
	Inflation         string `json:"inflation"`
	InflationChange   string `json:"inflation_change"`
	TargetBondingRate string `json:"target_bonding_rate"`
	Supply            string `json:"supply_base_units"`
	TotalBonded       string `json:"total_bonded_base_units"`
	ParticipationRate string `json:"participation_rate_percent"`
}

type RPC

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

RPC applies bounded HTTP transport and error redaction to geth's client.

func NewRPC

func NewRPC(endpoint *url.URL, transport http.RoundTripper) (*RPC, error)

NewRPC opens a bounded RPC client using the supplied transport. A nil transport uses the system HTTP transport, including normal TLS verification.

func OpenRPC

func OpenRPC(endpoint string) (*RPC, error)

func (*RPC) BalanceAt

func (r *RPC) BalanceAt(ctx context.Context, address ethcommon.Address, number *big.Int) (*big.Int, error)

func (*RPC) BlockNumber

func (r *RPC) BlockNumber(ctx context.Context) (uint64, error)

func (*RPC) ChainID

func (r *RPC) ChainID(ctx context.Context) (*big.Int, error)

ChainID uses ethclient's standard call and quantity decoding.

func (*RPC) CheckChainID

func (r *RPC) CheckChainID(ctx context.Context, expected *big.Int) error

CheckChainID validates the RPC chain ID, optionally pinning it to expected.

func (*RPC) Close

func (r *RPC) Close()

func (*RPC) CodeAt

func (r *RPC) CodeAt(ctx context.Context, address ethcommon.Address, number *big.Int) ([]byte, error)

func (*RPC) PendingNonceAt

func (r *RPC) PendingNonceAt(ctx context.Context, address ethcommon.Address) (uint64, error)

func (*RPC) TransactionReceipt

func (r *RPC) TransactionReceipt(ctx context.Context, hash ethcommon.Hash) (*types.Receipt, error)

type RedeemTicket

type RedeemTicket struct {
	Recipient         ethcommon.Address
	Sender            ethcommon.Address
	FaceValue         *big.Int
	WinProb           *big.Int
	SenderNonce       uint32
	RecipientRandHash ethcommon.Hash
	AuxData           []byte
	Signature         []byte
	RecipientRand     *big.Int
}

The redemption tuple follows Yondon Fu's go-livepeer/eth/client_ticketbroker.go RedeemWinningTicket (ffcefd6341d14696e2718c1a42875428cd2cc953).

type RoundInspection

type RoundInspection struct {
	BlockSnapshot
	CurrentRound         string `json:"current_round"`
	LastInitializedRound string `json:"last_initialized_round"`
	Initialized          bool   `json:"initialized"`
	Locked               bool   `json:"locked"`
}

type SenderInfo

type SenderInfo struct {
	Snapshot                        ChainSnapshot
	Deposit, Reserve, WithdrawRound *big.Int
}

SenderInfo is a coherent view of a sender's collateral and the amount of reserve this particular recipient can claim in the initialized round. A zero recipient requests total remaining reserve, for sender readiness. Sender/reserve semantics follow go-livepeer/eth/client_ticketbroker.go, originally by Yondon Fu and Nico Vergauwen, with L1-round handling by Rafał Leszko (4b6ede31f040a084ff9e55bd798a0d6fffee1e1b).

type SignedTransaction

type SignedTransaction struct {
	Hash  ethcommon.Hash
	Raw   []byte
	Nonce uint64
	From  ethcommon.Address
}

type StakeInspection

type StakeInspection struct {
	BlockSnapshot
	Address         common.Address `json:"address"`
	Status          string         `json:"status"`
	BondedStake     string         `json:"bonded_stake_base_units"`
	PendingStake    string         `json:"pending_stake_base_units"`
	CollectedFees   string         `json:"collected_fees_wei"`
	PendingFees     string         `json:"pending_fees_wei"`
	Delegate        common.Address `json:"delegate"`
	DelegatedAmount string         `json:"delegated_amount_base_units"`
	StartRound      string         `json:"start_round"`
	LastClaimRound  string         `json:"last_claim_round"`
	NextLockID      string         `json:"next_lock_id"`
}

type TicketBrokerInspection

type TicketBrokerInspection struct {
	BlockSnapshot
	Address                common.Address `json:"address"`
	Deposit                string         `json:"deposit_wei"`
	Reserve                string         `json:"reserve_wei"`
	WithdrawRound          string         `json:"withdraw_round"`
	UnlockPeriod           string         `json:"unlock_period"`
	FundingStatus          string         `json:"funding_status"`
	ProjectedWithdrawRound *string        `json:"projected_withdraw_round"`
}

type TransactionPlan

type TransactionPlan struct {
	To        ethcommon.Address `json:"to"`
	From      ethcommon.Address `json:"from"`
	Data      string            `json:"data"`
	ValueWei  string            `json:"value_wei"`
	GasLimit  uint64            `json:"gas_limit"`
	FeeCapWei string            `json:"max_fee_per_gas_wei"`
	TipCapWei string            `json:"max_priority_fee_per_gas_wei"`
}

type WaitOptions

type WaitOptions struct {
	Timeout         time.Duration
	MaxReplacements uint64
}

WaitOptions controls CLI inclusion waiting. Payment finality and durable recovery do not use this API. Timeout applies to every attempt, including last.

Directories

Path Synopsis
Selected protocol types from go-livepeer bd645a09266833fb859053445d9ac85846330756.
Selected protocol types from go-livepeer bd645a09266833fb859053445d9ac85846330756.

Jump to

Keyboard shortcuts

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