Update docs for NewAmount

- Documentation update to NewAmount.
  Call out the fact it's specifically for converting BTC to Satoshi.
  The caller should perform a simple type cast to an Amount when dealing
  with int64 values which denote a quantity of Satoshi.
This commit is contained in:
Mawuli Adzoe 2015-07-25 08:49:36 +00:00
parent 1c7f05922f
commit 03f6069579

View file

@ -68,6 +68,11 @@ func round(f float64) Amount {
// some value in bitcoin. NewAmount errors if f is NaN or +-Infinity, but // 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 // 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. // 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 NewAmount(f float64) (Amount, error) { func NewAmount(f float64) (Amount, error) {
// The amount is only considered invalid if it cannot be represented // The amount is only considered invalid if it cannot be represented
// as an integer type. This may happen if f is NaN or +-Infinity. // as an integer type. This may happen if f is NaN or +-Infinity.