more work on API atomization
This commit is contained in:
parent
f969bd3c5b
commit
75ea35722b
@ -4030,7 +4030,9 @@ typedef void
|
||||
* Run interaction with exchange to check KYC status
|
||||
* of a merchant.
|
||||
*
|
||||
* @param eh exchange handle to use
|
||||
* @param ctx CURL context
|
||||
* @param url exchange base URL
|
||||
* @param keys keys of the exchange
|
||||
* @param requirement_row number identifying the KYC requirement
|
||||
* @param h_payto hash of the payto:// URI at @a payment_target
|
||||
* @param ut type of the entity performing the KYC check
|
||||
@ -4040,13 +4042,16 @@ typedef void
|
||||
* @return NULL on error
|
||||
*/
|
||||
struct TALER_EXCHANGE_KycCheckHandle *
|
||||
TALER_EXCHANGE_kyc_check (struct TALER_EXCHANGE_Handle *eh,
|
||||
uint64_t requirement_row,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
enum TALER_KYCLOGIC_KycUserType ut,
|
||||
struct GNUNET_TIME_Relative timeout,
|
||||
TALER_EXCHANGE_KycStatusCallback cb,
|
||||
void *cb_cls);
|
||||
TALER_EXCHANGE_kyc_check (
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
struct TALER_EXCHANGE_Keys *keys,
|
||||
uint64_t requirement_row,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
enum TALER_KYCLOGIC_KycUserType ut,
|
||||
struct GNUNET_TIME_Relative timeout,
|
||||
TALER_EXCHANGE_KycStatusCallback cb,
|
||||
void *cb_cls);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -36,16 +36,16 @@
|
||||
struct TALER_EXCHANGE_KycCheckHandle
|
||||
{
|
||||
|
||||
/**
|
||||
* The connection to exchange this request handle will use
|
||||
*/
|
||||
struct TALER_EXCHANGE_Handle *exchange;
|
||||
|
||||
/**
|
||||
* The url for this request.
|
||||
*/
|
||||
char *url;
|
||||
|
||||
/**
|
||||
* Keys of the exchange.
|
||||
*/
|
||||
struct TALER_EXCHANGE_Keys *keys;
|
||||
|
||||
/**
|
||||
* Handle for the request.
|
||||
*/
|
||||
@ -111,7 +111,6 @@ handle_kyc_check_finished (void *cls,
|
||||
&status),
|
||||
GNUNET_JSON_spec_end ()
|
||||
};
|
||||
const struct TALER_EXCHANGE_Keys *key_state;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_JSON_parse (j,
|
||||
@ -126,9 +125,8 @@ handle_kyc_check_finished (void *cls,
|
||||
ks.details.ok.kyc_details = kyc_details;
|
||||
ks.details.ok.aml_status
|
||||
= (enum TALER_AmlDecisionState) status;
|
||||
key_state = TALER_EXCHANGE_get_keys (kch->exchange);
|
||||
if (GNUNET_OK !=
|
||||
TALER_EXCHANGE_test_signing_key (key_state,
|
||||
TALER_EXCHANGE_test_signing_key (kch->keys,
|
||||
&ks.details.ok.exchange_pub))
|
||||
{
|
||||
GNUNET_break_op (0);
|
||||
@ -249,25 +247,21 @@ handle_kyc_check_finished (void *cls,
|
||||
|
||||
|
||||
struct TALER_EXCHANGE_KycCheckHandle *
|
||||
TALER_EXCHANGE_kyc_check (struct TALER_EXCHANGE_Handle *exchange,
|
||||
uint64_t requirement_row,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
enum TALER_KYCLOGIC_KycUserType ut,
|
||||
struct GNUNET_TIME_Relative timeout,
|
||||
TALER_EXCHANGE_KycStatusCallback cb,
|
||||
void *cb_cls)
|
||||
TALER_EXCHANGE_kyc_check (
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
struct TALER_EXCHANGE_Keys *keys,
|
||||
uint64_t requirement_row,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
enum TALER_KYCLOGIC_KycUserType ut,
|
||||
struct GNUNET_TIME_Relative timeout,
|
||||
TALER_EXCHANGE_KycStatusCallback cb,
|
||||
void *cb_cls)
|
||||
{
|
||||
struct TALER_EXCHANGE_KycCheckHandle *kch;
|
||||
CURL *eh;
|
||||
struct GNUNET_CURL_Context *ctx;
|
||||
char *arg_str;
|
||||
|
||||
if (GNUNET_YES !=
|
||||
TEAH_handle_is_ready (exchange))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
char payto_str[sizeof (*h_payto) * 2];
|
||||
char *end;
|
||||
@ -282,19 +276,19 @@ TALER_EXCHANGE_kyc_check (struct TALER_EXCHANGE_Handle *exchange,
|
||||
timeout_ms = timeout.rel_value_us
|
||||
/ GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us;
|
||||
GNUNET_asprintf (&arg_str,
|
||||
"/kyc-check/%llu/%s/%s?timeout_ms=%llu",
|
||||
"kyc-check/%llu/%s/%s?timeout_ms=%llu",
|
||||
(unsigned long long) requirement_row,
|
||||
payto_str,
|
||||
TALER_KYCLOGIC_kyc_user_type2s (ut),
|
||||
timeout_ms);
|
||||
}
|
||||
kch = GNUNET_new (struct TALER_EXCHANGE_KycCheckHandle);
|
||||
kch->exchange = exchange;
|
||||
kch->h_payto = *h_payto;
|
||||
kch->cb = cb;
|
||||
kch->cb_cls = cb_cls;
|
||||
kch->url = TEAH_path_to_url (exchange,
|
||||
arg_str);
|
||||
kch->url = TALER_url_join (url,
|
||||
arg_str,
|
||||
NULL);
|
||||
GNUNET_free (arg_str);
|
||||
if (NULL == kch->url)
|
||||
{
|
||||
@ -309,7 +303,7 @@ TALER_EXCHANGE_kyc_check (struct TALER_EXCHANGE_Handle *exchange,
|
||||
GNUNET_free (kch);
|
||||
return NULL;
|
||||
}
|
||||
ctx = TEAH_handle_to_context (exchange);
|
||||
kch->keys = TALER_EXCHANGE_keys_incref (keys);
|
||||
kch->job = GNUNET_CURL_job_add_with_ct_json (ctx,
|
||||
eh,
|
||||
&handle_kyc_check_finished,
|
||||
@ -326,6 +320,7 @@ TALER_EXCHANGE_kyc_check_cancel (struct TALER_EXCHANGE_KycCheckHandle *kch)
|
||||
GNUNET_CURL_job_cancel (kch->job);
|
||||
kch->job = NULL;
|
||||
}
|
||||
TALER_EXCHANGE_keys_decref (kch->keys);
|
||||
GNUNET_free (kch->url);
|
||||
GNUNET_free (kch);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2021 Taler Systems SA
|
||||
Copyright (C) 2021-2023 Taler Systems SA
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
@ -114,16 +114,12 @@ check_kyc_run (void *cls,
|
||||
const struct TALER_TESTING_Command *res_cmd;
|
||||
const uint64_t *requirement_row;
|
||||
const struct TALER_PaytoHashP *h_payto;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
kcg->is = is;
|
||||
res_cmd = TALER_TESTING_interpreter_lookup_command (kcg->is,
|
||||
kcg->
|
||||
payment_target_reference);
|
||||
res_cmd = TALER_TESTING_interpreter_lookup_command (
|
||||
kcg->is,
|
||||
kcg->payment_target_reference);
|
||||
if (NULL == res_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
@ -152,13 +148,16 @@ check_kyc_run (void *cls,
|
||||
TALER_TESTING_interpreter_fail (kcg->is);
|
||||
return;
|
||||
}
|
||||
kcg->kwh = TALER_EXCHANGE_kyc_check (exchange,
|
||||
*requirement_row,
|
||||
h_payto,
|
||||
TALER_KYCLOGIC_KYC_UT_INDIVIDUAL,
|
||||
GNUNET_TIME_UNIT_SECONDS,
|
||||
&check_kyc_cb,
|
||||
kcg);
|
||||
kcg->kwh = TALER_EXCHANGE_kyc_check (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
TALER_TESTING_get_exchange_url (is),
|
||||
TALER_TESTING_get_keys (is),
|
||||
*requirement_row,
|
||||
h_payto,
|
||||
TALER_KYCLOGIC_KYC_UT_INDIVIDUAL,
|
||||
GNUNET_TIME_UNIT_SECONDS,
|
||||
&check_kyc_cb,
|
||||
kcg);
|
||||
GNUNET_assert (NULL != kcg->kwh);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user