gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: implement #6942: switch UUIDs to


From: gnunet
Subject: [taler-merchant] branch master updated: implement #6942: switch UUIDs to strings
Date: Sun, 01 Aug 2021 11:43:35 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 42d323d4 implement #6942: switch UUIDs to strings
42d323d4 is described below

commit 42d323d4344c748e1e793a606646c932d998cb47
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Aug 1 11:42:28 2021 +0200

    implement #6942: switch UUIDs to strings
---
 src/backend/taler-merchant-httpd_helper.c          | 24 +++++++++++++++++++++-
 src/backend/taler-merchant-httpd_helper.h          | 11 ++++++++++
 .../taler-merchant-httpd_private-post-orders.c     |  7 +++++--
 ...-merchant-httpd_private-post-products-ID-lock.c | 10 +++++----
 .../share/taler/exchange-offline/master.priv       |  1 -
 5 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_helper.c 
b/src/backend/taler-merchant-httpd_helper.c
index 0120b7b3..cc6288f9 100644
--- a/src/backend/taler-merchant-httpd_helper.c
+++ b/src/backend/taler-merchant-httpd_helper.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  (C) 2014--2020 Taler Systems SA
+  (C) 2014--2021 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Lesser General Public License as published by the Free 
Software
@@ -224,3 +224,25 @@ TMH_check_auth_config (struct MHD_Connection *connection,
   }
   return GNUNET_OK;
 }
+
+
+/**
+ * Generate binary UUID from client-provided UUID-string.
+ *
+ * @param uuids string intpu
+ * @param[out] uuid set to binary UUID
+ */
+void
+TMH_uuid_from_string (const char *uuids,
+                      struct GNUNET_Uuid *uuid)
+{
+  struct GNUNET_HashCode hc;
+
+  GNUNET_CRYPTO_hash (uuids,
+                      strlen (uuids),
+                      &hc);
+  GNUNET_static_assert (sizeof (hc) > sizeof (*uuid));
+  memcpy (uuid,
+          &hc,
+          sizeof (*uuid));
+}
diff --git a/src/backend/taler-merchant-httpd_helper.h 
b/src/backend/taler-merchant-httpd_helper.h
index 0460665b..cc5b3013 100644
--- a/src/backend/taler-merchant-httpd_helper.h
+++ b/src/backend/taler-merchant-httpd_helper.h
@@ -76,4 +76,15 @@ TMH_check_auth_config (struct MHD_Connection *connection,
                        const char **auth_token);
 
 
+/**
+ * Generate binary UUID from client-provided UUID-string.
+ *
+ * @param uuids string intpu
+ * @param[out] uuid set to binary UUID
+ */
+void
+TMH_uuid_from_string (const char *uuids,
+                      struct GNUNET_Uuid *uuid);
+
+
 #endif
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c 
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 8a0ca347..22e6327f 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1443,9 +1443,10 @@ TMH_private_post_orders (const struct TMH_RequestHandler 
*rh,
     {
       const char *error_name;
       unsigned int error_line;
+      const char *uuidsi;
       struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_fixed_auto ("uuid",
-                                     &uuids[i]),
+        GNUNET_JSON_spec_string ("uuid",
+                                 &uuidsi),
         GNUNET_JSON_spec_end ()
       };
 
@@ -1474,6 +1475,8 @@ TMH_private_post_orders (const struct TMH_RequestHandler 
*rh,
                                            
TALER_EC_GENERIC_PARAMETER_MALFORMED,
                                            "lock_uuids");
       }
+      TMH_uuid_from_string (uuidsi,
+                            &uuids[i]);
     }
   }
 
diff --git a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c 
b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c
index 0fae6023..7fc7b0ac 100644
--- a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c
+++ b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  (C) 2020 Taler Systems SA
+  (C) 2020, 2021 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as
@@ -35,12 +35,13 @@ TMH_private_post_products_ID_lock (const struct 
TMH_RequestHandler *rh,
   struct TMH_MerchantInstance *mi = hc->instance;
   const char *product_id = hc->infix;
   enum GNUNET_DB_QueryStatus qs;
+  const char *uuids;
   struct GNUNET_Uuid uuid;
   uint32_t quantity;
   struct GNUNET_TIME_Relative duration;
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_fixed_auto ("lock_uuid",
-                                 &uuid), // FIXME: use string?
+    GNUNET_JSON_spec_string ("lock_uuid",
+                             &uuids),
     TALER_JSON_spec_relative_time ("duration",
                                    &duration),
     GNUNET_JSON_spec_uint32 ("quantity",
@@ -61,7 +62,8 @@ TMH_private_post_products_ID_lock (const struct 
TMH_RequestHandler *rh,
              ? MHD_YES
              : MHD_NO;
   }
-
+  TMH_uuid_from_string (uuids,
+                        &uuid);
   qs = TMH_db->lock_product (TMH_db->cls,
                              mi->settings.id,
                              product_id,
diff --git 
a/src/testing/test_reducer_home/.local/share/taler/exchange-offline/master.priv 
b/src/testing/test_reducer_home/.local/share/taler/exchange-offline/master.priv
deleted file mode 100644
index b442413a..00000000
--- 
a/src/testing/test_reducer_home/.local/share/taler/exchange-offline/master.priv
+++ /dev/null
@@ -1 +0,0 @@
-�(��3����w�
c �˚R9��`>B�
\ No newline at end of file

-- 
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]