Skip to main content

Module amount

Module amount 

Source
Expand description

Exact decimal amounts: ZEC ↔ zatoshi and dollars ↔ token base units, without floating point.

Constants§

ZAT_PER_ZEC
Zatoshi per ZEC.

Functions§

exact
Token base units as an exact decimal string (4975000 → "4.975" for 6 decimals).
parse_decimal
Parses a non-negative decimal ("0.1", "25", "1.000001") into base units with decimals digits. Refuses signs, exponents, empty parts and more fractional digits than decimals.
parse_usd
Parses an amount of dollars into token base units with decimals digits (more than zero).
parse_zec
Parses an amount of ZEC into zatoshi (more than zero).
usd
Token base units as dollars with two decimals, rounded down (4975000 → "4.97" for 6 decimals).
zec
Zatoshi as ZEC, without trailing zeros (10000000 → "0.1").