exchange

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

commit c98b47d13eb5172d39b00706bff1264a142ce28d
parent 79f312df5d79787feb5af591641135e8a0eeb5f1
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 24 Aug 2024 14:49:54 +0200

fix #9122 and #9104

Diffstat:
Msrc/exchange/taler-exchange-httpd_kyc-start.c | 9++-------
Msrc/exchange/taler-exchange-httpd_kyc-upload.c | 3++-
Msrc/exchangedb/0005-legitimization_processes.sql | 5+++++
Msrc/exchangedb/Makefile.am | 1+
Msrc/exchangedb/pg_lookup_pending_legitimization.c | 18+-----------------
Msrc/exchangedb/pg_lookup_pending_legitimization.h | 9+--------
Msrc/include/taler_exchangedb_plugin.h | 39++++++++++++++++++++++++++++++++++-----
7 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_kyc-start.c b/src/exchange/taler-exchange-httpd_kyc-start.c @@ -273,8 +273,6 @@ TEH_handler_kyc_start ( const struct TALER_KYCLOGIC_KycProvider *provider; struct TALER_KYCLOGIC_ProviderDetails *pd; bool is_finished; - size_t enc_len; - void *enc = NULL; kyp = GNUNET_new (struct KycPoller); kyp->connection = rc->connection; @@ -329,9 +327,7 @@ TEH_handler_kyc_start ( &kyp->access_token, &kyp->h_payto, &kyp->jmeasures, - &is_finished, - &enc_len, - &enc); + &is_finished); if (qs < 0) { GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); @@ -349,14 +345,13 @@ TEH_handler_kyc_start ( TALER_EC_GENERIC_ENDPOINT_UNKNOWN, rc->url); } - GNUNET_free (enc); if (is_finished) { GNUNET_break_op (0); return TALER_MHD_reply_with_error ( rc->connection, MHD_HTTP_CONFLICT, - -1, // FIXME: TALER_EC_..._ALREADY_FINISHED + TALER_EC_EXCHANGE_KYC_FORM_ALREADY_UPLOADED, rc->url); } diff --git a/src/exchange/taler-exchange-httpd_kyc-upload.c b/src/exchange/taler-exchange-httpd_kyc-upload.c @@ -465,9 +465,10 @@ TEH_handler_kyc_upload ( const char *error_message; enum TALER_ErrorCode ec; - qs = TEH_plugin->lookup_pending_legitimization ( + qs = TEH_plugin->lookup_completed_legitimization ( TEH_plugin->cls, uc->legitimization_measure_serial_id, + uc->measure_index, &uc->access_token, &h_payto, &jmeasures, diff --git a/src/exchangedb/0005-legitimization_processes.sql b/src/exchangedb/0005-legitimization_processes.sql @@ -81,6 +81,11 @@ BEGIN ' ADD CONSTRAINT ' || table_name || '_foreign_key_legitimization_measure' ' FOREIGN KEY (legitimization_measure_serial_id)' ' REFERENCES legitimization_measures (legitimization_measure_serial_id)'); + + EXECUTE FORMAT ( + 'ALTER TABLE ' || table_name || + ' ADD CONSTRAINT ' || table_name || '_unique_measure_and_index' + ' UNIQUE (legitimization_measure_serial_id,measure_index)'); END $$; diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am @@ -174,6 +174,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \ pg_test_aml_officer.h pg_test_aml_officer.c \ pg_lookup_aml_officer.h pg_lookup_aml_officer.c \ pg_lookup_pending_legitimization.h pg_lookup_pending_legitimization.c \ + pg_lookup_completed_legitimization.h pg_lookup_completed_legitimization.c \ pg_lookup_active_legitimization.h pg_lookup_active_legitimization.c \ pg_trigger_aml_process.h pg_trigger_aml_process.c \ pg_insert_aml_decision.h pg_insert_aml_decision.c \ diff --git a/src/exchangedb/pg_lookup_pending_legitimization.c b/src/exchangedb/pg_lookup_pending_legitimization.c @@ -33,10 +33,7 @@ TEH_PG_lookup_pending_legitimization ( struct TALER_AccountAccessTokenP *access_token, struct TALER_PaytoHashP *h_payto, json_t **jmeasures, - bool *is_finished, - size_t *encrypted_attributes_len, - void **encrypted_attributes - ) + bool *is_finished) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -56,17 +53,9 @@ TEH_PG_lookup_pending_legitimization ( GNUNET_PQ_result_spec_bool ( "is_finished", is_finished), - GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_variable_size ( - "encrypted_attributes", - encrypted_attributes, - encrypted_attributes_len), - NULL), GNUNET_PQ_result_spec_end }; - *encrypted_attributes_len = 0; - *encrypted_attributes = NULL; PREPARE (pg, "lookup_pending_legitimization", "SELECT " @@ -74,14 +63,9 @@ TEH_PG_lookup_pending_legitimization ( ",wt.wire_target_h_payto" ",lm.access_token" ",lm.is_finished" - ",ka.encrypted_attributes" " FROM legitimization_measures lm" " JOIN wire_targets wt" " ON (lm.access_token = wt.access_token)" - " LEFT JOIN legitimization_processes lp" - " ON (lm.legitimization_measure_serial_id = lp.legitimization_measure_serial_id)" - " LEFT JOIN kyc_attributes ka" - " ON (ka.legitimization_serial = lp.legitimization_process_serial_id)" " WHERE lm.legitimization_measure_serial_id=$1;"); return GNUNET_PQ_eval_prepared_singleton_select ( pg->conn, diff --git a/src/exchangedb/pg_lookup_pending_legitimization.h b/src/exchangedb/pg_lookup_pending_legitimization.h @@ -40,11 +40,6 @@ * measures that were put on the account * @param[out] is_finished set to true if the legitimization was * already finished - * @param[out] encrypted_attributes_len set to length of - * @a encrypted_attributes - * @param[out] encrypted_attributes set to the attributes - * obtained for the legitimization process, if it - * succeeded, otherwise set to NULL * @return database transaction status */ enum GNUNET_DB_QueryStatus @@ -54,8 +49,6 @@ TEH_PG_lookup_pending_legitimization ( struct TALER_AccountAccessTokenP *access_token, struct TALER_PaytoHashP *h_payto, json_t **jmeasures, - bool *is_finished, - size_t *encrypted_attributes_len, - void **encrypted_attributes); + bool *is_finished); #endif diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h @@ -7441,11 +7441,6 @@ struct TALER_EXCHANGEDB_Plugin * measures that were put on the account * @param[out] is_finished set to true if the legitimization was * already finished - * @param[out] encrypted_attributes_len set to length of - * @a encrypted_attributes - * @param[out] encrypted_attributes set to the attributes - * obtained for the legitimization process, if it - * succeeded, otherwise set to NULL * @return database transaction status */ enum GNUNET_DB_QueryStatus @@ -7455,6 +7450,40 @@ struct TALER_EXCHANGEDB_Plugin struct TALER_AccountAccessTokenP *access_token, struct TALER_PaytoHashP *h_payto, json_t **jmeasures, + bool *is_finished); + + + /** + * Lookup measure data for a legitimization process. + * + * @param cls closure + * @param legitimization_measure_serial_id + * row in legitimization_measures table to access + * @param measure_index index of the measure to return + * attribute data for + * @param[out] access_token + * set to token for access control that must match + * @param[out] h_payto set to the the hash of the + * payto URI of the account undergoing legitimization + * @param[out] jmeasures set to the legitimization + * measures that were put on the account + * @param[out] is_finished set to true if the legitimization was + * already finished + * @param[out] encrypted_attributes_len set to length of + * @a encrypted_attributes + * @param[out] encrypted_attributes set to the attributes + * obtained for the legitimization process, if it + * succeeded, otherwise set to NULL + * @return database transaction status + */ + enum GNUNET_DB_QueryStatus + (*lookup_completed_legitimization)( + void *cls, + uint64_t legitimization_measure_serial_id, + uint32_t measure_index, + struct TALER_AccountAccessTokenP *access_token, + struct TALER_PaytoHashP *h_payto, + json_t **jmeasures, bool *is_finished, size_t *encrypted_attributes_len, void **encrypted_attributes);