summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-10-10 21:01:43 +0200
committerChristian Grothoff <christian@grothoff.org>2021-10-10 21:01:43 +0200
commit3cc3a5d6215a3ca4e85c4b44c9a4360739bc4b67 (patch)
tree9dd2674ae160e6499695342ab56de65f74bf4e15 /src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
parent0e06513c2910cda1ddc22c8a5d3825557e57660e (diff)
downloadmerchant-3cc3a5d6215a3ca4e85c4b44c9a4360739bc4b67.tar.gz
merchant-3cc3a5d6215a3ca4e85c4b44c9a4360739bc4b67.tar.bz2
merchant-3cc3a5d6215a3ca4e85c4b44c9a4360739bc4b67.zip
-add exchange lookup to kyc handler (WiP)
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c')
-rw-r--r--src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c71
1 files changed, 56 insertions, 15 deletions
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>
@@ -58,6 +59,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.
*/
struct KycContext *kc;
@@ -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 (
@@ -455,6 +471,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
}