simple

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 simple contains a simplistic implementation of the perun wallet, account, and transactor interfaces. A simple wallet can be instantiated directly from a list of secret keys. It is meant to be used for testing and demonstration purposes only. It should not be used in production.

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongAddrType = stderrors.New("wrong address type")

ErrWrongAddrType signals than an operation failed because an address was of the wrong type.

Functions

func IsErrWrongAddrType

func IsErrWrongAddrType(err error) bool

IsErrWrongAddrType returns whether the cause of the error was an ErrWrongAddrType error.

Types

type Account

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

Account represents an account held in the simple wallet.

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.

func (*Account) SignHash

func (a *Account) SignHash(hash []byte) ([]byte, error)

SignHash is used to sign an already prefixed hash with this account.

type Transactor

type Transactor struct {
	*Wallet
	types.Signer
}

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

func NewTransactor

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

NewTransactor returns a Transactor that can make TransactOpts for accounts contained in the given simple wallet.

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 wallet of the transactor factory.

type Wallet

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

Wallet is a simple wallet.Wallet implementation holding a map of all included accounts.

func NewWallet

func NewWallet(privateKeys ...*ecdsa.PrivateKey) *Wallet

NewWallet creates a new Wallet with accounts corresponding to the privateKeys.

func (*Wallet) Contains

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

Contains checks whether this wallet contains the account corresponding to the given address.

func (*Wallet) DecrementUsage

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

DecrementUsage is called whenever a channel is settled.

func (*Wallet) IncrementUsage

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

IncrementUsage is called whenever a new channel is created or restored.

func (*Wallet) LockAll

func (w *Wallet) LockAll()

LockAll is called by the framework when a Client shuts down.

func (*Wallet) NewRandomAccount

func (w *Wallet) NewRandomAccount(prng *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(address wallet.Address) (wallet.Account, error)

Unlock returns the account corresponding to the given address if the wallet contains this account.

Jump to

Keyboard shortcuts

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