summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-03-25 23:43:59 +0100
committerFlorian Dold <florian@dold.me>2021-03-25 23:43:59 +0100
commit53da30caea49d5802333994a42f0ccfe43e5138f (patch)
tree5a0ffac32041a207f6750f87b48b1adcd49b5734 /core
parent82cbba4c7418cc624d4a5e095176b0a88bd9b739 (diff)
downloaddocs-53da30caea49d5802333994a42f0ccfe43e5138f.tar.gz
docs-53da30caea49d5802333994a42f0ccfe43e5138f.tar.bz2
docs-53da30caea49d5802333994a42f0ccfe43e5138f.zip
improve amount description, no more ParsedAmount
Diffstat (limited to 'core')
-rw-r--r--core/api-common.rst49
1 files changed, 19 insertions, 30 deletions
diff --git a/core/api-common.rst b/core/api-common.rst
index a875d101..cecaf95b 100644
--- a/core/api-common.rst
+++ b/core/api-common.rst
@@ -387,37 +387,15 @@ this allows accurate representation of monetary amounts.
The following constrains apply for a valid amount:
-1. The ``<Currency>`` part must be at most 12 characters long and may not contain a colon (``:``).
+1. The ``<Currency>`` part must be at most 11 characters long and may only consist
+ of ASCII letters (``a-zA-Z``).
2. The integer part of ``<DecimalAmount>`` may be at most 2^52.
3. The fractional part of ``<DecimalAmount>`` may contain at most 8 decimal digits.
-Internally, amounts are parsed into the following object:
-
.. note::
"EUR:1.50" and "EUR:10" are valid amounts. These are all invalid amounts: "A:B:1.5", "EUR:4503599627370501.0", "EUR:1.", "EUR:.1".
-.. ts:def:: ParsedAmount
-
- interface ParsedAmount {
- // Name of the currency using either a three-character ISO 4217 currency
- // code, or a regional currency identifier starting with a "*" followed by
- // at most 10 characters. ISO 4217 exponents in the name are not supported,
- // although the "fraction" is corresponds to an ISO 4217 exponent of 6.
- currency: string;
-
- // Non-negative integer value in the currency, can be at most 2^52.
- // Note that "1" here would correspond to 1 EUR or 1 USD,
- // depending on `currency`, not 1 cent.
- value: number;
-
- // Unsigned 32 bit fractional value to be added to ``value`` representing
- // an additional currency fraction, in units of one hundred millionth (1e-8)
- // of the base currency value. For example, a fraction
- // of 50,000,000 would correspond to 50 cents.
- fraction: number;
- }
-
An amount that is prefixed with a ``+`` or ``-`` character is also used in certain contexts.
When no sign is present, the amount is assumed to be positive.
@@ -471,14 +449,25 @@ value and the denomination of the currency:
.. sourcecode:: c
- struct TALER_Amount {
+ struct TALER_AmountNBO {
+ // Non-negative integer value in the currency (in network byte order),
+ // can be at most 2^52.
+ // Note that "1" here would correspond to 1 EUR or 1 USD,
+ // depending on `currency`, not 1 cent.
uint64_t value;
+
+ // Unsigned 32 bit fractional value (in network byte order)
+ // to be added to ``value`` representing
+ // an additional currency fraction, in units of one hundred millionth (1e-8)
+ // of the base currency value. For example, a fraction
+ // of 50,000,000 would correspond to 50 cents.
uint32_t fraction;
- uint8_t currency_code[12]; // i.e. "EUR" or "USD"
- };
- struct TALER_AmountNBO {
- uint64_t value; // in network byte order
- uint32_t fraction; // in network byte order
+
+ // Name of the currency, using either a three-character ISO 4217 currency
+ // code, or a regional currency identifier between 4 and 11 characters,
+ // consisting of ASCII alphabetic characters ("a-zA-Z").
+ // Should be padded to 12 bytes with 0-characters.
+ // Currency codes are compared case-insensitively.
uint8_t currency_code[12];
};