gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated (5ed3b2cf -> 6f608fbc)


From: gnunet
Subject: [taler-merchant] branch master updated (5ed3b2cf -> 6f608fbc)
Date: Wed, 12 Apr 2023 13:18:44 +0200

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

grothoff pushed a change to branch master
in repository merchant.

    from 5ed3b2cf store user-type with merchant settings
     new 69684b2f wirewatch skeleton
     new 6f608fbc wirewatch skeleton: debian service

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...aler-merchant.taler-merchant-wirewatch.service} |   4 +-
 src/backend/Makefile.am                            |  21 ++-
 src/backend/taler-merchant-wirewatch.c             | 208 +++++++++++++++++++++
 3 files changed, 230 insertions(+), 3 deletions(-)
 copy debian/{taler-merchant.taler-merchant-webhook.service => 
taler-merchant.taler-merchant-wirewatch.service} (55%)
 create mode 100644 src/backend/taler-merchant-wirewatch.c

diff --git a/debian/taler-merchant.taler-merchant-webhook.service 
b/debian/taler-merchant.taler-merchant-wirewatch.service
similarity index 55%
copy from debian/taler-merchant.taler-merchant-webhook.service
copy to debian/taler-merchant.taler-merchant-wirewatch.service
index 0e3e0c60..5cf6c8c7 100644
--- a/debian/taler-merchant.taler-merchant-webhook.service
+++ b/debian/taler-merchant.taler-merchant-wirewatch.service
@@ -1,5 +1,5 @@
 [Unit]
-Description=GNU Taler payment system merchant backend webhook trigger service
+Description=GNU Taler payment system merchant bank transfer import service
 After=postgres.service
 
 [Service]
@@ -7,7 +7,7 @@ User=taler-merchant-httpd
 Type=simple
 Restart=always
 RestartSec=1s
-ExecStart=/usr/bin/taler-merchant-webhook -c /etc/taler/taler.conf
+ExecStart=/usr/bin/taler-merchant-wirewatch -c /etc/taler/taler.conf
 PrivateTmp=yes
 PrivateDevices=yes
 ProtectSystem=full
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index c6b99bfc..21ff7907 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -17,7 +17,8 @@ EXTRA_DIST = \
 
 bin_PROGRAMS = \
   taler-merchant-httpd \
-  taler-merchant-webhook
+  taler-merchant-webhook \
+  taler-merchant-wirewatch
 
 taler_merchant_httpd_SOURCES = \
   taler-merchant-httpd.c taler-merchant-httpd.h \
@@ -171,3 +172,21 @@ taler_merchant_webhook_LDADD = \
   $(XLIB)
 taler_merchant_webhook_CFLAGS = \
   $(AM_CFLAGS)
