gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: double melt test no works with a


From: gnunet
Subject: [taler-exchange] branch master updated: double melt test no works with age restriction
Date: Tue, 22 Feb 2022 18:36:58 +0100

This is an automated email from the git hooks/post-receive script.

oec pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 7910ca18 double melt test no works with age restriction
7910ca18 is described below

commit 7910ca183f40a544dae4add5e7b5ff4775e65e12
Author: Özgür Kesim <oec-taler@kesim.org>
AuthorDate: Tue Feb 22 18:35:10 2022 +0100

    double melt test no works with age restriction
    
    - added missing field h_age_commitment in exchange's error response
    - slight refactoring
---
 src/exchange/taler-exchange-httpd_responses.c |  5 ++++-
 src/exchangedb/plugin_exchangedb_postgres.c   | 12 +++--------
 src/include/taler_crypto_lib.h                |  5 +++++
 src/include/taler_exchangedb_plugin.h         | 10 +++++++++
 src/lib/exchange_api_common.c                 | 30 +++++++++++++++------------
 src/testing/test_exchange_api.c               |  2 --
 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 9007e9d9..d4da5162 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 2f59401c..c80f3370 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 a49b9eb5..ed447e90 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -1055,6 +1055,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 529d4943..dfe9ab7f 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1126,6 +1126,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.
@@ -1321,6 +1326,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
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index b7a43bbc..160f62dc 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 b6dd39c8..46419193 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 ()
   };
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]