gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -first sketch for purse delete h


From: gnunet
Subject: [taler-exchange] branch master updated: -first sketch for purse delete handler
Date: Tue, 27 Dec 2022 22:01:52 +0100

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 9facc2d3 -first sketch for purse delete handler
9facc2d3 is described below

commit 9facc2d3811be421f0ad4a2a3b3be4f266efb904
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Dec 27 22:01:48 2022 +0100

    -first sketch for purse delete handler
---
 contrib/gana                                      |   2 +-
 src/exchange/Makefile.am                          |   1 +
 src/exchange/taler-exchange-httpd.c               |   1 +
 src/exchange/taler-exchange-httpd_purses_delete.c | 129 ++++++++++++++++++++++
 src/exchange/taler-exchange-httpd_purses_delete.h |  42 +++++++
 src/include/taler_exchangedb_plugin.h             |   2 +-
 6 files changed, 175 insertions(+), 2 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index 3a0709c6..f603a795 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 3a0709c68490ba3c5612cdb1da36ee298097ebce
+Subproject commit f603a795963748040e41693daceae343b3a972ed
diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am
index b2365eec..29596c38 100644
--- a/src/exchange/Makefile.am
+++ b/src/exchange/Makefile.am
@@ -155,6 +155,7 @@ taler_exchange_httpd_SOURCES = \
   taler-exchange-httpd_mhd.c taler-exchange-httpd_mhd.h \
   taler-exchange-httpd_purses_create.c taler-exchange-httpd_purses_create.h \
   taler-exchange-httpd_purses_deposit.c taler-exchange-httpd_purses_deposit.h \
+  taler-exchange-httpd_purses_delete.c taler-exchange-httpd_purses_delete.h \
   taler-exchange-httpd_purses_get.c taler-exchange-httpd_purses_get.h \
   taler-exchange-httpd_purses_merge.c taler-exchange-httpd_purses_merge.h \
   taler-exchange-httpd_recoup.c taler-exchange-httpd_recoup.h \
diff --git a/src/exchange/taler-exchange-httpd.c 
b/src/exchange/taler-exchange-httpd.c
index 691e1ef7..4b64dfd5 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -50,6 +50,7 @@
 #include "taler-exchange-httpd_purses_create.h"
 #include "taler-exchange-httpd_purses_deposit.h"
 #include "taler-exchange-httpd_purses_get.h"
+#include "taler-exchange-httpd_purses_delete.h"
 #include "taler-exchange-httpd_purses_merge.h"
 #include "taler-exchange-httpd_recoup.h"
 #include "taler-exchange-httpd_recoup-refresh.h"
