Documentation ¶
Index ¶
Constants ¶
const ( AmountMegaBTC Unit = 6 AmountKiloBTC Unit = 3 AmountBTC Unit = 0 AmountMilliBTC Unit = -3 AmountMicroBTC Unit = -6 AmountSatoshi Unit = -8 CENT int64 = 1000000 )
These constants define various units used when describing a bitcoin monetary amount.
Variables ¶
This section is empty.
Functions ¶
func MoneyRange ¶
Types ¶
type Amount ¶
type Amount int64
Amount represents the base bitcoin monetary unit (colloquially referred to as a `Satoshi'). A single Amount is equal to 1e-8 of a bitcoin.
func NewAmount ¶
NewAmount creates an Amount from a floating point value representing some value in bitcoin. NewAmount errors if f is NaN or +-Infinity, but does not check that the amount is within the total amount of bitcoin producible as f may not refer to an amount at a single moment in time.
NewAmount is for specifically for converting BTC to Satoshi. For creating a new Amount with an int64 value which denotes a quantity of Satoshi, 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 ¶
Format formats a monetary amount counted in bitcoin 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 "Satoshi" 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 bitcoin (for example, calculating a fee by multiplying by a percentage).