loader

package
v0.0.0-...-c45a497 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: ISC Imports: 11 Imported by: 0

Documentation

Overview

Package loader provides a concurrent safe implementation of a wallet loader.

It is intended to allow creating and opening wallets as well as managing services like ticket buyer by RPC servers as well other subsystems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type Loader

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

Loader implements the creating of new and opening of existing wallets, while providing a callback system for other subsystems to handle the loading of a wallet. This is primarely intended for use by the RPC servers, to enable methods and services which require the wallet when the wallet is loaded by another subsystem.

Loader is safe for concurrent access.

func NewLoader

func NewLoader(chainParams *chaincfg.Params, dbDirPath string, stakeOptions *StakeOptions, gapLimit int,
	allowHighFees bool, relayFee float64, accountGapLimit int) *Loader

NewLoader constructs a Loader.

func (*Loader) CreateNewWallet

func (l *Loader) CreateNewWallet(pubPassphrase, privPassphrase, seed []byte) (w *wallet.Wallet, err error)

CreateNewWallet creates a new wallet using the provided public and private passphrases. The seed is optional. If non-nil, addresses are derived from this seed. If nil, a secure random seed is generated.

func (*Loader) CreateWatchingOnlyWallet

func (l *Loader) CreateWatchingOnlyWallet(extendedPubKey string, pubPass []byte) (w *wallet.Wallet, err error)

CreateWatchingOnlyWallet creates a new watch-only wallet using the provided extended public key and public passphrase.

func (*Loader) DbDirPath

func (l *Loader) DbDirPath() string

DbDirPath returns the Loader's database directory path

func (*Loader) LoadedWallet

func (l *Loader) LoadedWallet() (*wallet.Wallet, bool)

LoadedWallet returns the loaded wallet, if any, and a bool for whether the wallet has been loaded or not. If true, the wallet pointer should be safe to dereference.

func (*Loader) NetworkBackend

func (l *Loader) NetworkBackend() (n wallet.NetworkBackend, ok bool)

NetworkBackend returns the associated wallet network backend, if any, and a bool describing whether a non-nil network backend was set.

func (*Loader) OpenExistingWallet

func (l *Loader) OpenExistingWallet(pubPassphrase []byte) (w *wallet.Wallet, rerr error)

OpenExistingWallet opens the wallet from the loader's wallet database path and the public passphrase. If the loader is being called by a context where standard input prompts may be used during wallet upgrades, setting canConsolePrompt will enable these prompts.

func (*Loader) PurchaseManager

func (l *Loader) PurchaseManager() *ticketbuyer.PurchaseManager

PurchaseManager returns the ticket purchaser instance. If ticket purchasing has been disabled, it returns nil.

func (*Loader) RunAfterLoad

func (l *Loader) RunAfterLoad(fn func(*wallet.Wallet))

RunAfterLoad adds a function to be executed when the loader creates or opens a wallet. Functions are executed in a single goroutine in the order they are added.

func (*Loader) SetDatabaseDriver

func (l *Loader) SetDatabaseDriver(driver string)

SetDatabaseDriver specifies the database to be used by walletdb

func (*Loader) SetNetworkBackend

func (l *Loader) SetNetworkBackend(n wallet.NetworkBackend)

SetNetworkBackend associates the loader with a wallet network backend.

func (*Loader) StartTicketPurchase

func (l *Loader) StartTicketPurchase(passphrase []byte, ticketbuyerCfg *ticketbuyer.Config) error

StartTicketPurchase launches the ticketbuyer to start purchasing tickets.

func (*Loader) StopTicketPurchase

func (l *Loader) StopTicketPurchase() error

StopTicketPurchase stops the ticket purchaser, waiting until it has finished.

func (*Loader) UnloadWallet

func (l *Loader) UnloadWallet() error

UnloadWallet stops the loaded wallet, if any, and closes the wallet database. Returns with errors.Invalid if the wallet has not been loaded with CreateNewWallet or LoadExistingWallet. The Loader may be reused if this function returns without error.

func (*Loader) WalletExists

func (l *Loader) WalletExists() (bool, error)

WalletExists returns whether a file exists at the loader's database path. This may return an error for unexpected I/O failures.

type StakeOptions

type StakeOptions struct {
	VotingEnabled       bool
	TicketFee           float64
	AddressReuse        bool
	VotingAddress       dcrutil.Address
	PoolAddress         dcrutil.Address
	PoolFees            float64
	StakePoolColdExtKey string
}

StakeOptions contains the various options necessary for stake mining.

Jump to

Keyboard shortcuts

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