keystore

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package keystore contains perun wallet and accounts implementation for accessing accounts stored in ethereum keystore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

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

Account represents an ethereum account.

func NewAccountFromEth

func NewAccountFromEth(wallet *Wallet, account *accounts.Account) *Account

NewAccountFromEth creates a new perun account from a given ethereum account.

func (*Account) Address

func (a *Account) Address() wallet.Address

Address returns the ethereum address of this account.

func (*Account) SignData

func (a *Account) SignData(data []byte) ([]byte, error)

SignData is used to sign data with this account.

type Transactor

type Transactor struct {
	Ks     *keystore.KeyStore
	Signer types.Signer
}

Transactor can be used to make TransactOpts for accounts stored in a keystore.

func NewTransactor

func NewTransactor(w Wallet, s types.Signer) *Transactor

NewTransactor returns a backend that can make TransactOpts for accounts contained in the given keystore.

func (*Transactor) NewTransactor

func (t *Transactor) NewTransactor(account accounts.Account) (*bind.TransactOpts, error)

NewTransactor returns a TransactOpts for the given account. It errors if the account is not contained in the keystore used for initializing transactOpts backend.

type Wallet

type Wallet struct {
	Ks *keystore.KeyStore
	// contains filtered or unexported fields
}

Wallet represents an ethereum wallet. It uses the go-ethereum keystore to store keys. Accessing the wallet is threadsafe, however you should not create two wallets from the same key directory.

func NewWallet

func NewWallet(ks *keystore.KeyStore, pw string) (*Wallet, error)

NewWallet creates a new Wallet from a keystore and password.

func (*Wallet) Contains

func (w *Wallet) Contains(a common.Address) bool

Contains checks whether this wallet holds this account.

func (*Wallet) DecrementUsage

func (w *Wallet) DecrementUsage(a wallet.Address)

DecrementUsage currently does nothing. In the future, it will track the usage of keys and release unused keys.

func (*Wallet) IncrementUsage

func (w *Wallet) IncrementUsage(a wallet.Address)

IncrementUsage currently does nothing. In the future, it will track the usage of keys.

func (*Wallet) LockAll

func (w *Wallet) LockAll()

LockAll locks all the wallet's keys and releases all its resources. It is no longer usable after this call.

func (*Wallet) NewAccount

func (w *Wallet) NewAccount() *Account

NewAccount creates a new random account which is already unlocked.

func (*Wallet) NewRandomAccount

func (w *Wallet) NewRandomAccount(rnd *rand.Rand) wallet.Account

NewRandomAccount creates a new pseudorandom account using the provided randomness. The returned account is already unlocked.

func (*Wallet) Unlock

func (w *Wallet) Unlock(addr wallet.Address) (wallet.Account, error)

Unlock retrieves the account with the given address and unlocks it. If there is no matching account or unlocking fails, returns an error.

Jump to

Keyboard shortcuts

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