hd

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package hd contains perun wallet and accounts implementation for accessing accounts stored in an ethereum hierarchial deterministic (HD) wallet.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRootDerivationPath = accounts.DefaultRootDerivationPath

DefaultRootDerivationPath represent the default root derivation path for ethereum accounts as per BIP32.

Functions

This section is empty.

Types

type Account

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

Account represents an account held in the HD wallet.

func NewAccountFromEth

func NewAccountFromEth(wallet accounts.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 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 {
	Wallet accounts.Wallet
	Signer types.Signer
}

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

func NewTransactor

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

NewTransactor returns a backend that can make TransactOpts for accounts contained in the given ethereum 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 used for initializing transactor backend.

type Wallet

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

Wallet is a wallet.Wallet implementation for using HD wallets. It supports any implementation of the HD wallet interface (accounts.Wallet) defined in go-ethereum project.

func NewWallet

func NewWallet(hdwallet accounts.Wallet, derivationPath string, numUsedAccs uint) (*Wallet, error)

NewWallet returns a new perun wallet that uses the given HD wallet.

Use the DefaultRootDerivationPath for accessing ethereum on-chain accounts. numUsedAccs should be the number of used accounts in the wallet.

All of these accounts will be retreived from the wallet, unlocked and made accesible for making signatures.

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(a wallet.Address)

DecrementUsage implements wallet.Wallet. It is a noop.

func (*Wallet) IncrementUsage

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

IncrementUsage implements wallet.Wallet. It is a noop.

func (*Wallet) LockAll

func (w *Wallet) LockAll()

LockAll implements wallet.LockAll. It is noop.

func (*Wallet) NewAccount

func (w *Wallet) NewAccount() (*Account, error)

NewAccount creates a new account which is unlocked and ready to use. It will be derived at the index numDerivedAccs (as the index starts from 0) and numDerivedAccs will be incremented.

func (*Wallet) Unlock

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

Unlock checks if the wallet contains the account corresponding to the given address. There is no concept of unlocking in software only hd wallet.

func (*Wallet) Wallet added in v0.5.2

func (w *Wallet) Wallet() accounts.Wallet

Wallet returns the underlying ethereum wallet.

Jump to

Keyboard shortcuts

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