aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2022-02-22 18:35:10 +0100
committerÖzgür Kesim <oec-taler@kesim.org>2022-02-22 18:35:10 +0100
commit7910ca183f40a544dae4add5e7b5ff4775e65e12 (patch)
treec7ea92bc5f255c94f17e8359a2cc611c1b1ec872 /src
parentfbdc1996a6166893415c59ed830e75a8ccf79a51 (diff)
double melt test no works with age restriction
- added missing field h_age_commitment in exchange's error response - slight refactoring
Diffstat (limited to 'src')
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c5
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c12
-rw-r--r--src/include/taler_crypto_lib.h5
-rw-r--r--src/include/taler_exchangedb_plugin.h10
-rw-r--r--src/lib/exchange_api_common.c30
-rw-r--r--src/testing/test_exchange_api.c2
6 files changed, 39 insertions, 25 deletions
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 9007e9d9f..d4da51621 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -111,6 +111,9 @@ TEH_RESPONSE_compile_transaction_history (
GNUNET_JSON_pack_data_auto ("h_denom_pub",
&deposit->h_denom_pub),
GNUNET_JSON_pack_allow_null (
+ deposit->no_age_commitment ?
+ GNUNET_JSON_pack_string (
+ "h_age_commitment", NULL) :
GNUNET_JSON_pack_data_auto ("h_age_commitment",
&deposit->h_age_commitment)),
GNUNET_JSON_pack_data_auto ("coin_sig",
@@ -146,7 +149,7 @@ TEH_RESPONSE_compile_transaction_history (
/* Age restriction is optional. We communicate a NULL value to
* JSON_PACK below */
- if (! TALER_AgeCommitmentHash_isNullOrZero (&melt->h_age_commitment))
+ if (! melt->no_age_commitment)
phac = &melt->h_age_commitment;
if (0 !=
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 2f59401c6..c80f33707 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -5644,14 +5644,13 @@ postgres_get_known_coin (void *cls,
GNUNET_PQ_query_param_auto_from_type (coin_pub),
GNUNET_PQ_query_param_end
};
- bool is_null;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
&coin_info->denom_pub_hash),
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash",
&coin_info->h_age_commitment),
- &is_null),
+ &coin_info->no_age_commitment),
TALER_PQ_result_spec_denom_sig ("denom_sig",
&coin_info->denom_sig),
GNUNET_PQ_result_spec_end
@@ -6590,7 +6589,6 @@ add_coin_deposit (void *cls,
struct TALER_EXCHANGEDB_DepositListEntry *deposit;
struct TALER_EXCHANGEDB_TransactionList *tl;
uint64_t serial_id;
- bool is_null;
chc->have_deposit_or_melt = true;
deposit = GNUNET_new (struct TALER_EXCHANGEDB_DepositListEntry);
@@ -6605,7 +6603,7 @@ add_coin_deposit (void *cls,
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash",
&deposit->h_age_commitment),
- &is_null),
+ &deposit->no_age_commitment),
GNUNET_PQ_result_spec_timestamp ("wallet_timestamp",
&deposit->timestamp),
GNUNET_PQ_result_spec_timestamp ("refund_deadline",
@@ -6671,7 +6669,6 @@ add_coin_melt (void *cls,
struct TALER_EXCHANGEDB_MeltListEntry *melt;
struct TALER_EXCHANGEDB_TransactionList *tl;
uint64_t serial_id;
- bool hac_isnull;
chc->have_deposit_or_melt = true;
melt = GNUNET_new (struct TALER_EXCHANGEDB_MeltListEntry);
@@ -6691,7 +6688,7 @@ add_coin_melt (void *cls,
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type ("h_age_commitment",
&melt->h_age_commitment),
- &hac_isnull),
+ &melt->no_age_commitment),
GNUNET_PQ_result_spec_uint64 ("melt_serial_id",
&serial_id),
GNUNET_PQ_result_spec_end
@@ -6708,9 +6705,6 @@ add_coin_melt (void *cls,
return;
}
- if (hac_isnull)
- memset (&melt->h_age_commitment, 0, sizeof(melt->h_age_commitment));
-
}
tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList);
tl->next = chc->head;
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index a49b9eb5f..ed447e905 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -1056,6 +1056,11 @@ struct TALER_CoinPublicInfo
struct TALER_AgeCommitmentHash h_age_commitment;
/**
+ * True, if age commitment is not applicable.
+ */
+ bool no_age_commitment;
+
+ /**
* (Unblinded) signature over @e coin_pub with @e denom_pub,
* which demonstrates that the coin is valid.
*/
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index 529d49431..dfe9ab7fe 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1127,6 +1127,11 @@ struct TALER_EXCHANGEDB_DepositListEntry
struct TALER_AgeCommitmentHash h_age_commitment;
/**
+ * true, if age commitment is not applicable
+ */
+ bool no_age_commitment;
+
+ /**
* Detailed information about the receiver for executing the transaction.
* URL in payto://-format.
*/
@@ -1322,6 +1327,11 @@ struct TALER_EXCHANGEDB_MeltListEntry
struct TALER_AgeCommitmentHash h_age_commitment;
/**
+ * true, if no h_age_commitment is applicable
+ */
+ bool no_age_commitment;
+
+ /**
* How much value is being melted? This amount includes the fees,
* so the final amount contributed to the melt is this value minus
* the fee for melting the coin. We include the fee in what is
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index b7a43bbc8..160f62dc6 100644
--- a/src/lib/exchange_api_common.c
+++ b/src/lib/exchange_api_common.c
@@ -477,7 +477,7 @@ TALER_EXCHANGE_verify_coin_history (
struct TALER_MerchantPublicKeyP merchant_pub;
struct GNUNET_TIME_Timestamp refund_deadline = {0};
struct TALER_CoinSpendSignatureP sig;
- struct TALER_AgeCommitmentHash *hac = NULL;
+ struct TALER_AgeCommitmentHash hac = {0};
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("coin_sig",
&sig),
@@ -487,6 +487,9 @@ TALER_EXCHANGE_verify_coin_history (
&h_wire),
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
h_denom_pub),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
+ &hac)),
GNUNET_JSON_spec_timestamp ("timestamp",
&wallet_timestamp),
GNUNET_JSON_spec_mark_optional (
@@ -508,18 +511,19 @@ TALER_EXCHANGE_verify_coin_history (
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
- TALER_wallet_deposit_verify (&amount,
- &fee,
- &h_wire,
- &h_contract_terms,
- hac,
- NULL /* h_extensions! */,
- h_denom_pub,
- wallet_timestamp,
- &merchant_pub,
- refund_deadline,
- coin_pub,
- &sig))
+ TALER_wallet_deposit_verify (
+ &amount,
+ &fee,
+ &h_wire,
+ &h_contract_terms,
+ TALER_AgeCommitmentHash_isNullOrZero (&hac) ? NULL : &hac,
+ NULL /* h_extensions! */,
+ h_denom_pub,
+ wallet_timestamp,
+ &merchant_pub,
+ refund_deadline,
+ coin_pub,
+ &sig))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c
index b6dd39c87..46419193d 100644
--- a/src/testing/test_exchange_api.c
+++ b/src/testing/test_exchange_api.c
@@ -644,7 +644,6 @@ run (void *cls,
GNUNET_TIME_UNIT_ZERO,
"EUR:0.1",
MHD_HTTP_OK),
-#if 0 /* FIXME oec */
/* Test running a failing melt operation (same operation
* again must fail) */
TALER_TESTING_cmd_melt ("refresh-melt-failing-age",
@@ -658,7 +657,6 @@ run (void *cls,
MHD_HTTP_CONFLICT,
NULL),
-#endif
TALER_TESTING_cmd_end ()
};