+
+
+taler_merchant_wirewatch_SOURCES = \
+  taler-merchant-wirewatch.c
+taler_merchant_wirewatch_LDADD = \
+  $(top_builddir)/src/backenddb/libtalermerchantdb.la \
+  -ltalermhd \
+  -ltalerjson \
+  -ltalerutil \
+  -ltalerpq \
+  -ljansson \
+  -lgnunetcurl \
+  -lgnunetjson \
+  -lgnunetutil \
+  -lcurl \
+  $(XLIB)
+taler_merchant_wirewatch_CFLAGS = \
+  $(AM_CFLAGS)
diff --git a/src/backend/taler-merchant-wirewatch.c 
b/src/backend/taler-merchant-wirewatch.c
new file mode 100644
index 00000000..a771c736
--- /dev/null
+++ b/src/backend/taler-merchant-wirewatch.c
@@ -0,0 +1,208 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2023 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-merchant-wirewatch.c
+ * @brief Process that imports information about incoming bank transfers into 
the merchant backend
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <jansson.h>
+#include <pthread.h>
+#include "taler_merchantdb_lib.h"
+#include "taler_merchantdb_plugin.h"
+
+
+/**
+ * The merchant's configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+/**
+ * Our database plugin.
+ */
+static struct TALER_MERCHANTDB_Plugin *db_plugin;
+
+/**
+ * Next task to run, if any.
+ */
+static struct GNUNET_SCHEDULER_Task *task;
+
+/**
+ * Handle to the context for interacting with the bank.
+ */
+static struct GNUNET_CURL_Context *ctx;
+
+/**
+ * Scheduler context for running the @e ctx.
+ */
+static struct GNUNET_CURL_RescheduleContext *rc;
+
+/**
+ * Value to return from main(). 0 on success, non-zero on errors.
+ */
+static int global_ret;
+
+/**
+ * #GNUNET_YES if we are in test mode and should exit when idle.
+ */
+static int test_mode;
+
+
+/**
+ * We're being aborted with CTRL-C (or SIGTERM). Shut down.
+ *
+ * @param cls closure
+ */
+static void
+shutdown_task (void *cls)
+{
+  (void) cls;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Running shutdown\n");
+  if (NULL != task)
+  {
+    GNUNET_SCHEDULER_cancel (task);
+    task = NULL;
+  }
+  db_plugin->rollback (db_plugin->cls); /* just in case */
+  TALER_MERCHANTDB_plugin_unload (db_plugin);
+  db_plugin = NULL;
+  cfg = NULL;
+  if (NULL != ctx)
+  {
+    GNUNET_CURL_fini (ctx);
+    ctx = NULL;
+  }
+  if (NULL != rc)
+  {
+    GNUNET_CURL_gnunet_rc_destroy (rc);
+    rc = NULL;
+  }
+}
+
+
+/**
+ * Run next iteration.
+ *
+ * @param cls NULL
+ */
+static void
+do_work (void *cls);
+
+
+static void
+do_work (void *cls)
+{
+  (void) cls;
+  task = NULL;
+}
+
+
+/**
+ * First task.
+ *
+ * @param cls closure, NULL
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
+ * @param c configuration
+ */
+static void
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *c)
+{
+  (void) args;
+  (void) cfgfile;
+
+  cfg = c;
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+                                 NULL);
+  ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
+                          &rc);
+  rc = GNUNET_CURL_gnunet_rc_create (ctx);
+  if (NULL == ctx)
+  {
+    GNUNET_break (0);
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+  if (NULL ==
+      (db_plugin = TALER_MERCHANTDB_plugin_load (cfg)))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to initialize DB subsystem\n");
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+  if (GNUNET_OK !=
+      db_plugin->connect (db_plugin->cls))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to connect to database\n");
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+  GNUNET_assert (NULL == task);
+  task = GNUNET_SCHEDULER_add_now (&do_work,
+                                   NULL);
+}
+
+
+/**
+ * The main function of taler-merchant-wirewatch
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc,
+      char *const *argv)
+{
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_option_flag ('t',
+                               "test",
+                               "run in test mode and exit when idle",
+                               &test_mode),
+    GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION),
+    GNUNET_GETOPT_OPTION_END
+  };
+  enum GNUNET_GenericReturnValue ret;
+
+  if (GNUNET_OK !=
+      GNUNET_STRINGS_get_utf8_args (argc, argv,
+                                    &argc, &argv))
+    return EXIT_INVALIDARGUMENT;
+  TALER_OS_init ();
+  ret = GNUNET_PROGRAM_run (
+    argc, argv,
+    "taler-merchant-wirewatch",
+    gettext_noop (
+      "background process that watches for incoming wire transfers to the 
merchant bank account"),
+    options,
+    &run, NULL);
+  GNUNET_free_nz ((void *) argv);
+  if (GNUNET_SYSERR == ret)
+    return EXIT_INVALIDARGUMENT;
+  if (GNUNET_NO == ret)
+    return EXIT_SUCCESS;
+  return global_ret;
+}
+
+
+/* end of taler-exchange-wirewatch.c */

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