conf

package
v0.0.0-...-cfb1625 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package conf is for working with dot-donate files. See: https://github.com/aboodman/dot-donate.

Index

Constants

View Source
const (
	// DonateFile is the name of the dot-donate file.
	DonateFile string = ".donate"

	// PaymentTypeBTC indicates payment should happen using the Bitcoin network.
	PaymentTypeBTC string = "BTC"
	// PaymentTypePayPal indicates payment should happen using PayPal.
	PaymentTypePayPal string = "PayPal"
	// PaymentTypeUSDC indicates payment should happen using Coinbase's stablecoin, USDC.
	PaymentTypeUSDC string = "USDC"
	// PaymentTypeNone indicates no payment type.
	PaymentTypeNone string = ""
)

Variables

View Source
var (
	// ErrNoSupportedPaymentType is returned by conf.Read() when the config looks valid, but it
	// doesn't contain a payment type tythe supports.
	ErrNoSupportedPaymentType error = errors.New("No supported payment type")
)

Functions

func ValidUSDCAddress

func ValidUSDCAddress(addr string) bool

ValidUSDCAddress returns true if an string is a correctly formated USDC address. It doesn't check whether the address actually exists.

Types

type Config

type Config struct {
	BTC    string `json:"BTC,omitempty"`
	PayPal string `json:"PayPal,omitempty"`
	USDC   string `json:"USDC,omitempty"`
}

Config describes the json metadata developers add to their package to opt-in to receiving tythes.

func Read

func Read(dir string) (*Config, error)

Read loads the Config of a package if there is one. Returns nil, nil if no config.

func (Config) AddressForType

func (c Config) AddressForType(paymentType string) string

AddressForType returns the address to be used for a particular payment type.

func (Config) PreferredPaymentType

func (c Config) PreferredPaymentType() string

PreferredPaymentType returns the payment type that should be used, in the case that multiple are specified.

type PaymentType

type PaymentType string

PaymentType is a mechanism that tythe can use to move money between parties.

Jump to

Keyboard shortcuts

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