wallet

package
v0.0.0-...-55ecaa8 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PRIVATE_KEY_KEY     = "private-key"
	MNEMONIC_KEY        = "mnemonic"
	DERIVATION_PATH_KEY = "mnemonic-derivation-path"
)

Variables

View Source
var (
	ErrWalletNotSet = errors.New("wallet not set")
	ErrWallet       = errors.New("cannot retrieve mnemonic or private key")
)
View Source
var ErrEnvWalletSet = errors.New("cannot set private key for env wallet, switch to keychain wallet by removing WALLET_PRIVATE_KEY env var")

Functions

func NewSeedFromMnemonic

func NewSeedFromMnemonic(mnemonic string, passOpt ...string) ([]byte, error)

NewSeedFromMnemonic returns a BIP-39 seed based on a BIP-39 mnemonic.

Types

type EnvWallet

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

func NewEnvWallet

func NewEnvWallet(privKey lib.HexString) *EnvWallet

func (*EnvWallet) DeleteWallet

func (w *EnvWallet) DeleteWallet() error

func (*EnvWallet) GetPrivateKey

func (w *EnvWallet) GetPrivateKey() (lib.HexString, error)

func (*EnvWallet) PrivateKeyUpdated

func (w *EnvWallet) PrivateKeyUpdated() <-chan struct{}

func (*EnvWallet) SetMnemonic

func (w *EnvWallet) SetMnemonic(mnemonic string, derivationPath string) error

func (*EnvWallet) SetPrivateKey

func (w *EnvWallet) SetPrivateKey(privateKeyOxHex lib.HexString) error

type KeychainWallet

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

func NewKeychainWallet

func NewKeychainWallet(keychain i.KeyValueStorage) *KeychainWallet

func (*KeychainWallet) DeleteWallet

func (w *KeychainWallet) DeleteWallet() error

func (*KeychainWallet) GetPrivateKey

func (w *KeychainWallet) GetPrivateKey() (lib.HexString, error)

GetPrivateKey use this function to get the private key regardless of whether it was stored as a mnemonic or private key

errors with ErrPkeyAndMnemonic if both mnemonic and private key are stored

func (*KeychainWallet) PrivateKeyUpdated

func (w *KeychainWallet) PrivateKeyUpdated() <-chan struct{}

func (*KeychainWallet) SetMnemonic

func (w *KeychainWallet) SetMnemonic(mnemonic string, derivationPath string) error

SetMnemonic stores the mnemonic of the wallet

func (*KeychainWallet) SetPrivateKey

func (w *KeychainWallet) SetPrivateKey(privateKey lib.HexString) error

SetPrivateKey stores the private key of the wallet

type Wallet

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

func NewFromMnemonic

func NewFromMnemonic(mnemonic string, passOpt ...string) (*Wallet, error)

NewFromMnemonic returns a new wallet from a BIP-39 mnemonic.

func (*Wallet) DerivePrivateKey

func (w *Wallet) DerivePrivateKey(path accounts.DerivationPath) (*ecdsa.PrivateKey, error)

DerivePrivateKey derives the private key of the derivation path.

Jump to

Keyboard shortcuts

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