hdwallet

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: MIT Imports: 17 Imported by: 0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.1.0

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 added in v0.1.0

func (a HDWalletAddress) Address() common.Address

func (HDWalletAddress) DerivationIndex added in v0.1.0

func (a HDWalletAddress) DerivationIndex() int

func (HDWalletAddress) DerivationPath added in v0.1.0

func (a HDWalletAddress) DerivationPath() string

func (HDWalletAddress) Hardened added in v0.1.0

func (a HDWalletAddress) Hardened() bool

func (HDWalletAddress) HardenedDerivationIndex added in v0.1.0

func (a HDWalletAddress) HardenedDerivationIndex() int

func (HDWalletAddress) PrivateKey added in v0.1.0

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

func (HDWalletAddress) PrivateKeyBytes added in v0.1.0

func (a HDWalletAddress) PrivateKeyBytes() []byte

func (HDWalletAddress) PrivateKeyHex added in v0.1.0

func (a HDWalletAddress) PrivateKeyHex() string

func (HDWalletAddress) PublicKey added in v0.1.0

func (a HDWalletAddress) PublicKey() ecdsa.PublicKey

func (HDWalletAddress) PublicKeyBytes added in v0.1.0

func (a HDWalletAddress) PublicKeyBytes() []byte

func (HDWalletAddress) PublicKeyHex added in v0.1.0

func (a HDWalletAddress) PublicKeyHex() string

func (*HDWalletAddress) TransactOptsForChainID added in v0.1.0

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 added in v0.2.0

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