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 ¶
- Variables
- func DisableLog()
- func UseLogger(logger btclog.Logger)
- type Loader
- func (l *Loader) CreateNewWallet(pubPassphrase, privPassphrase, seed []byte) (w *wallet.Wallet, err error)
- func (l *Loader) LoadedWallet() (*wallet.Wallet, bool)
- func (l *Loader) OpenExistingWallet(pubPassphrase []byte, privPassphrase []byte) (w *wallet.Wallet, rerr error)
- func (l *Loader) PurchaseManager() *ticketbuyer.PurchaseManager
- func (l *Loader) RunAfterLoad(fn func(*wallet.Wallet))
- func (l *Loader) SetChainClient(chainClient *hcrpcclient.Client)
- func (l *Loader) StartTicketPurchase(passphrase []byte, ticketbuyerCfg *ticketbuyer.Config) error
- func (l *Loader) StopTicketPurchase() error
- func (l *Loader) UnloadWallet() error
- func (l *Loader) WalletExists() (bool, error)
- type StakeOptions
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWalletLoaded describes the error condition of attempting to load or // create a wallet when the loader has already done so. ErrWalletLoaded = errors.New("wallet already loaded") // ErrWalletNotLoaded describes the error condition of attempting to close // a loaded wallet when a wallet has not been loaded. ErrWalletNotLoaded = errors.New("wallet is not loaded") // ErrWalletExists describes the error condition of attempting to create a // new wallet when one exists already. ErrWalletExists = errors.New("wallet already exists") // ErrTicketBuyerStarted describes the error condition of attempting to // start ticketbuyer when it is already started. ErrTicketBuyerStarted = errors.New("ticketbuyer already started") // ErrTicketBuyerStopped describes the error condition of attempting to // stop ticketbuyer when it is already stopped. ErrTicketBuyerStopped = errors.New("ticketbuyer not running") // ErrNoChainClient describes the error condition of attempting to start // ticketbuyer when no chain client is available. ErrNoChainClient = errors.New("chain client not available") )
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
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, addrIdxScanLen int, allowHighFees bool, relayFee float64, enableOmni bool) *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) LoadedWallet ¶
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) OpenExistingWallet ¶
func (l *Loader) OpenExistingWallet(pubPassphrase []byte, privPassphrase []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 ¶
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) SetChainClient ¶
func (l *Loader) SetChainClient(chainClient *hcrpcclient.Client)
SetChainClient sets the chain server client.
func (*Loader) StartTicketPurchase ¶
func (l *Loader) StartTicketPurchase(passphrase []byte, ticketbuyerCfg *ticketbuyer.Config) error
StartTicketPurchase launches the ticketbuyer to start purchasing tickets.
func (*Loader) StopTicketPurchase ¶
StopTicketPurchase stops the ticket purchaser, waiting until it has finished. If no ticket purchaser is running, it returns ErrTicketBuyerStopped.
func (*Loader) UnloadWallet ¶
UnloadWallet stops the loaded wallet, if any, and closes the wallet database. This returns ErrWalletNotLoaded 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 ¶
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 { TicketPurchasingEnabled bool VotingEnabled bool TicketFee float64 AddressReuse bool TicketAddress hcutil.Address SubsidyAddress hcutil.Address PoolAddress hcutil.Address PoolFees float64 StakePoolColdExtKey string }
StakeOptions contains the various options necessary for stake mining.