bitcoin-hs-0.0.1: Partial implementation of the Bitcoin protocol (as of 2013)

Safe HaskellSafe
LanguageHaskell98

Bitcoin.Protocol.Amount

Contents

Description

Amounts of BTC

Synopsis

Documentation

newtype Amount Source #

A (nonnegative) amount of bitcoins.

Note: the Show/Read instances look like

newtype Amount = BTC Double

eg. BTC 1.3

However, the internal representation is different.

Constructors

Amount 

Fields

human-friendly definitions of amounts

btc :: Double -> Amount Source #

Whole BTCs

mbtc :: Double -> Amount Source #

milli-BTCs

ubtc :: Double -> Amount Source #

micro-BTCs

satoshi :: Int -> Amount Source #

"satoshi" is the smallest unit: 1 satoshi = 10^(-8) BTC

constants

amountMultiplier :: Num a => a Source #

10^amountExponent == 10^8

amountExponent :: Int Source #

The exponent is 8, as 10^(-8) is the smallest unit.

conversion

integerAmount :: Amount -> Integer Source #

The amount measured in smallest units (satoshis)

doubleAmount :: Amount -> Double Source #

The amount in BTCs as a Double

amountFromDouble :: Double -> Amount Source #

Convert whole BTCs to an Amount. Rounding to whole satoshis.

showAmount :: Amount -> String Source #

Shows an amount in BTCs using the minimum necessary digits

parseAmount :: String -> Maybe Amount Source #

Note: unlike doubleAmount, this ignores all digits after the 8th decimal.