vsp

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: ISC Imports: 28 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 BadRequestError

type BadRequestError struct {
	HTTPStatus int    `json:"-"`
	Code       int    `json:"code"`
	Message    string `json:"message"`
}

func (*BadRequestError) Error

func (e *BadRequestError) Error() string

type Client

type Client struct {
	Wallet *wallet.Wallet
	Policy Policy
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Client, error)

func (*Client) FeePercentage

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

func (*Client) ForUnspentUnexpiredTickets

func (c *Client) ForUnspentUnexpiredTickets(ctx context.Context,
	f func(hash *chainhash.Hash) error) error

ForUnspentUnexpiredTickets performs a function on every unexpired and unspent ticket from the wallet.

func (*Client) Process

func (c *Client) Process(ctx context.Context, ticketHash *chainhash.Hash, 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 must not be nil, but may point to an empty transaction, and 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, policy Policy) error

ProcessManagedTickets discovers tickets which were previously registered with a VSP and begins syncing them in the background. This is used to recover VSP tracking after seed restores, and is only performed on unspent and unexpired tickets.

func (*Client) ProcessUnprocessedTickets

func (c *Client) ProcessUnprocessedTickets(ctx context.Context, policy Policy)

ProcessUnprocessedTickets ...

func (*Client) ProcessWithPolicy

func (c *Client) ProcessWithPolicy(ctx context.Context, ticketHash *chainhash.Hash, feeTx *wire.MsgTx,
	policy Policy) error

ProcessWithPolicy is the same as Process but allows a fee payment policy to be specified, instead of using the client's default policy.

func (*Client) SetVoteChoice added in v1.6.1

func (c *Client) SetVoteChoice(ctx context.Context, hash *chainhash.Hash, choices ...wallet.AgendaChoice) error

SetVoteChoice takes the provided AgendaChoices and ticket hash, checks the status of the ticket from the connected vsp. The status provides the current vote choice so we can just update from there if need be.

func (*Client) TrackedTickets added in v1.7.1

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
}

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 TicketInfo added in v1.7.1

type TicketInfo struct {
	TicketHash     chainhash.Hash
	CommitmentAddr dcrutil.Address
	VotingAddr     dcrutil.Address
	State          uint32
	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