currency

package
v0.14.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: ISC Imports: 15 Imported by: 2

Documentation

Overview

Package currency - types and functions for converting currencies to/from enumeration values

Index

Constants

View Source
const (
	Nothing  Currency = iota // this must be the first value
	Bitcoin  Currency = iota
	Litecoin Currency = iota

	First Currency = Nothing + 1
	Last  Currency = maximumValue - 1
	Count int      = int(Last) // count of currencies
)

possible currency values

Variables

This section is empty.

Functions

func UnpackMap added in v0.7.0

func UnpackMap(buffer []byte, testnet bool) (Map, Set, error)

UnpackMap - unpack and validate a currency address mapping

Types

type Currency

type Currency uint64

Currency - currency enumeration

func FromUint64

func FromUint64(n uint64) (Currency, error)

FromUint64 - convert a number to a currency

func (Currency) ChainParam added in v0.12.0

func (currency Currency) ChainParam(chainName string) *chaincfg.Params

func (Currency) GetFee added in v0.3.5

func (currency Currency) GetFee() (uint64, error)

GetFee - returns the fee for a specific currency

func (Currency) GoString

func (currency Currency) GoString() string

GoString - convert abot enum value and symbol, for debugging

func (Currency) Index added in v0.5.0

func (currency Currency) Index() int

Index - convert a valid currency to a zero based array index

func (Currency) IsValid added in v0.5.0

func (currency Currency) IsValid() bool

IsValid - valid currency if in range of First to Last None is not considered as valid

func (Currency) MarshalText

func (currency Currency) MarshalText() ([]byte, error)

MarshalText - convert a currency into JSON

func (*Currency) Scan

func (currency *Currency) Scan(state fmt.ScanState, verb rune) error

Scan - convert a currency string

func (Currency) String

func (currency Currency) String() string

String - convert a currency to its string symbol

func (Currency) Uint64

func (currency Currency) Uint64() uint64

Uint64 - convert the currency to a number

func (*Currency) UnmarshalText

func (currency *Currency) UnmarshalText(s []byte) error

UnmarshalText - convert currency string to a currency enumeration value from JSON

func (Currency) ValidateAddress added in v0.7.0

func (currency Currency) ValidateAddress(address string, testnet bool) error

ValidateAddress - generic validate function

type Map added in v0.7.0

type Map map[Currency]string

Map - currency mapping to address strings

func (Map) Pack added in v0.7.0

func (m Map) Pack(testnet bool) ([]byte, error)

Pack - validate and pack a currency → address mapping create packed data as: (N = Address length)

Currency N Address   {first item}
…                    {more items}
Currency N Address   {final item}

type Set added in v0.7.0

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

Set - currency set

func MakeSet added in v0.7.0

func MakeSet(currencies ...Currency) Set

MakeSet - create a set of currencies

func (*Set) Add added in v0.7.0

func (set *Set) Add(c Currency) bool

Add - returns true if already present

func (*Set) Count added in v0.7.0

func (set *Set) Count() int

Count - returns number of currencies in the set

Directories

Path Synopsis
Package bitcoin - to validate bitcoin addresses
Package bitcoin - to validate bitcoin addresses
Package litecoin - to validate litecoin addresses
Package litecoin - to validate litecoin addresses
Package satoshi - to convert satoshi values to integers
Package satoshi - to convert satoshi values to integers

Jump to

Keyboard shortcuts

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