summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2022-06-27 10:36:13 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2022-06-27 10:36:13 +0200
commit5633ad5a26d435c32b0df2b757950c416c6faaec (patch)
tree3937f9f21f394ffbf6798f7561e054f8367710ba
parenta6544069f98fdbfce4ac215dd5f0ee0660469c2c (diff)
downloadexchange-5633ad5a26d435c32b0df2b757950c416c6faaec.tar.gz
exchange-5633ad5a26d435c32b0df2b757950c416c6faaec.tar.bz2
exchange-5633ad5a26d435c32b0df2b757950c416c6faaec.zip
better api for parsing a denomination group
-rw-r--r--src/exchange/taler-exchange-httpd_keys.c2
-rw-r--r--src/include/taler_json_lib.h8
-rw-r--r--src/json/json_helper.c8
-rw-r--r--src/lib/exchange_api_handle.c4
4 files changed, 12 insertions, 10 deletions
diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c
index ee80dcf9..fcdfe119 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -2190,6 +2190,8 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
.age_mask = dk->meta.age_mask,
};
+ memset (&meta.hash, 0, sizeof(meta.hash));
+
/* Search the group/JSON-blob for the key */
GNUNET_CRYPTO_hash (&meta, sizeof(meta), &key);
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index 0b58b43d..1300f875 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -375,9 +375,6 @@ struct TALER_DenominationGroup
struct TALER_DenomFeeSet fees;
struct TALER_AgeMask age_mask;
- // currency must be set prior to calling TALER_JSON_spec_denomination_group
- const char *currency;
-
// hash is/should be the XOR of all SHA-512 hashes of the public keys in this
// group
struct GNUNET_HashCode hash;
@@ -385,14 +382,15 @@ struct TALER_DenominationGroup
/**
* Generate a parser for a group of denominations.
- * NOTE: group.currency MUST have been set prior to calling this function.
*
- * @param field name of the field, maybe NULL
+ * @param[in] field name of the field, maybe NULL
+ * @param[in] currency name of the currency
* @param[out] group denomination group information
* @return corresponding field spec
*/
struct GNUNET_JSON_Specification
TALER_JSON_spec_denomination_group (const char *field,
+ const char *currency,
struct TALER_DenominationGroup *group);
/**
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index b29a49b3..202caf6f 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -250,16 +250,17 @@ parse_denomination_group (void *cls,
{
struct TALER_DenominationGroup *group = spec->ptr;
const char *cipher;
+ const char *currency = cls;
bool age_mask_missing = false;
bool has_age_restricted_suffix = false;
struct GNUNET_JSON_Specification gspec[] = {
GNUNET_JSON_spec_string ("cipher",
&cipher),
TALER_JSON_spec_amount ("value",
- group->currency,
+ currency,
&group->value),
TALER_JSON_SPEC_DENOM_FEES ("fee",
- group->currency,
+ currency,
&group->fees),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("age_mask",
@@ -307,9 +308,11 @@ parse_denomination_group (void *cls,
struct GNUNET_JSON_Specification
TALER_JSON_spec_denomination_group (const char *name,
+ const char *currency,
struct TALER_DenominationGroup *group)
{
struct GNUNET_JSON_Specification ret = {
+ .cls = (void *) currency,
.parser = &parse_denomination_group,
.cleaner = NULL,
.field = name,
@@ -318,7 +321,6 @@ TALER_JSON_spec_denomination_group (const char *name,
.size_ptr = NULL,
};
-
return ret;
}
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index c690c352..f7865af7 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -952,9 +952,9 @@ decode_keys_json (const json_t *resp_obj,
// First, parse { cipher, fees, value, age_mask, hash } of the current
// group.
- struct TALER_DenominationGroup group = { .currency = currency };
+ struct TALER_DenominationGroup group = {0};
struct GNUNET_JSON_Specification group_spec[] = {
- TALER_JSON_spec_denomination_group (NULL, &group),
+ TALER_JSON_spec_denomination_group (NULL, currency, &group),
GNUNET_JSON_spec_end ()
};
EXITIF (GNUNET_SYSERR ==