Documentation
¶
Overview ¶
Package rewards pkg/deployment/rewards/config.go c3-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/payout.go c3-app-rewards
Package rewards pkg/deployment/rewards/server.go c3-app-rewards
Package rewards pkg/deployment/rewards/xpubindex.go c3-app-rewards
Index ¶
- Constants
- Variables
- func CheckTransactionPayouts(day, rawTxn string, sharesCSV []byte, spent func(string) (bool, error)) error
- func NodeAddressSpent(nodeURL string) func(addr string) (bool, error)
- func NodeAddressUsed(nodeURL string) func(addr string) (bool, error)
- func RemotePK(r *http.Request) cipher.PubKey
- func SingleAddressPKs(sharesCSV []byte) map[string][]string
- func WhitelistAuth(wlkeys []cipher.PubKey) func(http.Handler) http.Handler
- func Whitelisted(r *http.Request, wlkeys []cipher.PubKey) bool
- type Config
- type SkippedPayout
- type XpubIndex
Constants ¶
const XpubIndexFile = "xpub_index.json"
XpubIndexFile sits in the reward system's working directory, outside the served hist dir.
Variables ¶
SingleAddressCutoff is the first reward day that pays a single address only if it has never sent coins. See rewards/mainnet_rules.md, Skycoin Address.
Functions ¶
func CheckTransactionPayouts ¶
func CheckTransactionPayouts(day, rawTxn string, sharesCSV []byte, spent func(string) (bool, error)) error
CheckTransactionPayouts refuses a raw transaction (hex) for a reward day on or after SingleAddressCutoff that pays a single reward address of the day that has sent coins, or when spent cannot answer.
func NodeAddressSpent ¶
NodeAddressSpent reports whether an address has ever sent coins, using a skycoin node API.
func NodeAddressUsed ¶
NodeAddressUsed reports whether an address has ever received coins, using a skycoin node API.
func RemotePK ¶
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 SingleAddressPKs ¶
SingleAddressPKs reads a day's shares CSV and maps each single (not xpub derived) reward address to the visors paid there. The first column is the address, the second the visor PK and the last the xpub, empty for a single address.
func WhitelistAuth ¶
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 SkippedPayout ¶
SkippedPayout is a payout to a single address left out at distribution because the address has sent coins.
func FilterSpentPayouts ¶
func FilterSpentPayouts(day string, txnCSV, sharesCSV []byte, spent func(string) (bool, error)) ([]byte, []SkippedPayout, error)
FilterSpentPayouts drops from a day's reward transaction CSV ("address, amount" rows) every payout to a single address that has sent coins, from SingleAddressCutoff on. It fails, rather than guess, when spent cannot answer.
func (SkippedPayout) String ¶
func (s SkippedPayout) String() string
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 ¶
LoadXpubIndex reads the record at path. A missing file is an empty record.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package rewardsbot pkg/deployment/rewards/bot/bot.go c3-app-rewards
|
Package rewardsbot pkg/deployment/rewards/bot/bot.go c3-app-rewards |
|
Package rewardsserver pkg/deployment/rewards/server/cmd.go c3-app-rewards
|
Package rewardsserver pkg/deployment/rewards/server/cmd.go c3-app-rewards |