diff --git a/src/exchange/taler-exchange-httpd_purses_delete.c 
b/src/exchange/taler-exchange-httpd_purses_delete.c
new file mode 100644
index 00000000..34ab11b5
--- /dev/null
+++ b/src/exchange/taler-exchange-httpd_purses_delete.c
@@ -0,0 +1,129 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2022 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 published by the Free 
Software
+  Foundation; either version 3, or (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more 
details.
+
+  You should have received a copy of the GNU Affero General Public License 
along with
+  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler-exchange-httpd_purses_delete.c
+ * @brief Handle DELETE /purses/$PID requests; parses the request and
+ *        verifies the signature before handing deletion to the database.
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_json_lib.h>
+#include <jansson.h>
+#include <microhttpd.h>
+#include "taler_json_lib.h"
+#include "taler_mhd_lib.h"
+#include "taler-exchange-httpd_common_deposit.h"
+#include "taler-exchange-httpd_purses_delete.h"
+#include "taler-exchange-httpd_responses.h"
+#include "taler_exchangedb_lib.h"
+#include "taler-exchange-httpd_keys.h"
+
+
+MHD_RESULT
+TEH_handler_purses_delete (
+  struct MHD_Connection *connection,
+  const struct TALER_PurseContractPublicKeyP *purse_pub)
+{
+  struct TALER_PurseContractSignatureP purse_sig;
+  bool found;
+  bool decided;
+
+  {
+    const char *sig;
+
+    sig = MHD_lookup_connection_value (connection,
+                                       MHD_HEADER_KIND,
+                                       "Taler-Purse-Signature");
+    if ( (NULL == sig) ||
+         (GNUNET_OK !=
+          GNUNET_STRINGS_string_to_data (sig,
+                                         strlen (sig),
+                                         &purse_sig,
+                                         sizeof (purse_sig))) )
+    {
+      GNUNET_break_op (0);
+      return TALER_MHD_reply_with_error (connection,
+                                         MHD_HTTP_BAD_REQUEST,
+                                         (NULL == sig)
+                                         ? TALER_EC_GENERIC_PARAMETER_MISSING
+                                         : 
TALER_EC_GENERIC_PARAMETER_MALFORMED,
+                                         "Taler-Purse-Signature");
+    }
+  }
+
+  if (GNUNET_OK !=
+      TALER_wallet_purse_delete_verify (purse_pub,
+                                        &purse_sig))
+  {
+    TALER_LOG_WARNING ("Invalid signature on /purses/$PID/delete request\n");
+    return TALER_MHD_reply_with_error (connection,
+                                       MHD_HTTP_FORBIDDEN,
+                                       
TALER_EC_EXCHANGE_PURSE_DELETE_SIGNATURE_INVALID,
+                                       NULL);
+  }
+  if (GNUNET_SYSERR ==
+      TEH_plugin->preflight (TEH_plugin->cls))
+  {
+    GNUNET_break (0);
+    return TALER_MHD_reply_with_error (connection,
+                                       MHD_HTTP_INTERNAL_SERVER_ERROR,
+                                       TALER_EC_GENERIC_DB_START_FAILED,
+                                       "preflight failure");
+  }
+
+  {
+    enum GNUNET_DB_QueryStatus qs;
+
+    qs = TEH_plugin->do_purse_delete (TEH_plugin->cls,
+                                      purse_pub,
+                                      &purse_sig,
+                                      &decided,
+                                      &found);
+    if (qs <= 0)
+    {
+      TALER_LOG_WARNING (
+        "Failed to store delete purse information in database\n");
+      return TALER_MHD_reply_with_error (connection,
+                                         MHD_HTTP_INTERNAL_SERVER_ERROR,
+                                         TALER_EC_GENERIC_DB_STORE_FAILED,
+                                         "purse delete");
+    }
+  }
+  if (! found)
+  {
+    return TALER_MHD_reply_with_ec (
+      connection,
+      TALER_EC_EXCHANGE_GENERIC_PURSE_UNKNOWN,
+      NULL);
+  }
+  if (decided)
+  {
+    return TALER_MHD_reply_with_ec (
+      connection,
+      TALER_EC_EXCHANGE_PURSE_DELETE_ALREADY_DECIDED,
+      NULL);
+  }
+  /* success */
+  return TALER_MHD_reply_static (connection,
+                                 MHD_HTTP_NO_CONTENT,
+                                 NULL,
+                                 NULL,
+                                 0);
+}
+
+
+/* end of taler-exchange-httpd_purses_delete.c */
diff --git a/src/exchange/taler-exchange-httpd_purses_delete.h 
b/src/exchange/taler-exchange-httpd_purses_delete.h
new file mode 100644
index 00000000..15da2163
--- /dev/null
+++ b/src/exchange/taler-exchange-httpd_purses_delete.h
@@ -0,0 +1,42 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2022 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 published by the Free 
Software
+  Foundation; either version 3, or (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more 
details.
+
+  You should have received a copy of the GNU Affero General Public License 
along with
+  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler-exchange-httpd_purses_delete.h
+ * @brief Handle DELETE /purses/$PID requests
+ * @author Christian Grothoff
+ */
+#ifndef TALER_EXCHANGE_HTTPD_PURSES_DELETE_H
+#define TALER_EXCHANGE_HTTPD_PURSES_DELETE_H
+
+#include <gnunet/gnunet_util_lib.h>
+#include <microhttpd.h>
+#include "taler-exchange-httpd.h"
+
+
+/**
+ * Handle a DELETE "/purses/$PURSE_PUB" request.
+ *
+ * @param connection the MHD connection to handle
+ * @param purse_pub public key of the purse
+ * @return MHD result code
+ */
+MHD_RESULT
+TEH_handler_purses_delete (
+  struct MHD_Connection *connection,
+  const struct TALER_PurseContractPublicKeyP *purse_pub);
+
+
+#endif
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 5dcad4f7..5a55b5c9 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -5950,7 +5950,7 @@ struct TALER_EXCHANGEDB_Plugin
     void *cls,
     const struct TALER_PurseContractPublicKeyP *purse_pub,
     const struct TALER_PurseContractSignatureP *purse_sig,
-    bool *dediced,
+    bool *decided,
     bool *found);
 
 

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