exchange

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

commit f6a86e8680ec57d5389e58c88bb462600894b25f
parent 97a767743cbbad2886d285f2885d3761bcb58d4a
Author: Florian Dold <florian@dold.me>
Date:   Mon,  4 Nov 2024 15:20:00 +0100

kyc: create legi process before running instant measure aml program

Diffstat:
Msrc/exchange/taler-exchange-httpd_aml-decision.c | 29+++++++++++++++++++++++++++--
Msrc/exchangedb/exchange_do_insert_aml_decision.sql | 10++++++++--
Msrc/exchangedb/pg_insert_aml_decision.c | 6+++++-
Msrc/exchangedb/pg_insert_aml_decision.h | 5++++-
Msrc/include/taler_exchangedb_plugin.h | 5++++-
5 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_aml-decision.c b/src/exchange/taler-exchange-httpd_aml-decision.c @@ -168,6 +168,7 @@ TEH_handler_post_aml_decision ( struct TALER_PaytoHashP h_payto; struct TALER_AmlOfficerSignatureP officer_sig; struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs = NULL; + uint64_t legi_measure_serial_id = 0; MHD_RESULT ret; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_mark_optional ( @@ -332,7 +333,8 @@ TEH_handler_post_aml_decision ( &officer_sig, &invalid_officer, &unknown_account, - &last_date); + &last_date, + &legi_measure_serial_id); json_decref (jmeasures); if (qs <= 0) { @@ -381,6 +383,7 @@ TEH_handler_post_aml_decision ( { const struct TALER_KYCLOGIC_Measure *instant_ms = NULL; struct MHD_Response *empty_response; + enum GNUNET_DB_QueryStatus qs; if (NULL != new_measures) { @@ -394,6 +397,7 @@ TEH_handler_post_aml_decision ( to select some measure and contribute their KYC data. */ json_t *attributes = json_object (); /* instant: empty attributes */ + uint64_t process_row; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running instant measure after AML decision\n"); @@ -403,10 +407,31 @@ TEH_handler_post_aml_decision ( = MHD_create_response_from_buffer_static (0, ""); GNUNET_assert (NULL != empty_response); + + qs = TEH_plugin->insert_kyc_requirement_process ( + TEH_plugin->cls, + &h_payto, + 0, /* measure index */ + legi_measure_serial_id, + "SKIP", + NULL, /* provider_account_id */ + NULL, /* provider_legitimziation_id */ + &process_row); + if (qs < 0) + { + GNUNET_break (0); + ret = TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "insert_kyc_requirement_process"); + goto done; + } + /* FIXME: Insert start time of KYC process' AML program */ adc->kat = TEH_kyc_finished2 ( &rc->async_scope_id, - 0LL, + process_row, instant_ms, &h_payto, "SKIP", /* provider */ diff --git a/src/exchangedb/exchange_do_insert_aml_decision.sql b/src/exchangedb/exchange_do_insert_aml_decision.sql @@ -31,7 +31,8 @@ CREATE FUNCTION exchange_do_insert_aml_decision( IN in_notify_s TEXT, OUT out_invalid_officer BOOLEAN, OUT out_account_unknown BOOLEAN, - OUT out_last_date INT8) + OUT out_last_date INT8, + OUT out_legitimization_measure_serial_id INT8) LANGUAGE plpgsql AS $$ DECLARE @@ -40,6 +41,7 @@ DECLARE BEGIN out_account_unknown=FALSE; +out_legitimization_measure_serial_id=0; -- Check officer is eligible to make decisions. @@ -132,7 +134,11 @@ THEN (my_access_token ,in_decision_time ,in_jmeasures - ,1); + ,1) + RETURNING + legitimization_measure_serial_id + INTO + out_legitimization_measure_serial_id; END IF; -- end if for where we had in_jmeasures diff --git a/src/exchangedb/pg_insert_aml_decision.c b/src/exchangedb/pg_insert_aml_decision.c @@ -44,7 +44,8 @@ TEH_PG_insert_aml_decision ( const struct TALER_AmlOfficerSignatureP *decider_sig, bool *invalid_officer, bool *unknown_account, - struct GNUNET_TIME_Timestamp *last_date) + struct GNUNET_TIME_Timestamp *last_date, + uint64_t *legitimization_measure_serial_id) { struct PostgresClosure *pg = cls; struct TALER_KycCompletedEventP rep = { @@ -85,6 +86,8 @@ TEH_PG_insert_aml_decision ( unknown_account), GNUNET_PQ_result_spec_timestamp ("out_last_date", last_date), + GNUNET_PQ_result_spec_uint64 ("out_legitimization_measure_serial_id", + legitimization_measure_serial_id), GNUNET_PQ_result_spec_end }; enum GNUNET_DB_QueryStatus qs; @@ -95,6 +98,7 @@ TEH_PG_insert_aml_decision ( " out_invalid_officer" ",out_account_unknown" ",out_last_date" + ",out_legitimization_measure_serial_id" " FROM exchange_do_insert_aml_decision" "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13);"); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, diff --git a/src/exchangedb/pg_insert_aml_decision.h b/src/exchangedb/pg_insert_aml_decision.h @@ -49,6 +49,8 @@ * @param[out] unknown_account set to TRUE if @a h_payto does not refer to a known account and @a jmeasures was given * @param[out] last_date set to the previous decision time; * the INSERT is not performed if @a last_date is not before @a decision_time + * @param[out] legitimization_measure_serial_id serial ID of the legitimization measures + * of the decision * @return database transaction status */ enum GNUNET_DB_QueryStatus @@ -68,7 +70,8 @@ TEH_PG_insert_aml_decision ( const struct TALER_AmlOfficerSignatureP *decider_sig, bool *invalid_officer, bool *unknown_account, - struct GNUNET_TIME_Timestamp *last_date); + struct GNUNET_TIME_Timestamp *last_date, + uint64_t *legitimization_measure_serial_id); #endif diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h @@ -7679,6 +7679,8 @@ struct TALER_EXCHANGEDB_Plugin * @param[out] unknown_account set to TRUE if @a h_payto does not refer to a known account and @a jmeasures was given * @param[out] last_date set to the previous decision time; * the INSERT is not performed if @a last_date is not before @a decision_time + * @param[out] legitimization_measure_serial_id serial ID of the legitimization measures + * of the decision * @return database transaction status */ enum GNUNET_DB_QueryStatus @@ -7698,7 +7700,8 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_AmlOfficerSignatureP *decider_sig, bool *invalid_officer, bool *unknown_account, - struct GNUNET_TIME_Timestamp *last_date); + struct GNUNET_TIME_Timestamp *last_date, + uint64_t *legitimization_measure_serial_id); /**