gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: expand kyc tester helper program


From: gnunet
Subject: [taler-exchange] branch master updated: expand kyc tester helper program to also request KYC access token and output KYC SPA base URL
Date: Sat, 28 Dec 2024 23:51:34 +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 b88d3fff4 expand kyc tester helper program to also request KYC access 
token and output KYC SPA base URL
b88d3fff4 is described below

commit b88d3fff420704ca39141ff1f836f5ffde0b1b8a
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Dec 28 23:51:26 2024 +0100

    expand kyc tester helper program to also request KYC access token and 
output KYC SPA base URL
---
 src/exchange-tools/taler-exchange-kyc-trigger.c | 87 +++++++++++++++++++++++++
 src/exchange/taler-exchange-httpd_keys.c        | 12 ++--
 2 files changed, 93 insertions(+), 6 deletions(-)

diff --git a/src/exchange-tools/taler-exchange-kyc-trigger.c 
b/src/exchange-tools/taler-exchange-kyc-trigger.c
index f4d7bfc6c..ececdfb3f 100644
--- a/src/exchange-tools/taler-exchange-kyc-trigger.c
+++ b/src/exchange-tools/taler-exchange-kyc-trigger.c
@@ -55,6 +55,11 @@ static const struct GNUNET_CONFIGURATION_Handle *kcfg;
  */
 static struct TALER_EXCHANGE_KycWalletHandle *kwh;
 
+/**
+ * Handle for exchange kyc-check interaction.
+ */
+static struct TALER_EXCHANGE_KycCheckHandle *kc;
+
 /**
  * Balance threshold to report to the exchange.
  */
@@ -77,6 +82,57 @@ static char *currency;
 static char *CFG_exchange_url;
 
 
+/**
+ * Function called with the result of a KYC check.
+ *
+ * @param cls closure
+ * @param ks the account's KYC status details
+ */
+static void
+kyc_status_cb (
+  void *cls,
+  const struct TALER_EXCHANGE_KycStatus *ks)
+{
+  kc = NULL;
+  switch (ks->hr.http_status)
+  {
+  case MHD_HTTP_OK:
+    {
+      char *buf;
+
+      buf = GNUNET_STRINGS_data_to_string_alloc (
+        &ks->details.ok.access_token,
+        sizeof (ks->details.ok.access_token));
+      fprintf (stdout,
+               "KYC SPA at %skyc-spa/%s\n",
+               CFG_exchange_url,
+               buf);
+      GNUNET_free (buf);
+    }
+    break;
+  case MHD_HTTP_ACCEPTED:
+    {
+      char *buf;
+
+      buf = GNUNET_STRINGS_data_to_string_alloc (
+        &ks->details.ok.access_token,
+        sizeof (ks->details.ok.access_token));
+      fprintf (stdout,
+               "KYC SPA at %skyc-spa/%s\n",
+               CFG_exchange_url,
+               buf);
+      GNUNET_free (buf);
+    }
+    break;
+  case MHD_HTTP_FORBIDDEN:
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "KYC auth now required?\n");
+    break;
+  }
+  GNUNET_SCHEDULER_shutdown ();
+}
+
+
 /**
  * Function called with the result for a wallet looking
  * up its KYC payment target.
@@ -113,6 +169,32 @@ kyc_wallet_cb (
                : "KYC auth OK",
                ps);
       GNUNET_free (ps);
+      if (! knr->bad_kyc_auth)
+      {
+        struct TALER_NormalizedPaytoHashP h_payto;
+        union TALER_AccountPrivateKeyP pk;
+        struct TALER_NormalizedPayto np;
+
+        np = TALER_reserve_make_payto (CFG_exchange_url,
+                                       &reserve_pub);
+        TALER_normalized_payto_hash (np,
+                                     &h_payto);
+        GNUNET_free (np.normalized_payto);
+        pk.reserve_priv = reserve_priv;
+        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                    "Requesting /kyc-check to determine KYC entrypoint\n");
+        kc = TALER_EXCHANGE_kyc_check (ctx,
+                                       CFG_exchange_url,
+                                       &h_payto,
+                                       &pk,
+                                       TALER_EXCHANGE_KLPT_NONE,
+                                       GNUNET_TIME_UNIT_ZERO,
+                                       &kyc_status_cb,
+                                       NULL);
+        GNUNET_break (NULL != kc);
+        if (NULL != kc)
+          return;
+      }
     }
     break;
   default:
@@ -139,6 +221,11 @@ do_shutdown (void *cls)
     TALER_EXCHANGE_kyc_wallet_cancel (kwh);
     kwh = NULL;
   }
+  if (NULL != kc)
+  {
+    TALER_EXCHANGE_kyc_check_cancel (kc);
+    kc = NULL;
+  }
   if (NULL != ctx)
   {
     GNUNET_CURL_fini (ctx);
diff --git a/src/exchange/taler-exchange-httpd_keys.c 
b/src/exchange/taler-exchange-httpd_keys.c
index 902d82007..5580f9c2e 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -430,13 +430,13 @@ struct WireFeeSet
 
 
 /**
- * State we keep per thread to cache the /wire response.
+ * State we keep per thread to cache the wire part of the /keys response.
  */
 struct WireStateHandle
 {
 
   /**
-   * JSON reply for /wire response.
+   * JSON reply for wire response.
    */
   json_t *json_reply;
 
@@ -615,7 +615,7 @@ wire_update_event_cb (void *cls,
   (void) extra;
   (void) extra_size;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Received /wire update event\n");
+              "Received wire update event\n");
   TEH_check_invariants ();
   wire_generation++;
   key_generation++;
@@ -819,7 +819,7 @@ add_wire_fee (void *cls,
 
 
 /**
- * Create the /wire response from our database state.
+ * Create the wire response from our database state.
  *
  * @return NULL on error
  */
@@ -848,7 +848,7 @@ build_wire_state (void)
     return wsh;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Build /wire data with %u accounts\n",
+              "Build wire data with %u accounts\n",
               (unsigned int) json_array_size (wire_accounts_array));
   wire_fee_object = json_object ();
   GNUNET_assert (NULL != wire_fee_object);
@@ -970,7 +970,7 @@ get_wire_state (void)
     struct WireStateHandle *wsh;
 
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "Rebuilding /wire, generation upgrade from %llu to %llu\n",
+                "Rebuilding wire, generation upgrade from %llu to %llu\n",
                 (unsigned long long) (NULL == old_wsh) ? 0LL :
                 old_wsh->wire_generation,
                 (unsigned long long) wire_generation);

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