Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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.
const ( // SatoshiPerBitcent is the number of satoshi in one bitcoin cent. SatoshiPerBitcent Amount = 1e6 // SatoshiPerBitcoin is the number of satoshi in one bitcoin (1 DUO). SatoshiPerBitcoin Amount = 1e8 // MaxSatoshi is the maximum transaction amount allowed in satoshi. MaxSatoshi = 21e6 * SatoshiPerBitcoin )
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 DUO 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/p9c/monorepo/util#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 podbuild on top of bitcoin (for example, calculating a fee by multiplying by a percentage).
type Unit ¶
type Unit int
Unit describes a method of converting an Amount to something other than the base unit of a bitcoin. The value of the AmountUnit is the exponent component of the decadic multiple to convert from an amount in bitcoin to an amount counted in units.