HDWallet

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMnemonic

func GenerateMnemonic() (string, error)

*

GenerateMnemonic function generate a random mnemonic.

Returns:
	string: A random mnemonic phrase.
	error: An error if the generation of mnemonic fails.

func GenerateSeed

func GenerateSeed(mnemonic string, passphrase string) (string, error)

*

GenerateSeed generates a seed string from a mnemonic and passphrase.

Params:
	mnemonic (string): The mnemonic for seed generation.
	passphrase (string): The passphrase for seed generation.

Returns:
	string: The seed string in hexadecimal format.
	error: An error if the generation seed fails.

func IsMnemonic

func IsMnemonic(mnemonic string) bool

*

IsMnemonic checks if a given mnemonic pgrase is valid.

Params:
	mnemonic (string): The mnemonic phrase to validate.

Returns:
	bool: true if the mnemonic is valid, false otherwise.

Types

type HDWallet

type HDWallet struct {
	RootXprivKey bip32.XPrv
	XPrivKey     bip32.XPrv
	Path         string
	Seed         []byte
	Mnemonic     string
	Passphrase   string
	Entropy      string
}

func NewHDWalletFromMnemonic

func NewHDWalletFromMnemonic(mnemonic string, passphrase string) (*HDWallet, error)

func NewHDWalletFromSeed

func NewHDWalletFromSeed(seed string) (*HDWallet, error)

*

NewHDWalletFromSeed creates a new HDWallet instance from a seed string.

Params:
	seed (string): The input seed string.

Returns:
	*HDWallet: A new HDWallet instance.
	error: An error if the new wallet fails.

func (*HDWallet) Derive

func (hd *HDWallet) Derive(index uint32, hardened bool) *HDWallet

*

Derive function derives a new HDWallet from the current wallet
based on an index and a flag.

Params:
	index (uint32): The index for derivation.
	hardened (bool): A flag indicating whether to perform a hardened derivation.

Returns:
	*HDWallet: A new HDWallet derived based on the index and hardening flag.

func (*HDWallet) DerivePath

func (hd *HDWallet) DerivePath(path string) (*HDWallet, error)

*

DerivePath derives a new HDWallet from the current wallet based on
the path.

Params:
	path (string): The derivation path in the format "m/".

Returns:
	*HDWallet: A new HDWallet derived based on the path.
	error: An error if the derived path fails.

Jump to

Keyboard shortcuts

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