diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-02-17 18:24:20 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-02-17 18:24:20 +0100 |
commit | aa5e7d2ad5e712434f32ab41b63d53bb897c6105 (patch) | |
tree | 63eca83e563d69d5d689f4e9c3c218be0950e854 /src/exchange | |
parent | 86e0f2c70d07c7c5e1656667bd818498ea55d0a4 (diff) |
more towards actually allowing AML decisions to trigger KYC
Diffstat (limited to 'src/exchange')
-rw-r--r-- | src/exchange/taler-exchange-httpd_aml-decision.c | 85 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_batch-withdraw.c | 15 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_kyc-check.c | 13 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_kyc-wallet.c | 2 |
4 files changed, 106 insertions, 9 deletions
diff --git a/src/exchange/taler-exchange-httpd_aml-decision.c b/src/exchange/taler-exchange-httpd_aml-decision.c index 0fd58b9e..2830e54e 100644 --- a/src/exchange/taler-exchange-httpd_aml-decision.c +++ b/src/exchange/taler-exchange-httpd_aml-decision.c @@ -103,6 +103,85 @@ make_aml_decision (void *cls, enum GNUNET_DB_QueryStatus qs; struct GNUNET_TIME_Timestamp last_date; bool invalid_officer; + uint64_t requirement_row = 0; + + if ( (NULL != dc->kyc_requirements) && + (0 != json_array_size (dc->kyc_requirements)) ) + { + char *res = NULL; + size_t idx; + json_t *req; + bool satisfied; + + json_array_foreach (dc->kyc_requirements, idx, req) + { + const char *r = json_string_value (req); + + if (NULL == res) + { + res = GNUNET_strdup (r); + } + else + { + char *tmp; + + GNUNET_asprintf (&tmp, + "%s %s", + res, + r); + GNUNET_free (res); + res = tmp; + } + } + + { + json_t *kyc_details = NULL; + + qs = TALER_KYCLOGIC_check_satisfied ( + &res, + &dc->h_payto, + &kyc_details, + TEH_plugin->select_satisfied_kyc_processes, + TEH_plugin->cls, + &satisfied); + json_decref (kyc_details); + } + if (qs < 0) + { + if (GNUNET_DB_STATUS_SOFT_ERROR != qs) + { + GNUNET_break (0); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "select_satisfied_kyc_processes"); + return GNUNET_DB_STATUS_HARD_ERROR; + } + return qs; + } + if (! satisfied) + { + qs = TEH_plugin->insert_kyc_requirement_for_account ( + TEH_plugin->cls, + res, + &dc->h_payto, + &requirement_row); + if (qs < 0) + { + if (GNUNET_DB_STATUS_SOFT_ERROR != qs) + { + GNUNET_break (0); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "insert_kyc_requirement_for_account"); + return GNUNET_DB_STATUS_HARD_ERROR; + } + return qs; + } + } + GNUNET_free (res); + } qs = TEH_plugin->insert_aml_decision (TEH_plugin->cls, &dc->h_payto, @@ -111,6 +190,7 @@ make_aml_decision (void *cls, dc->decision_time, dc->justification, dc->kyc_requirements, + requirement_row, dc->officer_pub, &dc->officer_sig, &invalid_officer, @@ -151,11 +231,6 @@ make_aml_decision (void *cls, return GNUNET_DB_STATUS_HARD_ERROR; } - if (NULL != dc->kyc_requirements) - { - // FIXME: act on these! - } - return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c b/src/exchange/taler-exchange-httpd_batch-withdraw.c index e6be54a5..493a2bc7 100644 --- a/src/exchange/taler-exchange-httpd_batch-withdraw.c +++ b/src/exchange/taler-exchange-httpd_batch-withdraw.c @@ -210,7 +210,7 @@ batch_withdraw_transaction (void *cls, enum GNUNET_DB_QueryStatus qs; bool balance_ok = false; bool found = false; - const char *kyc_required; + char *kyc_required; struct TALER_PaytoHashP reserve_h_payto; wc->now = GNUNET_TIME_timestamp_get (); @@ -349,11 +349,22 @@ batch_withdraw_transaction (void *cls, { /* insert KYC requirement into DB! */ wc->kyc.ok = false; - return TEH_plugin->insert_kyc_requirement_for_account ( + qs = TEH_plugin->insert_kyc_requirement_for_account ( TEH_plugin->cls, kyc_required, &wc->h_payto, &wc->kyc.requirement_row); + GNUNET_free (kyc_required); + if (qs < 0) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + if (GNUNET_DB_STATUS_HARD_ERROR == qs) + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "insert_kyc_requirement_for_account"); + } + return qs; } wc->kyc.ok = true; qs = TEH_plugin->do_batch_withdraw (TEH_plugin->cls, diff --git a/src/exchange/taler-exchange-httpd_kyc-check.c b/src/exchange/taler-exchange-httpd_kyc-check.c index 07b8dc66..57ac8389 100644 --- a/src/exchange/taler-exchange-httpd_kyc-check.c +++ b/src/exchange/taler-exchange-httpd_kyc-check.c @@ -332,7 +332,7 @@ kyc_check (void *cls, return GNUNET_DB_STATUS_HARD_ERROR; } qs = TALER_KYCLOGIC_check_satisfied ( - requirements, + &requirements, &h_payto, &kyp->kyc_details, TEH_plugin->select_satisfied_kyc_processes, @@ -389,6 +389,17 @@ kyc_check (void *cls, NULL, NULL, &kyp->process_row); + if (qs < 0) + { + if (GNUNET_DB_STATUS_SOFT_ERROR == qs) + return qs; + GNUNET_break (0); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "insert_kyc_requirement_process"); + return GNUNET_DB_STATUS_HARD_ERROR; + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Initiating KYC check with logic %s\n", kyp->ih_logic->name); diff --git a/src/exchange/taler-exchange-httpd_kyc-wallet.c b/src/exchange/taler-exchange-httpd_kyc-wallet.c index e56204ef..77f2dea7 100644 --- a/src/exchange/taler-exchange-httpd_kyc-wallet.c +++ b/src/exchange/taler-exchange-httpd_kyc-wallet.c @@ -237,7 +237,7 @@ TEH_handler_kyc_wallet ( NULL, 0); } - GNUNET_free (kyc.required); + GNUNET_free (krc.required); return TEH_RESPONSE_reply_kyc_required (rc->connection, &krc.h_payto, &krc.kyc); |