util

package
v0.0.0-...-0802566 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Log is the ethdo global logger.

Functions

func AcceptablePassphrase

func AcceptablePassphrase(passphrase string) bool

AcceptablePassphrase returns true if the passphrase is acceptable.

func AttestationHead

func AttestationHead(ctx context.Context,
	headersCache *BeaconBlockHeaderCache,
	attestation *spec.VersionedAttestation,
) (
	phase0.Root,
	error,
)

AttestationHead returns the head for which the attestation should have voted.

func AttestationHeadCorrect

func AttestationHeadCorrect(ctx context.Context,
	headersCache *BeaconBlockHeaderCache,
	attestation *spec.VersionedAttestation,
) (
	bool,
	error,
)

AttestationHeadCorrect returns true if the given attestation had the correct head.

func AttestationTarget

func AttestationTarget(ctx context.Context,
	headersCache *BeaconBlockHeaderCache,
	chainTime chaintime.Service,
	attestation *spec.VersionedAttestation,
) (
	phase0.Root,
	error,
)

AttestationTarget returns the target for which the attestation should have voted.

func AttestationTargetCorrect

func AttestationTargetCorrect(ctx context.Context,
	headersCache *BeaconBlockHeaderCache,
	chainTime chaintime.Service,
	attestation *spec.VersionedAttestation,
) (
	bool,
	error,
)

AttestationTargetCorrect returns true if the given attestation had the correct target.

func BLSID

func BLSID(id uint64) *bls.ID

BLSID turns a uint64 in to a BLS identifier.

func BestPublicKey

func BestPublicKey(account e2wtypes.Account) (e2types.PublicKey, error)

BestPublicKey returns the best public key for operations. It prefers the composite public key if present, otherwise the public key.

func ConnectToBeaconNode

func ConnectToBeaconNode(ctx context.Context, opts *ConnectOpts) (eth2client.Service, error)

ConnectToBeaconNode connects to a beacon node at the given address.

func GetBaseDir

func GetBaseDir() string

GetBaseDir fetches the base directory for wallets.

func GetOptionalPassphrase

func GetOptionalPassphrase() (string, error)

GetOptionalPassphrase fetches the passphrase if supplied by the user.

func GetPassphrase

func GetPassphrase() (string, error)

GetPassphrase fetches the passphrase supplied by the user.

func GetPassphrases

func GetPassphrases() []string

GetPassphrases fetches the passphrases supplied by the user.

func GetStorePassphrase

func GetStorePassphrase(store string) string

GetStorePassphrase fetches the store passphrase supplied by the user.

func GetWalletPassphrase

func GetWalletPassphrase() string

GetWalletPassphrase fetches the wallet passphrase supplied by the user.

func InitLogging

func InitLogging() error

InitLogging initialises logging.

func LockAccount

func LockAccount(ctx context.Context, account e2wtypes.Account) error

LockAccount attempts to lock an account.

func Network

func Network(ctx context.Context, eth2Client eth2client.Service) (string, error)

Network returns the name of the network., calculated from the deposit contract information. If not known, returns "Unknown".

func ParseAccount

func ParseAccount(ctx context.Context,
	accountStr string,
	supplementary []string,
	unlock bool,
) (
	e2wtypes.Account,
	error,
)

ParseAccount parses input to obtain an account.

func ParseEpoch

func ParseEpoch(_ context.Context, chainTime chaintime.Service, epochStr string) (phase0.Epoch, error)

ParseEpoch parses input to calculate the desired epoch.

func ParseSlot

func ParseSlot(_ context.Context, chainTime chaintime.Service, slotStr string) (phase0.Slot, error)

ParseSlot parses input to calculate the desired slot.

func ParseValidator

func ParseValidator(ctx context.Context,
	validatorsProvider eth2client.ValidatorsProvider,
	validatorStr string,
	stateID string,
) (
	*apiv1.Validator,
	error,
)

ParseValidator parses input to obtain the validator.

func ParseValidators

func ParseValidators(ctx context.Context, validatorsProvider eth2client.ValidatorsProvider, validatorsStr []string, stateID string) ([]*apiv1.Validator, error)

ParseValidators parses input to obtain the list of validators.

func SeedFromMnemonic

func SeedFromMnemonic(mnemonic string) ([]byte, error)

SeedFromMnemonic creates a seed from a mnemonic.

func SetupStore

func SetupStore() error

SetupStore sets up the account store.

func SignRoot

func SignRoot(account e2wtypes.Account, root spec.Root, domain spec.Domain) (e2types.Signature, error)

SignRoot signs the hash tree root of a data structure.

func UnlockAccount

func UnlockAccount(ctx context.Context, account e2wtypes.Account, passphrases []string) (bool, error)

