balance

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package balance provides utilities for fetching a Flipcash user's balance from the OCP server.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound indicates the user has no account bound to a public key, so
	// there's no owner account to fetch a balance for.
	ErrNotFound = errors.New("no owner account found for user")

	// ErrDenied indicates the OCP server refused to disclose the balance of an
	// owner account.
	ErrDenied = errors.New("denied access to balance")
)

Functions

This section is empty.

Types

type Client

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

Client fetches user balances from the OCP server.

func NewClient

func NewClient(
	log *zap.Logger,
	accounts account.Store,
	ocpBalance ocp_balancepb.BalanceClient,
) *Client

NewClient returns a Client backed by the OCP Balance service. The parent application is responsible for constructing ocpBalance against the OCP server's gRPC endpoint.

func (*Client) GetTotalUsdfBalance

func (c *Client) GetTotalUsdfBalance(ctx context.Context, userID *commonpb.UserId) (uint64, error)

GetTotalUsdfBalance returns a user's total balance in USDF quarks.

The value is what OCP reports as the owner account's core mint value, which is USDF for Flipcash. It spans every mint the user holds, with non-core mint holdings valued in USDF, so it is the user's total balance and not just the quarks sitting in their USDF accounts.

A user that hasn't opened OCP accounts yet has a zero balance. ErrNotFound is returned when the user has no public key bound at all.

Jump to

Keyboard shortcuts

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