exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

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

expand kyc tester helper program to also request KYC access token and output KYC SPA base URL

Diffstat:
Msrc/exchange-tools/taler-exchange-kyc-trigger.c | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/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 @@ -56,6 +56,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. */ static struct TALER_Amount balance; @@ -78,6 +83,57 @@ 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 @@ -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);