commit eb4a284cb5335010cba85c4d2b9ee09e85bb0580
parent 5a0ba5e96c5e0637f42c36ead0e6233c7e82b5f7
Author: Florian Dold <florian@dold.me>
Date: Tue, 5 Nov 2024 15:05:10 +0100
rename insert_kyc_attributes to insert_kyc_measure_result
This reflects much better what the DB query does.
Diffstat:
11 files changed, 350 insertions(+), 357 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_common_kyc.c b/src/exchange/taler-exchange-httpd_common_kyc.c
@@ -305,7 +305,7 @@ kyc_aml_finished (
kat->attributes,
&ea,
&eas);
- qs = TEH_plugin->insert_kyc_attributes (
+ qs = TEH_plugin->insert_kyc_measure_result (
TEH_plugin->cls,
kat->process_row,
&kat->account_id,
@@ -337,7 +337,7 @@ kyc_aml_finished (
kat->response
= TALER_MHD_make_error (
TALER_EC_GENERIC_DB_STORE_FAILED,
- "do_insert_kyc_attributes");
+ "do_insert_kyc_measure_result");
/* Continued below to return the response */
}
RETURN_RESULT:
@@ -786,7 +786,7 @@ handle_aml_fallback_result (
&eas);
json_decref (attributes);
}
- qs = TEH_plugin->insert_kyc_attributes (
+ qs = TEH_plugin->insert_kyc_measure_result (
TEH_plugin->cls,
fb->orig_requirement_row,
&fb->account_id,
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
@@ -187,7 +187,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \
pg_have_deposit2.h pg_have_deposit2.c \
pg_aggregate.h pg_aggregate.c \
pg_create_aggregation_transient.h pg_create_aggregation_transient.c \
- pg_insert_kyc_attributes.h pg_insert_kyc_attributes.c \
+ pg_insert_kyc_measure_result.h pg_insert_kyc_measure_result.c \
pg_select_kyc_attributes.h pg_select_kyc_attributes.c \
pg_insert_aml_officer.h pg_insert_aml_officer.c \
pg_test_aml_officer.h pg_test_aml_officer.c \
diff --git a/src/exchangedb/exchange_do_insert_kyc_attributes.sql b/src/exchangedb/exchange_do_insert_kyc_attributes.sql
@@ -1,151 +0,0 @@
---
--- This file is part of TALER
--- Copyright (C) 2023, 2024 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 published by the Free Software
--- Foundation; either version 3, or (at your option) any later version.
---
--- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
--- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
--- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License along with
--- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
---
-
-DROP FUNCTION IF EXISTS exchange_do_insert_kyc_attributes;
-CREATE FUNCTION exchange_do_insert_kyc_attributes(
- IN in_process_row INT8,
- IN in_h_payto BYTEA,
- IN in_birthday INT4,
- IN in_provider_name TEXT,
- IN in_provider_account_id TEXT,
- IN in_provider_legitimization_id TEXT,
- IN in_collection_time_ts INT8,
- IN in_expiration_time INT8,
- IN in_expiration_time_ts INT8,
- IN in_account_properties TEXT,
- IN in_new_rules TEXT,
- IN ina_events TEXT[],
- IN in_enc_attributes BYTEA,
- IN in_to_investigate BOOLEAN,
- IN in_kyc_completed_notify_s TEXT,
- OUT out_ok BOOLEAN)
-LANGUAGE plpgsql
-AS $$
-DECLARE
- my_trigger_outcome_serial INT8;
- my_lmsi INT8;
- my_i INT4;
- ini_event TEXT;
-BEGIN
-
-
-UPDATE legitimization_outcomes
- SET is_active=FALSE
- WHERE h_payto=in_h_payto
- -- this clause is a minor optimization to avoid
- -- updating outcomes that have long expired.
- AND expiration_time >= in_collection_time_ts;
-
-INSERT INTO legitimization_outcomes
- (h_payto
- ,decision_time
- ,expiration_time
- ,jproperties
- ,to_investigate
- ,jnew_rules)
-VALUES
- (in_h_payto
- ,in_collection_time_ts
- ,in_expiration_time_ts
- ,in_account_properties
- ,in_to_investigate
- ,in_new_rules)
-RETURNING
- outcome_serial_id
-INTO
- my_trigger_outcome_serial;
-
-IF in_process_row IS NOT NULL
-THEN
- INSERT INTO kyc_attributes
- (h_payto
- ,collection_time
- ,expiration_time
- ,encrypted_attributes
- ,legitimization_serial
- ,trigger_outcome_serial
- ) VALUES
- (in_h_payto
- ,in_collection_time_ts
- ,in_expiration_time_ts
- ,in_enc_attributes
- ,in_process_row
- ,my_trigger_outcome_serial);
-END IF;
-
-UPDATE legitimization_processes
- SET provider_user_id=in_provider_account_id
- ,provider_legitimization_id=in_provider_legitimization_id
- ,expiration_time=GREATEST(expiration_time,in_expiration_time)
- ,finished=TRUE
- WHERE h_payto=in_h_payto
- AND legitimization_process_serial_id=in_process_row
- AND provider_name=in_provider_name
- RETURNING legitimization_measure_serial_id
- INTO my_lmsi;
-out_ok=FOUND;
-
-IF out_ok
-THEN
- UPDATE legitimization_measures
- SET is_finished=TRUE
- WHERE legitimization_measure_serial_id=my_lmsi;
-END IF;
-
-UPDATE reserves
- SET birthday=in_birthday
- WHERE (reserve_pub IN
- (SELECT reserve_pub
- FROM reserves_in
- WHERE wire_source_h_payto IN
- (SELECT wire_source_h_payto
- FROM wire_targets
- WHERE h_normalized_payto=in_h_payto) ) )
--- The next 3 clauses primarily serve to limit
--- unnecessary updates for reserves we do not
--- care about anymore.
- AND ( ((current_balance).frac > 0) OR
- ((current_balance).val > 0 ) )
- AND (expiration_date > in_collection_time_ts);
-
-
-FOR i IN 1..COALESCE(array_length(ina_events,1),0)
-LOOP
- ini_event = ina_events[i];
- INSERT INTO kyc_events
- (event_timestamp
- ,event_type)
- VALUES
- (in_collection_time_ts
- ,ini_event);
-END LOOP;
-
-EXECUTE FORMAT (
- 'NOTIFY %s'
- ,in_kyc_completed_notify_s);
-
-INSERT INTO kyc_alerts
- (h_payto
- ,trigger_type)
- VALUES
- (in_h_payto,1)
- ON CONFLICT DO NOTHING;
-
-END $$;
-
-
-COMMENT ON FUNCTION exchange_do_insert_kyc_attributes(INT8, BYTEA, INT4, TEXT, TEXT, TEXT, INT8, INT8, INT8, TEXT, TEXT, TEXT[], BYTEA, BOOL, TEXT)
- IS 'Inserts new KYC attributes and updates the status of the legitimization process and the AML status for the account';
diff --git a/src/exchangedb/exchange_do_insert_kyc_measure_result.sql b/src/exchangedb/exchange_do_insert_kyc_measure_result.sql
@@ -0,0 +1,151 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2023, 2024 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 published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+
+DROP FUNCTION IF EXISTS exchange_do_insert_kyc_measure_result;
+CREATE FUNCTION exchange_do_insert_kyc_measure_result(
+ IN in_process_row INT8,
+ IN in_h_payto BYTEA,
+ IN in_birthday INT4,
+ IN in_provider_name TEXT,
+ IN in_provider_account_id TEXT,
+ IN in_provider_legitimization_id TEXT,
+ IN in_collection_time_ts INT8,
+ IN in_expiration_time INT8,
+ IN in_expiration_time_ts INT8,
+ IN in_account_properties TEXT,
+ IN in_new_rules TEXT,
+ IN ina_events TEXT[],
+ IN in_enc_attributes BYTEA,
+ IN in_to_investigate BOOLEAN,
+ IN in_kyc_completed_notify_s TEXT,
+ OUT out_ok BOOLEAN)
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ my_trigger_outcome_serial INT8;
+ my_lmsi INT8;
+ my_i INT4;
+ ini_event TEXT;
+BEGIN
+
+
+UPDATE legitimization_outcomes
+ SET is_active=FALSE
+ WHERE h_payto=in_h_payto
+ -- this clause is a minor optimization to avoid
+ -- updating outcomes that have long expired.
+ AND expiration_time >= in_collection_time_ts;
+
+INSERT INTO legitimization_outcomes
+ (h_payto
+ ,decision_time
+ ,expiration_time
+ ,jproperties
+ ,to_investigate
+ ,jnew_rules)
+VALUES
+ (in_h_payto
+ ,in_collection_time_ts
+ ,in_expiration_time_ts
+ ,in_account_properties
+ ,in_to_investigate
+ ,in_new_rules)
+RETURNING
+ outcome_serial_id
+INTO
+ my_trigger_outcome_serial;
+
+IF in_process_row IS NOT NULL
+THEN
+ INSERT INTO kyc_attributes
+ (h_payto
+ ,collection_time
+ ,expiration_time
+ ,encrypted_attributes
+ ,legitimization_serial
+ ,trigger_outcome_serial
+ ) VALUES
+ (in_h_payto
+ ,in_collection_time_ts
+ ,in_expiration_time_ts
+ ,in_enc_attributes
+ ,in_process_row
+ ,my_trigger_outcome_serial);
+END IF;
+
+UPDATE legitimization_processes
+ SET provider_user_id=in_provider_account_id
+ ,provider_legitimization_id=in_provider_legitimization_id
+ ,expiration_time=GREATEST(expiration_time,in_expiration_time)
+ ,finished=TRUE
+ WHERE h_payto=in_h_payto
+ AND legitimization_process_serial_id=in_process_row
+ AND provider_name=in_provider_name
+ RETURNING legitimization_measure_serial_id
+ INTO my_lmsi;
+out_ok=FOUND;
+
+IF out_ok
+THEN
+ UPDATE legitimization_measures
+ SET is_finished=TRUE
+ WHERE legitimization_measure_serial_id=my_lmsi;
+END IF;
+
+UPDATE reserves
+ SET birthday=in_birthday
+ WHERE (reserve_pub IN
+ (SELECT reserve_pub
+ FROM reserves_in
+ WHERE wire_source_h_payto IN
+ (SELECT wire_source_h_payto
+ FROM wire_targets
+ WHERE h_normalized_payto=in_h_payto) ) )
+-- The next 3 clauses primarily serve to limit
+-- unnecessary updates for reserves we do not
+-- care about anymore.
+ AND ( ((current_balance).frac > 0) OR
+ ((current_balance).val > 0 ) )
+ AND (expiration_date > in_collection_time_ts);
+
+
+FOR i IN 1..COALESCE(array_length(ina_events,1),0)
+LOOP
+ ini_event = ina_events[i];
+ INSERT INTO kyc_events
+ (event_timestamp
+ ,event_type)
+ VALUES
+ (in_collection_time_ts
+ ,ini_event);
+END LOOP;
+
+EXECUTE FORMAT (
+ 'NOTIFY %s'
+ ,in_kyc_completed_notify_s);
+
+INSERT INTO kyc_alerts
+ (h_payto
+ ,trigger_type)
+ VALUES
+ (in_h_payto,1)
+ ON CONFLICT DO NOTHING;
+
+END $$;
+
+
+COMMENT ON FUNCTION exchange_do_insert_kyc_measure_result(INT8, BYTEA, INT4, TEXT, TEXT, TEXT, INT8, INT8, INT8, TEXT, TEXT, TEXT[], BYTEA, BOOL, TEXT)
+ IS 'Inserts new KYC attributes and updates the status of the legitimization process and the AML status for the account';
diff --git a/src/exchangedb/pg_insert_kyc_attributes.c b/src/exchangedb/pg_insert_kyc_attributes.c
@@ -1,126 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022, 2023, 2024 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 published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file exchangedb/pg_insert_kyc_attributes.c
- * @brief Implementation of the insert_kyc_attributes function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_insert_kyc_attributes.h"
-#include "pg_helper.h"
-
-
-/*
- * FIXME:
- * This function does *so* much more than inserting KYC attributes.
- * Sometimes it doesn't even insert KYC attributes at all.
- * => Rename?
- */
-
-enum GNUNET_DB_QueryStatus
-TEH_PG_insert_kyc_attributes (
- void *cls,
- uint64_t process_row,
- const struct TALER_NormalizedPaytoHashP *h_payto,
- uint32_t birthday,
- struct GNUNET_TIME_Timestamp collection_time,
- const char *provider_name,
- const char *provider_account_id,
- const char *provider_legitimization_id,
- struct GNUNET_TIME_Absolute expiration_time,
- const json_t *account_properties,
- const json_t *new_rules,
- bool to_investigate,
- unsigned int num_events,
- const char **events,
- size_t enc_attributes_size,
- const void *enc_attributes)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Timestamp expiration
- = GNUNET_TIME_absolute_to_timestamp (expiration_time);
- struct TALER_KycCompletedEventP rep = {
- .header.size = htons (sizeof (rep)),
- .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
- .h_payto = *h_payto
- };
- char *kyc_completed_notify_s
- = GNUNET_PQ_get_event_notify_channel (&rep.header);
- struct GNUNET_PQ_QueryParam params[] = {
- (0 == process_row)
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_uint64 (&process_row),
- GNUNET_PQ_query_param_auto_from_type (h_payto),
- GNUNET_PQ_query_param_uint32 (&birthday),
- GNUNET_PQ_query_param_string (provider_name),
- (NULL == provider_account_id)
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_string (provider_account_id),
- (NULL == provider_legitimization_id)
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_string (provider_legitimization_id),
- GNUNET_PQ_query_param_timestamp (&collection_time),
- GNUNET_PQ_query_param_absolute_time (&expiration_time),
- GNUNET_PQ_query_param_timestamp (&expiration),
- NULL == account_properties
- ? GNUNET_PQ_query_param_null ()
- : TALER_PQ_query_param_json (account_properties),
- TALER_PQ_query_param_json (new_rules),
- GNUNET_PQ_query_param_array_ptrs_string (num_events,
- events,
- pg->conn),
- GNUNET_PQ_query_param_fixed_size (enc_attributes,
- enc_attributes_size),
- GNUNET_PQ_query_param_bool (to_investigate),
- GNUNET_PQ_query_param_string (kyc_completed_notify_s),
- GNUNET_PQ_query_param_end
- };
- bool ok;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_bool ("out_ok",
- &ok),
- GNUNET_PQ_result_spec_end
- };
- enum GNUNET_DB_QueryStatus qs;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Inserting KYC attributes, wake up on %s\n",
- kyc_completed_notify_s);
- GNUNET_break (NULL != new_rules);
- GNUNET_break (NULL != h_payto);
- GNUNET_break (NULL != enc_attributes);
- PREPARE (pg,
- "insert_kyc_attributes",
- "SELECT "
- " out_ok"
- " FROM exchange_do_insert_kyc_attributes "
- "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15);");
- qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "insert_kyc_attributes",
- params,
- rs);
- GNUNET_PQ_cleanup_query_params_closures (params);
- GNUNET_free (kyc_completed_notify_s);
- GNUNET_PQ_event_do_poll (pg->conn);
- if (qs <= 0)
- return qs;
- if (! ok)
- return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
- return qs;
-}
diff --git a/src/exchangedb/pg_insert_kyc_attributes.h b/src/exchangedb/pg_insert_kyc_attributes.h
@@ -1,71 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022, 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 published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file exchangedb/pg_insert_kyc_attributes.h
- * @brief implementation of the insert_kyc_attributes function for Postgres
- * @author Christian Grothoff
- */
-#ifndef PG_INSERT_KYC_ATTRIBUTES_H
-#define PG_INSERT_KYC_ATTRIBUTES_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_exchangedb_plugin.h"
-
-
-/**
- * Store KYC attribute data, update KYC process status and
- * AML status for the given account.
- *
- * @param cls closure
- * @param process_row KYC process row to update
- * @param h_payto account for which the attribute data is stored
- * @param birthday birthdate of user, in days after 1990, or 0 if unknown or definitively adult
- * @param collection_time when was the data collected
- * @param provider_name name of the provider that provided the attributes
- * @param provider_account_id provider account ID
- * @param provider_legitimization_id provider legitimization ID
- * @param expiration_time when does the data expire
- * @param account_properties new account properties
- * @param new_rules new KYC rules to apply to the account
- * @param to_investigate true to flag account for investigation
- * @param num_events length of the @a events array
- * @param events array of KYC events to trigger
- * @param enc_attributes_size number of bytes in @a enc_attributes
- * @param enc_attributes encrypted attribute data
- * @return database transaction status
- */
-enum GNUNET_DB_QueryStatus
-TEH_PG_insert_kyc_attributes (
- void *cls,
- uint64_t process_row,
- const struct TALER_NormalizedPaytoHashP *h_payto,
- uint32_t birthday,
- struct GNUNET_TIME_Timestamp collection_time,
- const char *provider_name,
- const char *provider_account_id,
- const char *provider_legitimization_id,
- struct GNUNET_TIME_Absolute expiration_time,
- const json_t *account_properties,
- const json_t *new_rules,
- bool to_investigate,
- unsigned int num_events,
- const char **events,
- size_t enc_attributes_size,
- const void *enc_attributes);
-
-
-#endif
diff --git a/src/exchangedb/pg_insert_kyc_measure_result.c b/src/exchangedb/pg_insert_kyc_measure_result.c
@@ -0,0 +1,119 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2022, 2023, 2024 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 published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file exchangedb/pg_insert_kyc_measure_result.c
+ * @brief Implementation of the insert_kyc_measure_result function for Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_insert_kyc_measure_result.h"
+#include "pg_helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TEH_PG_insert_kyc_measure_result (
+ void *cls,
+ uint64_t process_row,
+ const struct TALER_NormalizedPaytoHashP *h_payto,
+ uint32_t birthday,
+ struct GNUNET_TIME_Timestamp collection_time,
+ const char *provider_name,
+ const char *provider_account_id,
+ const char *provider_legitimization_id,
+ struct GNUNET_TIME_Absolute expiration_time,
+ const json_t *account_properties,
+ const json_t *new_rules,
+ bool to_investigate,
+ unsigned int num_events,
+ const char **events,
+ size_t enc_attributes_size,
+ const void *enc_attributes)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_TIME_Timestamp expiration
+ = GNUNET_TIME_absolute_to_timestamp (expiration_time);
+ struct TALER_KycCompletedEventP rep = {
+ .header.size = htons (sizeof (rep)),
+ .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
+ .h_payto = *h_payto
+ };
+ char *kyc_completed_notify_s
+ = GNUNET_PQ_get_event_notify_channel (&rep.header);
+ struct GNUNET_PQ_QueryParam params[] = {
+ (0 == process_row)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_uint64 (&process_row),
+ GNUNET_PQ_query_param_auto_from_type (h_payto),
+ GNUNET_PQ_query_param_uint32 (&birthday),
+ GNUNET_PQ_query_param_string (provider_name),
+ (NULL == provider_account_id)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (provider_account_id),
+ (NULL == provider_legitimization_id)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (provider_legitimization_id),
+ GNUNET_PQ_query_param_timestamp (&collection_time),
+ GNUNET_PQ_query_param_absolute_time (&expiration_time),
+ GNUNET_PQ_query_param_timestamp (&expiration),
+ NULL == account_properties
+ ? GNUNET_PQ_query_param_null ()
+ : TALER_PQ_query_param_json (account_properties),
+ TALER_PQ_query_param_json (new_rules),
+ GNUNET_PQ_query_param_array_ptrs_string (num_events,
+ events,
+ pg->conn),
+ GNUNET_PQ_query_param_fixed_size (enc_attributes,
+ enc_attributes_size),
+ GNUNET_PQ_query_param_bool (to_investigate),
+ GNUNET_PQ_query_param_string (kyc_completed_notify_s),
+ GNUNET_PQ_query_param_end
+ };
+ bool ok;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_bool ("out_ok",
+ &ok),
+ GNUNET_PQ_result_spec_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Inserting KYC attributes, wake up on %s\n",
+ kyc_completed_notify_s);
+ GNUNET_break (NULL != new_rules);
+ GNUNET_break (NULL != h_payto);
+ GNUNET_break (NULL != enc_attributes);
+ PREPARE (pg,
+ "insert_kyc_measure_result",
+ "SELECT "
+ " out_ok"
+ " FROM exchange_do_insert_kyc_measure_result "
+ "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15);");
+ qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "insert_kyc_measure_result",
+ params,
+ rs);
+ GNUNET_PQ_cleanup_query_params_closures (params);
+ GNUNET_free (kyc_completed_notify_s);
+ GNUNET_PQ_event_do_poll (pg->conn);
+ if (qs <= 0)
+ return qs;
+ if (! ok)
+ return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
+ return qs;
+}
diff --git a/src/exchangedb/pg_insert_kyc_measure_result.h b/src/exchangedb/pg_insert_kyc_measure_result.h
@@ -0,0 +1,71 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2022, 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 published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file exchangedb/pg_insert_kyc_measure_result.h
+ * @brief implementation of the insert_kyc_measure_result function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef PG_INSERT_KYC_ATTRIBUTES_H
+#define PG_INSERT_KYC_ATTRIBUTES_H
+
+#include "taler_util.h"
+#include "taler_json_lib.h"
+#include "taler_exchangedb_plugin.h"
+
+
+/**
+ * Store KYC attribute data, update KYC process status and
+ * AML status for the given account.
+ *
+ * @param cls closure
+ * @param process_row KYC process row to update
+ * @param h_payto account for which the attribute data is stored
+ * @param birthday birthdate of user, in days after 1990, or 0 if unknown or definitively adult
+ * @param collection_time when was the data collected
+ * @param provider_name name of the provider that provided the attributes
+ * @param provider_account_id provider account ID
+ * @param provider_legitimization_id provider legitimization ID
+ * @param expiration_time when does the data expire
+ * @param account_properties new account properties
+ * @param new_rules new KYC rules to apply to the account
+ * @param to_investigate true to flag account for investigation
+ * @param num_events length of the @a events array
+ * @param events array of KYC events to trigger
+ * @param enc_attributes_size number of bytes in @a enc_attributes
+ * @param enc_attributes encrypted attribute data
+ * @return database transaction status
+ */
+enum GNUNET_DB_QueryStatus
+TEH_PG_insert_kyc_measure_result (
+ void *cls,
+ uint64_t process_row,
+ const struct TALER_NormalizedPaytoHashP *h_payto,
+ uint32_t birthday,
+ struct GNUNET_TIME_Timestamp collection_time,
+ const char *provider_name,
+ const char *provider_account_id,
+ const char *provider_legitimization_id,
+ struct GNUNET_TIME_Absolute expiration_time,
+ const json_t *account_properties,
+ const json_t *new_rules,
+ bool to_investigate,
+ unsigned int num_events,
+ const char **events,
+ size_t enc_attributes_size,
+ const void *enc_attributes);
+
+
+#endif
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -222,7 +222,7 @@
#include "pg_set_purse_balance.h"
#include "pg_reserves_update.h"
#include "pg_compute_shard.h"
-#include "pg_insert_kyc_attributes.h"
+#include "pg_insert_kyc_measure_result.h"
#include "pg_select_kyc_attributes.h"
#include "pg_insert_aml_officer.h"
#include "pg_test_aml_officer.h"
@@ -805,8 +805,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
= &TEH_PG_set_purse_balance;
plugin->get_pending_kyc_requirement_process
= &TEH_PG_get_pending_kyc_requirement_process;
- plugin->insert_kyc_attributes
- = &TEH_PG_insert_kyc_attributes;
+ plugin->insert_kyc_measure_result
+ = &TEH_PG_insert_kyc_measure_result;
plugin->select_kyc_attributes
= &TEH_PG_select_kyc_attributes;
plugin->insert_aml_officer
diff --git a/src/exchangedb/procedures.sql.in b/src/exchangedb/procedures.sql.in
@@ -45,7 +45,7 @@ SET search_path TO exchange;
#include "exchange_do_insert_or_update_policy_details.sql"
#include "exchange_do_insert_aml_decision.sql"
#include "exchange_do_insert_aml_officer.sql"
-#include "exchange_do_insert_kyc_attributes.sql"
+#include "exchange_do_insert_kyc_measure_result.sql"
#include "exchange_do_reserves_in_insert.sql"
#include "exchange_do_batch_reserves_update.sql"
#include "exchange_do_get_link_data.sql"
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
@@ -7297,7 +7297,7 @@ struct TALER_EXCHANGEDB_Plugin
* @return database transaction status
*/
enum GNUNET_DB_QueryStatus
- (*insert_kyc_attributes)(
+ (*insert_kyc_measure_result)(
void *cls,
uint64_t process_row,
const struct TALER_NormalizedPaytoHashP *h_payto,