vsp

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: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*vspd.Client
	// contains filtered or unexported fields
}

func New

func New(cfg Config, log slog.Logger) (*Client, error)

func (*Client) FeePercentage

func (c *Client) FeePercentage(ctx context.Context) (float64, error)

func (*Client) Process

func (c *Client) Process(ctx context.Context, ticket *wallet.VSPTicket, feeTx *wire.MsgTx) error

Process begins processing a VSP fee payment for a ticket. If feeTx contains inputs, is used to pay the VSP fee. Otherwise, new inputs are selected and locked to prevent double spending the fee.

feeTx may be nil or may point to an empty transaction. It is modified with the inputs and the fee and change outputs before returning without an error. The fee transaction is also recorded as unpublised in the wallet, and the fee hash is associated with the ticket.

func (*Client) ProcessManagedTickets

func (c *Client) ProcessManagedTickets(ctx context.Context, tickets []*wallet.VSPTicket) error

ProcessManagedTickets adds the provided tickets to the client and resumes their fee payment process. Noop if a given ticket is already added, or if the ticket is not registered with the VSP. This is used to recover VSP tracking after seed restores.

func (*Client) ProcessUnprocessedTickets

func (c *Client) ProcessUnprocessedTickets(ctx context.Context, tickets []*wallet.VSPTicket)

ProcessUnprocessedTickets adds the provided tickets to the client. Noop if a given ticket is already added.

func (*Client) SetVoteChoice

func (c *Client) SetVoteChoice(ctx context.Context, ticket *wallet.VSPTicket,
	choices map[string]string, tspendPolicy map[string]string, treasuryPolicy map[string]string) error

SetVoteChoice takes the provided consensus, tspend and treasury key voting preferences, and checks if they match the status of the specified ticket from the connected VSP. The status provides the current voting preferences so we can just update from there if need be.

func (*Client) TrackedTickets

func (c *Client) TrackedTickets() []*TicketInfo

TrackedTickets returns information about all outstanding tickets tracked by a vsp.Client instance.

Currently this returns only info about tickets which fee hasn't been paid or confirmed at enough depth to be considered committed to.

type Config

type Config struct {
	// URL specifies the base URL of the VSP
	URL string

	// PubKey specifies the VSP's base64 encoded public key
	PubKey string

	// Dialer specifies an optional dialer when connecting to the VSP.
	Dialer DialFunc

	// Wallet specifies a loaded wallet.
	Wallet *wallet.Wallet

	// Default policy for fee payments unless another is provided by the
	// caller.
	Policy *Policy

	Params *chaincfg.Params
}

type DialFunc

type DialFunc func(ctx context.Context, network, addr string) (net.Conn, error)

type Policy

type Policy struct {
	MaxFee     dcrutil.Amount
	ChangeAcct uint32 // to derive fee addresses
	FeeAcct    uint32 // to pay fees from, if inputs are not provided to Process
}

type State

type State uint32
const (
	Unprocessed State
	FeePublished

	TicketSpent
)

type TicketInfo

type TicketInfo struct {
	TicketHash     chainhash.Hash
	CommitmentAddr stdaddr.StakeAddress
	VotingAddr     stdaddr.StakeAddress
	State          State
	Fee            dcrutil.Amount
	FeeHash        chainhash.Hash
}

TicketInfo stores per-ticket info tracked by a VSP Client instance.

Jump to

Keyboard shortcuts

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