commit a5ee672256b1c362b67b6d9ed1a08f2e00ac133a
parent afdccca78c95fe863f43614c92e4288a6bd79024
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Fri, 22 Dec 2023 14:54:48 +0800
deprecating currency code in currency specifications
Diffstat:
6 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_config.h b/src/exchange/taler-exchange-httpd_config.h
@@ -41,7 +41,7 @@
*
* Returned via both /config and /keys endpoints.
*/
-#define EXCHANGE_PROTOCOL_VERSION "17:1:0"
+#define EXCHANGE_PROTOCOL_VERSION "18:0:1"
/**
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
@@ -234,12 +234,14 @@ TALER_JSON_spec_amount (const char *name,
* a currency specification.
*
* @param name name of the amount field in the JSON
+ * @param currency_code currency code to parse
* @param[out] r_cspec where the currency spec has to be written
* @return spec for parsing an amount
*/
struct GNUNET_JSON_Specification
TALER_JSON_spec_currency_specification (
const char *name,
+ const char *currency_code,
struct TALER_CurrencySpecification *r_cspec);
diff --git a/src/include/taler_util.h b/src/include/taler_util.h
@@ -215,7 +215,7 @@ TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
struct TALER_CurrencySpecification
{
/**
- * Name of the currency.
+ * Currency code of the currency.
*/
char currency[TALER_CURRENCY_LEN];
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
@@ -162,15 +162,13 @@ parse_cspec (void *cls,
struct GNUNET_JSON_Specification *spec)
{
struct TALER_CurrencySpecification *r_cspec = spec->ptr;
+ const char *currency = spec->cls;
const char *name;
- const char *currency;
uint32_t fid;
uint32_t fnd;
uint32_t ftzd;
const json_t *map;
struct GNUNET_JSON_Specification gspec[] = {
- GNUNET_JSON_spec_string ("currency",
- ¤cy),
GNUNET_JSON_spec_string ("name",
&name),
GNUNET_JSON_spec_uint32 ("num_fractional_input_digits",
@@ -257,12 +255,13 @@ clean_cspec (void *cls,
struct GNUNET_JSON_Specification
TALER_JSON_spec_currency_specification (
const char *name,
+ const char *currency,
struct TALER_CurrencySpecification *r_cspec)
{
struct GNUNET_JSON_Specification ret = {
.parser = &parse_cspec,
.cleaner = &clean_cspec,
- .cls = NULL,
+ .cls = currency,
.field = name,
.ptr = r_cspec,
.ptr_size = 0,
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
@@ -850,9 +850,6 @@ decode_keys_json (const json_t *resp_obj,
GNUNET_JSON_spec_string (
"currency",
¤cy),
- TALER_JSON_spec_currency_specification (
- "currency_specification",
- &key_data->cspec),
GNUNET_JSON_spec_string (
"asset_type",
&asset_type),
@@ -913,6 +910,10 @@ decode_keys_json (const json_t *resp_obj,
}
{
struct GNUNET_JSON_Specification sspec[] = {
+ TALER_JSON_spec_currency_specification (
+ "currency_specification",
+ currency,
+ &key_data->cspec),
TALER_JSON_spec_amount (
"stefan_abs",
currency,
diff --git a/src/util/config.c b/src/util/config.c
@@ -477,6 +477,8 @@ TALER_CONFIG_currency_specs_to_json (const struct
return GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("name",
cspec->name),
+ /* 'currency' is deprecated as of exchange v18 and merchant v6;
+ remove this line once current-age > 6*/
GNUNET_JSON_pack_string ("currency",
cspec->currency),
GNUNET_JSON_pack_uint64 ("num_fractional_input_digits",