wad

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsatsPerSat  = 1000
	SatsPerBtc   = btcutil.SatoshiPerBitcoin
	MsatsPerBtc  = MsatsPerSat * SatsPerBtc
	AllCountries = "All"
)

Variables

View Source
var CryptoCurrency = CurrencyMap{
	"LTC": {
		Code: "LTC",
		Name: "Litecoin",
	},
	"ETH": {
		Code: "ETH",
		Name: "Ethereum",
	},
}
View Source
var Fiat = CurrencyMap{}/* 169 elements not displayed */

Functions

This section is empty.

Types

type Currency

type Currency struct {
	Code      string `json:"code"`
	Countries string `json:"countries"`
	Decimals  int    `json:"decimals"`
	// negative if null
	IsoNum int    `json:"iso_num"`
	Name   string `json:"name"`
	Symbol string `json:"symbol"`
}

type CurrencyMap

type CurrencyMap = map[string]Currency

type Rate

type Rate struct {
	BaseCode  string
	QuoteCode string
	RateValue float64
	Timestamp time.Time
}

func DeriveRate

func DeriveRate(baseQuote string, quoteCode string, rates [2]Rate) Rate

func NewRate

func NewRate(baseCode string, quoteCode string, rate float64) Rate

func (Rate) Convert

func (r Rate) Convert(value float64, valueCode string) (converted float64, code string)

func (Rate) Includes

func (r Rate) Includes(quote string) bool

wether or not Code is base Code or quote Code

func (Rate) Invert

func (r Rate) Invert() Rate

func (Rate) Other

func (r Rate) Other(code string) string

if base get quote if quote get base

func (Rate) ToString

func (r Rate) ToString() string

type Wad

type Wad struct {
	Msats       float64 `json:"Msats"`
	AssetStable bool    `json:"asset_stable"`
	AssetUnit   float64 `json:"asset_unit"`
	// contains filtered or unexported fields
}

todo add currency in here

func BitcoinWad

func BitcoinWad(msats float64) Wad

func CadWad

func CadWad(cad float64, rate Rate) Wad

func CustomWad

func CustomWad(units float64, rate Rate, code string, countries string, decimals int, name string, symbol string) Wad

func NewWad

func NewWad(msats float64, assetStable bool, assetUnit float64, code string) Wad

func UsdWad

func UsdWad(usd float64, rate Rate) Wad

func (Wad) FmtLong

func (w Wad) FmtLong() string

func (Wad) FmtShort

func (w Wad) FmtShort() string

func (*Wad) UpdateCurrency

func (w *Wad) UpdateCurrency(currency Currency)

Jump to

Keyboard shortcuts

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