hdwallet

package
v0.0.0-...-c57a2f4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2019 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWalletDirectory = "wallets"
	DefaultPrivateDataName = "private.key"

	ErrorPrivateKeyCreating = "Can't create private data in %v"

	StatusSuccessfullyCreated = "Wallet created successfully."
)

Variables

View Source
var (
	AccountNamespaceKey = []byte("waddrmgr")
)
View Source
var AvailableCoinTypes = []string{"BTC", "LTC", "ETH"}

Functions

func Decrypt

func Decrypt(data []byte, passphrase string) []byte

func Encrypt

func Encrypt(data []byte, passphrase string) []byte

func GeneratePath

func GeneratePath(testnet bool, name string) (string, error)

func GetLoader

func GetLoader(testnet bool, name string) (*wallet.Loader, error)

func GetNetwork

func GetNetwork(testNet bool) netparams.Params

func ValidatePhrase

func ValidatePhrase(phrase string) bool

Validating seed phrase. The seed phrase must contain only letters and spaces

The seed phrase must contain [12,24] words

Types

type AccountManager

type AccountManager struct {
	WalletAuth
	AccountName string `short:"a" long:"account" description:"Account name" json:"account"`
}

func (AccountManager) NewAccount

func (generator AccountManager) NewAccount(wallet btcWallet.Wallet) (uint32, error)

This function creates a new account based on wallet and already specified name For first you nedd to unlock the wallet with passpriv If any error caused during this process , the function will return 0 and an error

type AddressManager

type AddressManager struct {
	Account string `short:"a" long:"account" description:"Account name" json:"account"`

	WalletAuth

	Level int `short:"l" long:"level" description:"Address generation level"`
	Index int `short:"i" long:"index" description:"Address generation index"`
	// contains filtered or unexported fields
}

func (*AddressManager) NewAddress

func (am *AddressManager) NewAddress() (addresses []string, err error)

This function generates a new address based an account and the wallet Also considering coin type

func (*AddressManager) SetWallet

func (am *AddressManager) SetWallet(wallet *btcdWallet.Wallet)

This function will set the wallet in AddressManager If the wallet doesn't set than will be empty wallet instead

type HDWallet

type HDWallet struct {
	SeedPhrase string `json:"seed" short:"s" long:"seed" description:"Seed phrase of the  wallet"`
	WalletAuth
}

func (*HDWallet) Create

func (wallet *HDWallet) Create() (*btcdwallet.Wallet, error)

Create function receives a data to create and initialize wallet and return instance of HDWallet and/or error

type WalletAuth

type WalletAuth struct {
	WalletName string `short:"n" long:"name" description:"Name of the wallet" json:"wallet"`
	Password   string `short:"p" long:"password" description:"Password of the wallet" json:"password"`
	Coin       uint32 `short:"c" long:"coin" description:"Coin type" json:"coin"`
	TestNet    bool   `short:"t" long:"testnet" description:"TesNet network" json:"testnet"`
}

func (*WalletAuth) Authorize

func (wallet *WalletAuth) Authorize() (*btcwallet.Wallet, error)

This function will authorize wallet based on name and password If the loader can't find the wallet will be returned an error Else the function will be return an existing wallet

func (*WalletAuth) GetKeyScope

func (wallet *WalletAuth) GetKeyScope() waddrmgr.KeyScope

This function return kyscope data based on BIP and coin id ( we are always uisng BIP44 )

func (WalletAuth) Path

func (wallet WalletAuth) Path()

Jump to

Keyboard shortcuts

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