Documentation ¶
Overview ¶
Package usbwallet abstracts functionality provided by go-ethereum's usbwallet package, providing fully managed access to hardware wallets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAmbiguousDerivation is returned when account derivation is attempted // while multiple devices are connected but no non-zero expected address is // provided. ErrAmbiguousDerivation = errors.New("ambiguous account derivation") // ErrNoWalletsOpen is returned when account derivation is attempted but no // devices are open. ErrNoWalletsOpen = errors.New("no wallets open") )
Functions ¶
This section is empty.
Types ¶
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
A Wallet manages hardware wallets connected over USB. As it manages device events concurrently, any errors are reported on a channel accessible via the Err() method.
func NewLedger ¶
NewLedger is equivalent to calling New() with parameters specific to Ledger devices.
func (*Wallet) Close ¶
Close stops all device management and frees resources, also closing the Err() channel and unblocking all Wait() calls with sync.ErrToggleClosed.
func (*Wallet) Err ¶
Err returns the channel on which all errors are reported. Errors are not fatal to the Wallet.
func (*Wallet) SignerFn ¶
func (w *Wallet) SignerFn(index uint32, expectedAddr *common.Address, chainID *big.Int) (bind.SignerFn, common.Address, error)
SignerFn returns a SignerFn for use in a bind.TransactOpts. Unlike Metamask, the account index is 0-based. As the Wallet can manage more that one hardware device, the expected address removes ambiguity but MAY be nil (or a pointer to the zero address) i.f.f. there is only a single USB device connected.
Although a SignerFn accepts a types.Transaction, which itself contains a chain ID, the returned function is bound to a pre-specified chain for added security.