diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-01-17 18:59:15 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-01-17 18:59:15 +0100 |
commit | 7378b5a081a0d839c3bd63f6ddd359bca50be695 (patch) | |
tree | ce62b33d65e6372ea59ae7409b193824735ac538 /src/auditor/taler-auditor.c | |
parent | ac2e40d0491c0f118ff26cb316ec47e0786818e7 (diff) | |
download | exchange-7378b5a081a0d839c3bd63f6ddd359bca50be695.tar.xz |
amount rounding a la Christian
Diffstat (limited to 'src/auditor/taler-auditor.c')
-rw-r--r-- | src/auditor/taler-auditor.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index 8b2c2c37e..f3bb0e2b7 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -88,7 +88,7 @@ static char *currency; /** * How many fractional digits does the currency use? */ -static uint8_t currency_rounding_fractional_digits; +static struct TALER_Amount currency_round_unit; /** * Our configuration. @@ -2894,7 +2894,7 @@ check_wire_out_cb /* Round down to amount supported by wire method */ GNUNET_break (TALER_amount_round_down (&final_amount, - currency_rounding_fractional_digits)); + ¤cy_round_unit)); /* Calculate the exchange's gain as the fees plus rounding differences! */ if (GNUNET_OK != @@ -5205,28 +5205,29 @@ run (void *cls, return; } { - unsigned long long num; + char *rounding_str; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, + GNUNET_CONFIGURATION_get_value_string (cfg, "taler", - "CURRENCY_ROUNDING_FRACTIONAL_DIGITS", - &num)) + "CURRENCY_ROUND_UNIT", + &rounding_str)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "No [taler]/CURRENCY_ROUNDING_FRACTIONAL_DIGITS specified, defaulting to 2 digits.\n"); - currency_rounding_fractional_digits = 2; + "No [taler]/CURRENCY_ROUND_UNIT specified, defaulting to '0.01'.\n"); + TALER_amount_get_zero (currency, ¤cy_round_unit); + currency_round_unit.fraction = TALER_AMOUNT_FRAC_BASE / 100; } - else if (num > TALER_AMOUNT_FRAC_LEN) + else if (GNUNET_OK != + TALER_string_to_amount (rounding_str, + ¤cy_round_unit)) { - global_ret = 1; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Value of CURRENCY_ROUNDING_FRACTIONAL_DIGITS too big.\n"); + "Invalid amount `%s' specified in `TALER' under `CURRENCY_ROUND_UNIT'\n", + rounding_str); + GNUNET_free (rounding_str); + global_ret = 1; return; } - else - { - currency_rounding_fractional_digits = (uint8_t) num; - } } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, |