UnlockAccount attempts to unlock an account. It returns true if the account was already unlocked.

func ValidatorIndex

func ValidatorIndex(ctx context.Context, client consensusclient.Service, account string, pubKey string, index string) (phase0.ValidatorIndex, error)

ValidatorIndex obtains the index of a validator.

func VerifyRoot

func VerifyRoot(account e2wtypes.Account, root spec.Root, domain spec.Domain, signature e2types.Signature) (bool, error)

VerifyRoot verifies the hash tree root of a data structure.

func WalletAndAccountFromInput

func WalletAndAccountFromInput(ctx context.Context) (e2wtypes.Wallet, e2wtypes.Account, error)

WalletAndAccountFromInput obtains the wallet and account given the information in the viper variable "account".

func WalletAndAccountFromPath

func WalletAndAccountFromPath(ctx context.Context, path string) (e2wtypes.Wallet, e2wtypes.Account, error)

WalletAndAccountFromPath obtains the wallet and account given a path specification.

func WalletAndAccountsFromPath

func WalletAndAccountsFromPath(ctx context.Context, path string) (e2wtypes.Wallet, []e2wtypes.Account, error)

WalletAndAccountsFromPath obtains the wallet and matching accounts given a path specification.

func WalletFromInput

func WalletFromInput(ctx context.Context) (e2wtypes.Wallet, error)

WalletFromInput obtains a wallet given the information in the viper variable "account", or if not present the viper variable "wallet".

func WalletFromPath

func WalletFromPath(ctx context.Context, path string) (e2wtypes.Wallet, error)

WalletFromPath obtains a wallet given a path specification.

Types

type BeaconBlockHeaderCache

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

BeaconBlockHeaderCache is a cache of beacon block headers.

func NewBeaconBlockHeaderCache

func NewBeaconBlockHeaderCache(provider eth2client.BeaconBlockHeadersProvider) *BeaconBlockHeaderCache

NewBeaconBlockHeaderCache makes a new beacon block header cache.

func (*BeaconBlockHeaderCache) Fetch

Fetch the beacon block header for the given slot.

type ConnectOpts

type ConnectOpts struct {
	Address       string
	Timeout       time.Duration
	AllowInsecure bool
	LogFallback   bool
}

type DepositInfo

type DepositInfo struct {
	Name                  string
	Account               string
	PublicKey             []byte
	WithdrawalCredentials []byte
	Signature             []byte
	DepositDataRoot       []byte
	DepositMessageRoot    []byte
	ForkVersion           []byte
	Amount                uint64
	Version               uint64
}

DepositInfo is a generic deposit structure.

func DepositInfoFromJSON

func DepositInfoFromJSON(input []byte) ([]*DepositInfo, error)

DepositInfoFromJSON obtains deposit info from various possibly formx of JSON.

type ScratchAccount

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

ScratchAccount is an account that exists temporarily.

func NewScratchAccount

func NewScratchAccount(privKey []byte, pubKey []byte) (*ScratchAccount, error)

NewScratchAccount creates a new local account.

func (*ScratchAccount) ID

func (a *ScratchAccount) ID() uuid.UUID

ID returns the account ID.

func (*ScratchAccount) IsUnlocked

func (a *ScratchAccount) IsUnlocked(_ context.Context) (bool, error)

IsUnlocked returns true if the account is unlocked.

func (*ScratchAccount) Lock

func (a *ScratchAccount) Lock(_ context.Context) error

Lock locks the account.

func (*ScratchAccount) Name

func (a *ScratchAccount) Name() string

Name returns the account name.

func (*ScratchAccount) Path

func (a *ScratchAccount) Path() string

Path returns the account path.

func (*ScratchAccount) PrivateKey

func (a *ScratchAccount) PrivateKey(_ context.Context) (e2types.PrivateKey, error)

PrivateKey returns the account private key.

func (*ScratchAccount) PublicKey

func (a *ScratchAccount) PublicKey() e2types.PublicKey

PublicKey returns the account public key.

func (*ScratchAccount) Sign

func (a *ScratchAccount) Sign(_ context.Context, data []byte) (e2types.Signature, error)

Sign signs data with the account's private key.

func (*ScratchAccount) Unlock

func (a *ScratchAccount) Unlock(_ context.Context, _ []byte) error

Unlock unlocks the account.

type ValidatorExitData

type ValidatorExitData struct {
	Exit        *spec.SignedVoluntaryExit
	ForkVersion spec.Version
}

ValidatorExitData contains data for a validator exit.

func (*ValidatorExitData) MarshalJSON

func (d *ValidatorExitData) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaller.

func (*ValidatorExitData) UnmarshalJSON

func (d *ValidatorExitData) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaller.

Jump to

Keyboard shortcuts

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