gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: -add exchange lookup to kyc hand


From: gnunet
Subject: [taler-merchant] branch master updated: -add exchange lookup to kyc handler (WiP)
Date: Sun, 10 Oct 2021 21:01:45 +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 3cc3a5d6 -add exchange lookup to kyc handler (WiP)
3cc3a5d6 is described below

commit 3cc3a5d6215a3ca4e85c4b44c9a4360739bc4b67
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Oct 10 21:01:43 2021 +0200

    -add exchange lookup to kyc handler (WiP)
---
 src/backend/taler-merchant-httpd_exchanges.c       |  2 +-
 src/backend/taler-merchant-httpd_exchanges.h       |  2 +-
 ...r-merchant-httpd_private-get-instances-ID-kyc.c | 71 +++++++++++++++++-----
 3 files changed, 58 insertions(+), 17 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_exchanges.c 
b/src/backend/taler-merchant-httpd_exchanges.c
index dbafcbfb..874c5ee0 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -1258,7 +1258,7 @@ accept_exchanges (void *cls,
 }
 
 
-int
+enum GNUNET_GenericReturnValue
 TMH_EXCHANGES_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   merchant_curl_ctx
diff --git a/src/backend/taler-merchant-httpd_exchanges.h 
b/src/backend/taler-merchant-httpd_exchanges.h
index 95488ca8..df68b9a5 100644
--- a/src/backend/taler-merchant-httpd_exchanges.h
+++ b/src/backend/taler-merchant-httpd_exchanges.h
@@ -43,7 +43,7 @@ extern json_t *TMH_trusted_exchanges;
  * @return number of trusted exchanges on success; #GNUNET_SYSERR upon error in
  *          parsing.
  */
-int
+enum GNUNET_GenericReturnValue
 TMH_EXCHANGES_init (const struct GNUNET_CONFIGURATION_Handle *cfg);
 
 
diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c 
b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
index 80f40815..92b3d6be 100644
--- a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
+++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
@@ -25,6 +25,7 @@
 #include "platform.h"
 #include "taler-merchant-httpd_private-get-instances-ID-kyc.h"
 #include "taler-merchant-httpd_helper.h"
+#include "taler-merchant-httpd_exchanges.h"
 #include <taler/taler_json_lib.h>
 
 
@@ -57,6 +58,11 @@ struct ExchangeKycRequest
    */
   struct ExchangeKycRequest *prev;
 
+  /**
+   * Find operation where we connect to the respective exchange.
+   */
+  struct TMH_EXCHANGES_FindOperation *fo;
+
   /**
    * KYC request this exchange request is made for.
    */
@@ -255,6 +261,11 @@ kyc_context_cleanup (void *cls)
       TALER_EXCHANGE_kyc_check_cancel (ekr->kyc);
       ekr->kyc = NULL;
     }
+    if (NULL != ekr->fo)
+    {
+      TMH_EXCHANGES_find_exchange_cancel (ekr->fo);
+      ekr->fo = NULL;
+    }
     GNUNET_free (ekr->exchange_url);
     GNUNET_free (ekr->payto_uri);
     GNUNET_free (ekr);
@@ -331,6 +342,11 @@ handle_kyc_timeout (void *cls)
       TALER_EXCHANGE_kyc_check_cancel (ekr->kyc);
       ekr->kyc = NULL;
     }
+    if (NULL != ekr->fo)
+    {
+      TMH_EXCHANGES_find_exchange_cancel (ekr->fo);
+      ekr->fo = NULL;
+    }
     GNUNET_assert (
       0 ==
       json_array_append_new (
@@ -454,6 +470,42 @@ exchange_check_cb (void *cls,
 }
 
 
+/**
+ * Function called with the result of a #TMH_EXCHANGES_find_exchange()
+ * operation.  Runs the KYC check against the exchange.
+ *
+ * @param cls closure with our `struct ExchangeKycRequest *`
+ * @param hr HTTP response details
+ * @param eh handle to the exchange context
+ * @param payto_uri payto://-URI of the exchange
+ * @param wire_fee current applicable wire fee for dealing with @a eh, NULL if 
not available
+ * @param exchange_trusted true if this exchange is trusted by config
+ */
+static void
+kyc_with_exchange (void *cls,
+                   const struct TALER_EXCHANGE_HttpResponse *hr,
+                   struct TALER_EXCHANGE_Handle *eh,
+                   const char *payto_uri,
+                   const struct TALER_Amount *wire_fee,
+                   bool exchange_trusted)
+{
+  struct ExchangeKycRequest *ekr = cls;
+  struct KycContext *kc = ekr->kc;
+  struct GNUNET_HashCode h_payto;
+
+  ekr->fo = NULL;
+  GNUNET_CRYPTO_hash (ekr->payto_uri,
+                      strlen (ekr->payto_uri),
+                      &h_payto);
+  ekr->kyc = TALER_EXCHANGE_kyc_check (eh,
+                                       ekr->exchange_kyc_serial,
+                                       &h_payto,
+                                       kc->timeout,
+                                       &exchange_check_cb,
+                                       ekr);
+}
+
+
 /**
  * Function called from ``account_kyc_get_status``
  * with KYC status information for this merchant.
@@ -494,22 +546,11 @@ kyc_status_cb (void *cls,
   ekr->last_check = last_check;
   ekr->kyc_ok = kyc_ok;
   ekr->kc = kc;
-#if FIXME
-  exchange <= from (exchange_url);
-  {
-    struct GNUNET_HashCode h_payto;
-
-    GNUNET_CRYPTO_hash (payto_uri,
-                        strlen (payto_uri),
-                        &h_payto);
-    ekr->kyc = TALER_EXCHANGE_kyc_check (exchange,
-                                         exchange_kyc_serial,
-                                         &h_payto,
-                                         pc->timeout,
-                                         &exchange_check_cb,
+  ekr->fo = TMH_EXCHANGES_find_exchange (exchange_url,
+                                         NULL,
+                                         GNUNET_NO,
+                                         &kyc_with_exchange,
                                          ekr);
-  }
-#endif
 }
 
 

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