ticketbuyer

package
v4.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Config

type Config struct {
	BuyTickets bool

	// Account to buy tickets from
	Account uint32

	// Account to derive voting addresses from; overridden by VotingAddr
	VotingAccount uint32

	// Minimum amount to maintain in purchasing account
	Maintain dcrutil.Amount

	// Address to assign voting rights; overrides VotingAccount
	VotingAddr stdaddr.StakeAddress

	// Commitment address for stakepool fees
	PoolFeeAddr stdaddr.StakeAddress

	// Stakepool fee percentage (between 0-100)
	PoolFees float64

	// Limit maximum number of purchased tickets per block
	Limit int

	// CSPP-related options
	Mixing             bool
	MixedAccount       uint32
	MixedAccountBranch uint32
	TicketSplitAccount uint32
	ChangeAccount      uint32
	MixChange          bool

	// VSP client
	VSP *vsp.Client
}

Config modifies the behavior of TB.

type TB

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

TB is an automated ticket buyer, buying as many tickets as possible given an account's available balance. TB may be configured to buy tickets for any arbitrary voting address or (optional) stakepool.

func New

func New(w *wallet.Wallet) *TB

New returns a new TB to buy tickets from a wallet using the default config.

func (*TB) AccessConfig

func (tb *TB) AccessConfig(f func(cfg *Config))

AccessConfig runs f with the current config passed as a parameter. The config is protected by a mutex and this function is safe for concurrent access to read or modify the config. It is unsafe to leak a pointer to the config, but a copy of *cfg is legal.

func (*TB) Run

func (tb *TB) Run(ctx context.Context, passphrase []byte) error

Run executes the ticket buyer. If the private passphrase is incorrect, or ever becomes incorrect due to a wallet passphrase change, Run exits with an errors.Passphrase error.

Jump to

Keyboard shortcuts

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