hdwallet

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Entropy128Bit is the minimum entropy amount allowed by BIP39,
	// and results in a BIP39 mnemonic of length 12.
	Entropy128Bit int = 128
	// Entropy160Bit results in a BIP39 mnemonic of length 15.
	Entropy160Bit int = 160
	// Entropy192Bit results in a BIP39 mnemonic of length 18.
	Entropy192Bit int = 192
	// Entropy224Bit results in a BIP39 mnemonic of length 21.
	Entropy224Bit int = 224
	// Entropy256Bit is the maximum entropy amount allowed by BIP39,
	// and results in a BIP39 mnemonic of length 24.
	Entropy256Bit int = 256
)

Variables

This section is empty.

Functions

func EntropyFromString

func EntropyFromString(entropy string) []byte

EntropyFromString returns the []byte representation of a hex-encoded entropy string.

func MnemonicHasAddress

func MnemonicHasAddress(addressHex, mnemonic, passphrase string, maxIndex int) (common.Address, bool, error)

Types

type HDWallet

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

HDWallet represents a BIP32/BIP44 Hierarchical Deterministic Wallet.

func NewHDWallet

func NewHDWallet(opts ...NewWalletOpt) (*HDWallet, error)

NewHDWallet constructs and returns an *HDWallet instance using any passed NewWalletOpt parameters.

func (HDWallet) Accounts

func (w HDWallet) Accounts() []*HDWalletAddress

func (*HDWallet) DeriveAddress

func (w *HDWallet) DeriveAddress() (*HDWalletAddress, error)

DeriveAddress derives a new, non-hardened child account using the next available derivation index. If the next available derivation index is the start of available "hardened" derivation indices, an error is returned.

func (*HDWallet) DeriveAddressFromIndex

func (w *HDWallet) DeriveAddressFromIndex(idx int) (*HDWalletAddress, error)

DeriveAddressFromIndex derives a new child account using the provided derivation index, which can be a hardened or non-hardened index.

func (*HDWallet) DeriveHardenedAddress

func (w *HDWallet) DeriveHardenedAddress() (*HDWalletAddress, error)

DeriveHardenedAddress derives a new, hardened child account using the next available derivation index.

func (HDWallet) Entropy

func (w HDWallet) Entropy() []byte

func (HDWallet) MasterKey

func (w HDWallet) MasterKey() *hdkeychain.ExtendedKey

func (HDWallet) Mnemonic

func (w HDWallet) Mnemonic() string

func (HDWallet) Seed

func (w HDWallet) Seed() []byte

type HDWalletAddress

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

HDWalletAddress represents a BIP32-compliant derived HD Wallet address (see https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki), consisting of an on-chain address and ECDSA private/public keys.

func (HDWalletAddress) Address

func (a HDWalletAddress) Address() common.Address

func (HDWalletAddress) DerivationIndex

func (a HDWalletAddress) DerivationIndex() int

func (HDWalletAddress) DerivationPath

func (a HDWalletAddress) DerivationPath() string

func (HDWalletAddress) Hardened

func (a HDWalletAddress) Hardened() bool

func (HDWalletAddress) HardenedDerivationIndex

func (a HDWalletAddress) HardenedDerivationIndex() int

func (HDWalletAddress) PrivateKey

func (a HDWalletAddress) PrivateKey() *ecdsa.PrivateKey

func (HDWalletAddress) PrivateKeyBytes

func (a HDWalletAddress) PrivateKeyBytes() []byte

func (HDWalletAddress) PrivateKeyHex

func (a HDWalletAddress) PrivateKeyHex() string

func (HDWalletAddress) PublicKey

func (a HDWalletAddress) PublicKey() ecdsa.PublicKey

func (HDWalletAddress) PublicKeyBytes

func (a HDWalletAddress) PublicKeyBytes() []byte

func (HDWalletAddress) PublicKeyHex

func (a HDWalletAddress) PublicKeyHex() string

func (*HDWalletAddress) TransactOptsForChainID

func (a *HDWalletAddress) TransactOptsForChainID(chainID *big.Int) (*bind.TransactOpts, error)

TransactOptsForChainID wraps go-ethereum's low-level bind.NewKeyedTransactorWithChainID function, returning a keyed *bind.TransactOpts object for the passed chainID. If the HDWalletAddress instance has already successfully constructed a transactor for the passed chainID, the previously constructed transactor is returned. Otherwise, the result of bind.NewKeyedTransactorWithChainID is returned.

type NewWalletOpt

type NewWalletOpt interface {
	// contains filtered or unexported methods
}

func WithDeriveKeyForAccount

func WithDeriveKeyForAccount(newKey bool) NewWalletOpt

func WithEntropy

func WithEntropy(entropy []byte) NewWalletOpt

func WithEntropyBits

func WithEntropyBits(entropyBits int) NewWalletOpt

func WithMnemonic

func WithMnemonic(mnemonic string) NewWalletOpt

func WithPassphrase

func WithPassphrase(passphrase string) NewWalletOpt

Jump to

Keyboard shortcuts

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