Documentation
¶
Index ¶
Constants ¶
const ( // SatoshiPerBitcent is the number of satoshi in one gophercoin cent. SatoshiPerBitcent = 1e6 // GoshPerGcoin is the number of gosh in one gophercoin (1 GOC). GoshPerGcoin = 1e8 // MaxGosh is the maximum transaction amount allowed in gosh. MaxGosh = 21e6 * GoshPerGcoin )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Amount ¶
type Amount int64
Amount represents the base gophercoin monetary unit (colloquially referred to as a `Gosh'). A single Amount is equal to 1e-8 of a gophercoin.
func NewAmount ¶
NewAmount creates an Amount from a floating point value representing some value in gophercoin. NewAmount errors if f is NaN or +-Infinity, but does not check that the amount is within the total amount of gophercoin producible as f may not refer to an amount at a single moment in time.
NewAmount is for specifically for converting GOC to Gosh. For creating a new Amount with an int64 value which denotes a quantity of Gosh, do a simple type conversion from type int64 to Amount. See GoDoc for example: http://godoc.org/github.com/btcsuite/btcutil#example-Amount
func (Amount) Format ¶
func (a Amount) Format(u AmountUnit) string
Format formats a monetary amount counted in gophercoin base units as a string for a given unit. The conversion will succeed for any unit, however, known units will be formated with an appended label describing the units with SI notation, or "Gosh" for the base unit.
func (Amount) MulF64 ¶
MulF64 multiplies an Amount by a floating point value. While this is not an operation that must typically be done by a full node or wallet, it is useful for services that build on top of gophercoin (for example, calculating a fee by multiplying by a percentage).
func (Amount) ToUnit ¶
func (a Amount) ToUnit(u AmountUnit) float64
ToUnit converts a monetary amount counted in gophercoin base units to a floating point value representing an amount of gophercoin.
type AmountUnit ¶
type AmountUnit int
AmountUnit describes a method of converting an Amount to something other than the base unit of a gophercoin. The value of the AmountUnit is the exponent component of the decadic multiple to convert from an amount in gophercoin to an amount counted in units.
const ( AmountMegaGOC AmountUnit = 6 AmountKiloGOC AmountUnit = 3 AmountGOC AmountUnit = 0 AmountMilliGOC AmountUnit = -3 AmountMicroGOC AmountUnit = -6 AmountGosh AmountUnit = -8 )
These constants define various units used when describing a gophercoin monetary amount.
func (AmountUnit) String ¶
func (u AmountUnit) String() string
String returns the unit as a string. For recognized units, the SI prefix is used, or "Gosh" for the base unit. For all unrecognized units, "1eN GOC" is returned, where N is the AmountUnit.