wallet_signer

package
v0.0.0-...-0632440 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Signer

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

func (*Signer) Accounts

func (s *Signer) Accounts() []accounts.Account

Accounts retrieves the list of signing accounts the wallet is currently aware of. For hierarchical deterministic wallets, the list will not be exhaustive, rather only contain the accounts explicitly pinned during account derivation.

func (*Signer) Close

func (s *Signer) Close() error

Close releases any resources held by an open wallet instance.

func (*Signer) Contains

func (s *Signer) Contains(account accounts.Account) bool

Contains returns whether an account is part of this particular wallet or not.

func (*Signer) Derive

func (s *Signer) Derive(path accounts.DerivationPath, pin bool) (accounts.Account, error)

Derive attempts to explicitly derive a hierarchical deterministic account at the specified derivation path. If requested, the derived account will be added to the wallet's tracked account list.

func (*Signer) Open

func (s *Signer) Open(passphrase string) error

Open initializes access to a wallet instance. It is not meant to unlock or decrypt account keys, rather simply to establish a connection to hardware wallets and/or to access derivation seeds.

The passphrase parameter may or may not be used by the implementation of a particular wallet instance. The reason there is no passwordless open method is to strive towards a uniform wallet handling, oblivious to the different backend providers.

Please note, if you open a wallet, you must close it to release any allocated resources (especially important when working with hardware wallets).

func (*Signer) SelfDerive

func (s *Signer) SelfDerive(bases []accounts.DerivationPath, chain ethereum.ChainStateReader)

SelfDerive sets a base account derivation path from which the wallet attempts to discover non zero accounts and automatically add them to list of tracked accounts.

Note, self derivation will increment the last component of the specified path opposed to descending into a child path to allow discovering accounts starting from non zero components.

Some hardware wallets switched derivation paths through their evolution, so this method supports providing multiple bases to discover old user accounts too. Only the last base will be used to derive the next empty account.

You can disable automatic account discovery by calling SelfDerive with a nil chain state reader.

func (*Signer) SignData

func (s *Signer) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error)

SignData requests the wallet to sign the hash of the given data It looks up the account specified either solely via its address contained within, or optionally with the aid of any location metadata from the embedded URL field.

If the wallet requires additional authentication to sign the request (e.g. a password to decrypt the account, or a PIN code to verify the transaction), an AuthNeededError instance will be returned, containing infos for the user about which fields or actions are needed. The user may retry by providing the needed details via SignDataWithPassphrase, or by other means (e.g. unlock the account in a keystore).

func (*Signer) SignDataWithPassphrase

func (s *Signer) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error)

SignDataWithPassphrase is identical to SignData, but also takes a password NOTE: there's a chance that an erroneous call might mistake the two strings, and supply password in the mimetype field, or vice versa. Thus, an implementation should never echo the mimetype or return the mimetype in the error-response

func (*Signer) SignText

func (s *Signer) SignText(account accounts.Account, text []byte) ([]byte, error)

SignText requests the wallet to sign the hash of a given piece of data, prefixed by the Ethereum prefix scheme It looks up the account specified either solely via its address contained within, or optionally with the aid of any location metadata from the embedded URL field.

If the wallet requires additional authentication to sign the request (e.g. a password to decrypt the account, or a PIN code to verify the transaction), an AuthNeededError instance will be returned, containing infos for the user about which fields or actions are needed. The user may retry by providing the needed details via SignTextWithPassphrase, or by other means (e.g. unlock the account in a keystore).

This method should return the signature in 'canonical' format, with v 0 or 1.

func (*Signer) SignTextWithPassphrase

func (s *Signer) SignTextWithPassphrase(account accounts.Account, passphrase string, hash []byte) ([]byte, error)

SignTextWithPassphrase is identical to Signtext, but also takes a password

func (*Signer) SignTx

func (s *Signer) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

SignTx requests the wallet to sign the given transaction.

It looks up the account specified either solely via its address contained within, or optionally with the aid of any location metadata from the embedded URL field.

If the wallet requires additional authentication to sign the request (e.g. a password to decrypt the account, or a PIN code to verify the transaction), an AuthNeededError instance will be returned, containing infos for the user about which fields or actions are needed. The user may retry by providing the needed details via SignTxWithPassphrase, or by other means (e.g. unlock the account in a keystore).

func (*Signer) SignTxWithPassphrase

func (s *Signer) SignTxWithPassphrase(account accounts.Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

SignTxWithPassphrase is identical to SignTx, but also takes a password

func (*Signer) Status

func (s *Signer) Status() (string, error)

Status returns a textual status to aid the user in the current state of the wallet. It also returns an error indicating any failure the wallet might have encountered.

func (*Signer) URL

func (s *Signer) URL() accounts.URL

URL retrieves the canonical path under which this wallet is reachable. It is used by upper layers to define a sorting order over all wallets from multiple backends.

Jump to

Keyboard shortcuts

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