Help us shape the future of Go! Take the 2026 Go Developer Survey

rewards

package
v1.3.104 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package rewards pkg/deployment/rewards/config.go c4-app-rewards handler. It can be used standalone (via the CLI) or embedded in the visor's port 80 router for integrated DMSG/skynet access.

Package rewards pkg/deployment/rewards/server.go c4-app-rewards

Index

Constants

View Source
const XpubIndexFile = "xpub_index.json"

XpubIndexFile sits in the reward system's working directory, outside the served hist dir.

Variables

This section is empty.

Functions

func IsWhitelisted

func IsWhitelisted(r *http.Request, wlkeys []cipher.PubKey) bool

IsWhitelisted checks if the current request is from a whitelisted PK without blocking. Used for UI rendering (show/hide links).

func NodeAddressUsed

func NodeAddressUsed(nodeURL string) func(addr string) (bool, error)

NodeAddressUsed reports whether an address has ever received coins, using a skycoin node API.

func RemotePK

func RemotePK(r *http.Request) cipher.PubKey

RemotePK returns the DMSG-authenticated source public key of the current request (from RemoteAddr), or a null key if it can't be parsed. Exported for handlers that must attribute a request to its sender — e.g. the survey-push endpoint stores a pushed survey under the sender's own PK so a visor can only write its own.

func WhitelistAuth

func WhitelistAuth(wlkeys []cipher.PubKey) func(http.Handler) http.Handler

WhitelistAuth returns a middleware that checks if the remote PK (from DMSG/skynet RemoteAddr) is in the whitelist. Exported so the visor can use the same auth pattern.

Types

type Config

type Config struct {
	// StartTime is when the server started (for /health uptime).
	StartTime time.Time

	// PK and SK for DMSG client (only needed for standalone mode).
	PK cipher.PubKey
	SK cipher.SecKey

	// DmsgDisc is the DMSG discovery URL (standalone mode).
	DmsgDisc string
	// DmsgPort is the DMSG port to serve on (standalone mode).
	DmsgPort uint16
	// DmsgSessions is the number of DMSG sessions (standalone mode).
	DmsgSessions int

	// WebPort is the HTTP port (standalone mode).
	WebPort uint

	// WhitelistPKs is the list of PKs allowed to POST reward
	// transactions and access protected endpoints.
	WhitelistPKs []cipher.PubKey

	// WorkDir is the directory containing log_collection and reward
	// hist directories.
	WorkDir string

	// CanonicalDomain is the public domain name for SEO/sitemap
	// (e.g., "theskywirenetwork.net").
	CanonicalDomain string

	// HealthOnly disables all endpoints except /health.
	HealthOnly bool

	// EnsureOnlineURL is the URL to check for internet connectivity.
	EnsureOnlineURL string

	// LoginNode is the address of the login chain node.
	LoginNode string
	// SkycoinNode is the address of the skycoin node for tx broadcast.
	SkycoinNode string
	// LoginChainFlags is additional flags for login chain.
	LoginChainFlags string

	// Logger for the reward system.
	Log *logging.Logger
}

Config holds all the configuration needed to run the reward system UI.

type XpubIndex

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

XpubIndex records the external chain index paid to each xpub for each reward date, so no address is paid twice. Keys are SHA-256 hashes, so the xpubs are not stored.

func LoadXpubIndex

func LoadXpubIndex(path string) (*XpubIndex, error)

LoadXpubIndex reads the record at path. A missing file is an empty record.

func (*XpubIndex) Assign

func (x *XpubIndex) Assign(xpub, date string, used func(addr string) (bool, error)) (uint32, error)

Assign returns the index to pay xpub at for date. A date keeps the index it was first given. A new one is past every assigned index and every address used reports as seen.

func (*XpubIndex) MaxIndex

func (x *XpubIndex) MaxIndex(xpub string) (uint32, bool)

MaxIndex is the highest index assigned to xpub, and false if it was never assigned one.

Jump to

Keyboard shortcuts

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