use TALER_config_get_amount() consistently, require currency rounding option to exist instead of defaulting
This commit is contained in:
parent
6f3c682722
commit
4fac247bc7
@ -5258,28 +5258,14 @@ run (void *cls,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
char *rounding_str;
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_amount (cfg,
|
||||||
"taler",
|
"taler",
|
||||||
"CURRENCY_ROUND_UNIT",
|
"CURRENCY_ROUND_UNIT",
|
||||||
&rounding_str))
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
|
||||||
"No [taler]/CURRENCY_ROUND_UNIT specified, defaulting to '0.01'.\n");
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
|
||||||
TALER_amount_get_zero (currency,
|
|
||||||
¤cy_round_unit));
|
|
||||||
currency_round_unit.fraction = TALER_AMOUNT_FRAC_BASE / 100;
|
|
||||||
}
|
|
||||||
else if (GNUNET_OK !=
|
|
||||||
TALER_string_to_amount (rounding_str,
|
|
||||||
¤cy_round_unit))
|
¤cy_round_unit))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Invalid amount `%s' specified in `TALER' under `CURRENCY_ROUND_UNIT'\n",
|
"Invalid or missing amount in `TALER' under `CURRENCY_ROUND_UNIT'\n");
|
||||||
rounding_str);
|
|
||||||
GNUNET_free (rounding_str);
|
|
||||||
global_ret = 1;
|
global_ret = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2103,7 +2103,6 @@ run (void *cls,
|
|||||||
const struct GNUNET_CONFIGURATION_Handle *c)
|
const struct GNUNET_CONFIGURATION_Handle *c)
|
||||||
{
|
{
|
||||||
static const struct TALER_MasterPublicKeyP zeromp;
|
static const struct TALER_MasterPublicKeyP zeromp;
|
||||||
char *tinys;
|
|
||||||
|
|
||||||
(void) cls;
|
(void) cls;
|
||||||
(void) args;
|
(void) args;
|
||||||
@ -2113,22 +2112,11 @@ run (void *cls,
|
|||||||
start_time = GNUNET_TIME_absolute_get ();
|
start_time = GNUNET_TIME_absolute_get ();
|
||||||
cfg = c;
|
cfg = c;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
TALER_config_get_amount (cfg,
|
||||||
"auditor",
|
"auditor",
|
||||||
"TINY_AMOUNT",
|
"TINY_AMOUNT",
|
||||||
&tinys))
|
|
||||||
{
|
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"auditor",
|
|
||||||
"TINY_AMOUNT");
|
|
||||||
global_ret = 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_string_to_amount (tinys,
|
|
||||||
&tiny_amount))
|
&tiny_amount))
|
||||||
{
|
{
|
||||||
GNUNET_free (tinys);
|
|
||||||
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"auditor",
|
"auditor",
|
||||||
"TINY_AMOUNT",
|
"TINY_AMOUNT",
|
||||||
@ -2136,7 +2124,6 @@ run (void *cls,
|
|||||||
global_ret = 1;
|
global_ret = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GNUNET_free (tinys);
|
|
||||||
if (0 == GNUNET_memcmp (&zeromp,
|
if (0 == GNUNET_memcmp (&zeromp,
|
||||||
&master_pub))
|
&master_pub))
|
||||||
{
|
{
|
||||||
|
@ -163,6 +163,11 @@ struct CoinTypeParams
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configured currency.
|
||||||
|
*/
|
||||||
|
static char *currency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filename of the master private key.
|
* Filename of the master private key.
|
||||||
*/
|
*/
|
||||||
@ -987,7 +992,6 @@ create_wire_fee_for_method (void *cls,
|
|||||||
{
|
{
|
||||||
struct TALER_EXCHANGEDB_AggregateFees *af;
|
struct TALER_EXCHANGEDB_AggregateFees *af;
|
||||||
char *opt;
|
char *opt;
|
||||||
char *amounts;
|
|
||||||
|
|
||||||
GNUNET_snprintf (yearstr,
|
GNUNET_snprintf (yearstr,
|
||||||
sizeof (yearstr),
|
sizeof (yearstr),
|
||||||
@ -1002,68 +1006,44 @@ create_wire_fee_for_method (void *cls,
|
|||||||
GNUNET_asprintf (&opt,
|
GNUNET_asprintf (&opt,
|
||||||
"wire-fee-%u",
|
"wire-fee-%u",
|
||||||
year);
|
year);
|
||||||
if (GNUNET_OK !=
|
if ( (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (kcfg,
|
TALER_config_get_amount (kcfg,
|
||||||
section,
|
section,
|
||||||
opt,
|
opt,
|
||||||
&amounts))
|
&af->wire_fee)) ||
|
||||||
{
|
(0 != strcasecmp (currency,
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
af->wire_fee.currency)) )
|
||||||
section,
|
|
||||||
opt);
|
|
||||||
*ret = GNUNET_SYSERR;
|
|
||||||
GNUNET_free (opt);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_string_to_amount (amounts,
|
|
||||||
&af->wire_fee))
|
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Invalid amount `%s' specified in `%s' under `%s'\n",
|
"Invalid or missing amount in `%s' under `%s'\n",
|
||||||
amounts,
|
|
||||||
wiremethod,
|
wiremethod,
|
||||||
opt);
|
opt);
|
||||||
*ret = GNUNET_SYSERR;
|
*ret = GNUNET_SYSERR;
|
||||||
GNUNET_free (amounts);
|
|
||||||
GNUNET_free (opt);
|
GNUNET_free (opt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GNUNET_free (amounts);
|
|
||||||
GNUNET_free (opt);
|
GNUNET_free (opt);
|
||||||
|
|
||||||
/* handle closing fee */
|
/* handle closing fee */
|
||||||
GNUNET_asprintf (&opt,
|
GNUNET_asprintf (&opt,
|
||||||
"closing-fee-%u",
|
"closing-fee-%u",
|
||||||
year);
|
year);
|
||||||
if (GNUNET_OK !=
|
if ( (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (kcfg,
|
TALER_config_get_amount (kcfg,
|
||||||
section,
|
section,
|
||||||
opt,
|
opt,
|
||||||
&amounts))
|
&af->closing_fee)) ||
|
||||||
{
|
(0 != strcasecmp (currency,
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
af->wire_fee.currency)) )
|
||||||
section,
|
|
||||||
opt);
|
|
||||||
*ret = GNUNET_SYSERR;
|
|
||||||
GNUNET_free (opt);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_string_to_amount (amounts,
|
|
||||||
&af->closing_fee))
|
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Invalid amount `%s' specified in `%s' under `%s'\n",
|
"Invalid or missing amount in `%s' under `%s'\n",
|
||||||
amounts,
|
|
||||||
wiremethod,
|
wiremethod,
|
||||||
opt);
|
opt);
|
||||||
*ret = GNUNET_SYSERR;
|
*ret = GNUNET_SYSERR;
|
||||||
GNUNET_free (amounts);
|
|
||||||
GNUNET_free (opt);
|
GNUNET_free (opt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GNUNET_free (amounts);
|
|
||||||
|
|
||||||
GNUNET_free (opt);
|
GNUNET_free (opt);
|
||||||
sign_af (af,
|
sign_af (af,
|
||||||
@ -1193,6 +1173,18 @@ run (void *cls,
|
|||||||
(void) cfgfile;
|
(void) cfgfile;
|
||||||
kcfg = cfg;
|
kcfg = cfg;
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
|
"taler",
|
||||||
|
"CURRENCY",
|
||||||
|
¤cy))
|
||||||
|
{
|
||||||
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"taler",
|
||||||
|
"CURRENCY");
|
||||||
|
global_ret = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (now.abs_value_us != now_tmp.abs_value_us)
|
if (now.abs_value_us != now_tmp.abs_value_us)
|
||||||
{
|
{
|
||||||
/* The user gave "--now", use it */
|
/* The user gave "--now", use it */
|
||||||
|
@ -603,28 +603,16 @@ exchange_serve_process_config ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
char *rounding_str;
|
if ( (GNUNET_OK !=
|
||||||
if (GNUNET_OK !=
|
TALER_config_get_amount (cfg,
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
||||||
"taler",
|
"taler",
|
||||||
"CURRENCY_ROUND_UNIT",
|
"CURRENCY_ROUND_UNIT",
|
||||||
&rounding_str))
|
¤cy_round_unit)) ||
|
||||||
{
|
( (0 != currency_round_unit.fraction) &&
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
(0 != currency_round_unit.value) ) )
|
||||||
"No [taler]/CURRENCY_ROUND_UNIT specified, defaulting to '0.01'.\n");
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
|
||||||
TALER_amount_get_zero (exchange_currency_string,
|
|
||||||
¤cy_round_unit));
|
|
||||||
currency_round_unit.fraction = TALER_AMOUNT_FRAC_BASE / 100;
|
|
||||||
}
|
|
||||||
else if (GNUNET_OK !=
|
|
||||||
TALER_string_to_amount (rounding_str,
|
|
||||||
¤cy_round_unit))
|
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Invalid amount `%s' specified in `TALER' under `CURRENCY_ROUND_UNIT'\n",
|
"Invalid value specified in `TALER' under `CURRENCY_ROUND_UNIT'\n");
|
||||||
rounding_str);
|
|
||||||
GNUNET_free (rounding_str);
|
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ TALER_TEST_HOME = test_taler_exchange_httpd_home/
|
|||||||
[taler]
|
[taler]
|
||||||
# Currency supported by the exchange (can only be one)
|
# Currency supported by the exchange (can only be one)
|
||||||
CURRENCY = EUR
|
CURRENCY = EUR
|
||||||
|
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||||
|
|
||||||
[exchange]
|
[exchange]
|
||||||
# The DB plugin to use
|
# The DB plugin to use
|
||||||
|
@ -5,6 +5,7 @@ TALER_TEST_HOME = test_taler_exchange_httpd_home/
|
|||||||
[taler]
|
[taler]
|
||||||
# Currency supported by the exchange (can only be one)
|
# Currency supported by the exchange (can only be one)
|
||||||
CURRENCY = EUR
|
CURRENCY = EUR
|
||||||
|
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||||
|
|
||||||
[exchange]
|
[exchange]
|
||||||
# The DB plugin to use
|
# The DB plugin to use
|
||||||
@ -101,4 +102,3 @@ fee_deposit = EUR:0.00
|
|||||||
fee_refresh = EUR:0.01
|
fee_refresh = EUR:0.01
|
||||||
fee_refund = EUR:0.01
|
fee_refund = EUR:0.01
|
||||||
rsa_keysize = 1024
|
rsa_keysize = 1024
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ TALER_TEST_HOME = test_exchange_api_home/
|
|||||||
[taler]
|
[taler]
|
||||||
# Currency supported by the exchange (can only be one)
|
# Currency supported by the exchange (can only be one)
|
||||||
CURRENCY = EUR
|
CURRENCY = EUR
|
||||||
|
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||||
|
|
||||||
[auditor]
|
[auditor]
|
||||||
BASE_URL = "http://localhost:8083/"
|
BASE_URL = "http://localhost:8083/"
|
||||||
|
@ -9,6 +9,7 @@ TALER_TEST_HOME = test_exchange_api_home/
|
|||||||
[taler]
|
[taler]
|
||||||
# Currency supported by the exchange (can only be one)
|
# Currency supported by the exchange (can only be one)
|
||||||
CURRENCY = EUR
|
CURRENCY = EUR
|
||||||
|
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||||
|
|
||||||
[auditor]
|
[auditor]
|
||||||
BASE_URL = "http://localhost:8083/"
|
BASE_URL = "http://localhost:8083/"
|
||||||
|
@ -9,6 +9,7 @@ TALER_TEST_HOME = test_exchange_api_home/
|
|||||||
[taler]
|
[taler]
|
||||||
# Currency supported by the exchange (can only be one)
|
# Currency supported by the exchange (can only be one)
|
||||||
CURRENCY = EUR
|
CURRENCY = EUR
|
||||||
|
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||||
|
|
||||||
|
|
||||||
[exchange]
|
[exchange]
|
||||||
|
Loading…
Reference in New Issue
Block a user