commit 7ff7d48f8aabd3196f4e61d97eb7c6320d09627e
parent ddf0baf2b5e1ebeee37abc122de2227a3f0a6b03
Author: Florian Dold <dold@taler.net>
Date: Mon, 7 Sep 2026 22:04:10 +0200
exchange database: correct KYC and transaction statement naming
Rename the KYC process completion helper with the approved update_
prefix and update its callers and prepared statement. Allow start,
commit and rollback statement owners in the shared auditor transaction
module while retaining the other naming and uniqueness rules.
Diffstat:
8 files changed, 165 insertions(+), 158 deletions(-)
diff --git a/contrib/check-db-naming.py b/contrib/check-db-naming.py
@@ -41,6 +41,11 @@ EXEMPT = {
"account_history", "exchangedb_accounts", "exchangedb_transactions",
}
+# Transaction functions intentionally share this implementation file.
+STATEMENT_OWNERS = {
+ "src/auditordb/start.c": ("start", "commit", "rollback"),
+}
+
# Files that are not part of the API surface at all.
SKIP = {"pg", "template", "helper", "bench_db"}
@@ -78,8 +83,10 @@ def check_layer(impl_dir, hdr_dir, prefix):
text = c.read_text(errors="replace")
# 5. prepared statements named after the function
+ owners = STATEMENT_OWNERS.get(c.as_posix(), (stem,))
for s in dict.fromkeys(PREP.findall(text)):
- if s != stem and not s.startswith(stem + "_"):
+ if not any(s == owner or s.startswith(owner + "_")
+ for owner in owners):
errors.append(
f"{c}: prepared statement '{s}' is not named after '{stem}'")
# 6. cross-file uniqueness
diff --git a/src/exchange/taler-exchange-httpd_post-kyc-start-ID.c b/src/exchange/taler-exchange-httpd_post-kyc-start-ID.c
@@ -29,7 +29,7 @@
#include "taler-exchange-httpd_get-keys.h"
#include "taler-exchange-httpd_post-kyc-start-ID.h"
#include "taler-exchange-httpd_responses.h"
-#include "exchange-database/complete_legitimization_process_start.h"
+#include "exchange-database/update_legitimization_process_start.h"
#include "exchange-database/do_reserve_legitimization_process.h"
#include "exchange-database/get_pending_legitimization.h"
@@ -302,7 +302,7 @@ initiate_cb (
(TALER_EC_NONE == ec)
? redirect_url
: error_msg_hint);
- qs = TALER_EXCHANGEDB_complete_legitimization_process_start (
+ qs = TALER_EXCHANGEDB_update_legitimization_process_start (
TEH_pg,
kyp->process_row,
kyp->process_start_time,
@@ -327,7 +327,7 @@ initiate_cb (
? TALER_EC_GENERIC_DB_STORE_FAILED
: TALER_EC_EXCHANGE_KYC_GENERIC_PROVIDER_TIMEOUT;
kyp->hint = GNUNET_strdup ((qs < 0)
- ? "complete_legitimization_process_start"
+ ? "update_legitimization_process_start"
: "KYC process initiation was superseded");
}
else
@@ -446,7 +446,7 @@ reserve_and_start_process (struct KycPoller *kyp)
kyp);
if (NULL == kyp->ih)
{
- qs = TALER_EXCHANGEDB_complete_legitimization_process_start (
+ qs = TALER_EXCHANGEDB_update_legitimization_process_start (
TEH_pg,
kyp->process_row,
kyp->process_start_time,
@@ -465,7 +465,7 @@ reserve_and_start_process (struct KycPoller *kyp)
kyp->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_STORE_FAILED,
- "complete_legitimization_process_start");
+ "update_legitimization_process_start");
return TALER_MHD_reply_with_error (
kyp->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
diff --git a/src/exchangedb/complete_legitimization_process_start.c b/src/exchangedb/complete_legitimization_process_start.c
@@ -1,82 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2026 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/complete_legitimization_process_start.c
- * @brief conditionally complete external KYC process initiation
- */
-#include "taler/taler_pq_lib.h"
-#include "exchange-database/complete_legitimization_process_start.h"
-#include "helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TALER_EXCHANGEDB_complete_legitimization_process_start (
- struct TALER_EXCHANGEDB_PostgresContext *pg,
- uint64_t process_row,
- struct GNUNET_TIME_Absolute expected_start_time,
- const char *provider_name,
- const struct TALER_NormalizedPaytoHashP *h_payto,
- const char *provider_account_id,
- const char *provider_legitimization_id,
- const char *redirect_url,
- struct GNUNET_TIME_Absolute process_expiration,
- enum TALER_ErrorCode ec,
- const char *error_message_hint,
- bool finished)
-{
- uint32_t ec32 = (uint32_t) ec;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&process_row),
- GNUNET_PQ_query_param_absolute_time (&expected_start_time),
- GNUNET_PQ_query_param_string (provider_name),
- GNUNET_PQ_query_param_auto_from_type (h_payto),
- (NULL != provider_account_id)
- ? GNUNET_PQ_query_param_string (provider_account_id)
- : GNUNET_PQ_query_param_null (),
- (NULL != provider_legitimization_id)
- ? GNUNET_PQ_query_param_string (provider_legitimization_id)
- : GNUNET_PQ_query_param_null (),
- (NULL != redirect_url)
- ? GNUNET_PQ_query_param_string (redirect_url)
- : GNUNET_PQ_query_param_null (),
- GNUNET_PQ_query_param_absolute_time (&process_expiration),
- GNUNET_PQ_query_param_uint32 (&ec32),
- (NULL != error_message_hint)
- ? GNUNET_PQ_query_param_string (error_message_hint)
- : GNUNET_PQ_query_param_null (),
- GNUNET_PQ_query_param_bool (finished),
- GNUNET_PQ_query_param_end
- };
-
- PREPARE (pg,
- "complete_legitimization_process_start",
- "UPDATE legitimization_processes"
- " SET provider_user_id=$5"
- " ,provider_legitimization_id=$6"
- " ,redirect_url=$7"
- " ,process_expiration_time=$8"
- " ,error_code=$9"
- " ,error_message=$10"
- " ,finished=$11"
- " WHERE legitimization_process_serial_id=$1"
- " AND start_time=$2"
- " AND provider_name=$3"
- " AND h_payto=$4;");
- return GNUNET_PQ_eval_prepared_non_select (
- pg->conn,
- "complete_legitimization_process_start",
- params);
-}
diff --git a/src/exchangedb/meson.build b/src/exchangedb/meson.build
@@ -252,7 +252,7 @@ libtalerexchangedb = library(
'get_exists_aml_officer.c',
'do_trigger_kyc_rule_for_account.c',
'do_reserve_legitimization_process.c',
- 'complete_legitimization_process_start.c',
+ 'update_legitimization_process_start.c',
'update_aggregation_transient.c',
'update_auditor.c',
'update_legitimization_process_by_row.c',
diff --git a/src/exchangedb/test_legitimization_processes.c b/src/exchangedb/test_legitimization_processes.c
@@ -22,7 +22,7 @@
* Covers #TALER_EXCHANGEDB_insert_legitimization_process(),
* #TALER_EXCHANGEDB_update_legitimization_process_by_row(),
* #TALER_EXCHANGEDB_do_reserve_legitimization_process(),
- * #TALER_EXCHANGEDB_complete_legitimization_process_start(),
+ * #TALER_EXCHANGEDB_update_legitimization_process_start(),
* #TALER_EXCHANGEDB_insert_kyc_failure(),
* #TALER_EXCHANGEDB_insert_aml_program_failure(),
* #TALER_EXCHANGEDB_get_legitimization_process_by_account(),
@@ -37,7 +37,7 @@
* "redirect known" to "finished".
*/
#include "test_common.h"
-#include "exchange-database/complete_legitimization_process_start.h"
+#include "exchange-database/update_legitimization_process_start.h"
#include "exchange-database/do_reserve_legitimization_process.h"
#include "exchange-database/do_trigger_kyc_rule_for_account.h"
#include "exchange-database/get_kyc_provider_account.h"
@@ -640,7 +640,7 @@ check_reservation (struct TALER_EXCHANGEDB_PostgresContext *pg)
FAILIF (NULL != redirect_url);
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- TALER_EXCHANGEDB_complete_legitimization_process_start (
+ TALER_EXCHANGEDB_update_legitimization_process_start (
pg,
row,
start_time,
@@ -682,7 +682,7 @@ check_reservation (struct TALER_EXCHANGEDB_PostgresContext *pg)
start_time,
GNUNET_TIME_UNIT_SECONDS);
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
- TALER_EXCHANGEDB_complete_legitimization_process_start (
+ TALER_EXCHANGEDB_update_legitimization_process_start (
pg,
row,
other_start_time,
diff --git a/src/exchangedb/update_legitimization_process_start.c b/src/exchangedb/update_legitimization_process_start.c
@@ -0,0 +1,82 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2026 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/update_legitimization_process_start.c
+ * @brief conditionally complete external KYC process initiation
+ */
+#include "taler/taler_pq_lib.h"
+#include "exchange-database/update_legitimization_process_start.h"
+#include "helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TALER_EXCHANGEDB_update_legitimization_process_start (
+ struct TALER_EXCHANGEDB_PostgresContext *pg,
+ uint64_t process_row,
+ struct GNUNET_TIME_Absolute expected_start_time,
+ const char *provider_name,
+ const struct TALER_NormalizedPaytoHashP *h_payto,
+ const char *provider_account_id,
+ const char *provider_legitimization_id,
+ const char *redirect_url,
+ struct GNUNET_TIME_Absolute process_expiration,
+ enum TALER_ErrorCode ec,
+ const char *error_message_hint,
+ bool finished)
+{
+ uint32_t ec32 = (uint32_t) ec;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_uint64 (&process_row),
+ GNUNET_PQ_query_param_absolute_time (&expected_start_time),
+ GNUNET_PQ_query_param_string (provider_name),
+ GNUNET_PQ_query_param_auto_from_type (h_payto),
+ (NULL != provider_account_id)
+ ? GNUNET_PQ_query_param_string (provider_account_id)
+ : GNUNET_PQ_query_param_null (),
+ (NULL != provider_legitimization_id)
+ ? GNUNET_PQ_query_param_string (provider_legitimization_id)
+ : GNUNET_PQ_query_param_null (),
+ (NULL != redirect_url)
+ ? GNUNET_PQ_query_param_string (redirect_url)
+ : GNUNET_PQ_query_param_null (),
+ GNUNET_PQ_query_param_absolute_time (&process_expiration),
+ GNUNET_PQ_query_param_uint32 (&ec32),
+ (NULL != error_message_hint)
+ ? GNUNET_PQ_query_param_string (error_message_hint)
+ : GNUNET_PQ_query_param_null (),
+ GNUNET_PQ_query_param_bool (finished),
+ GNUNET_PQ_query_param_end
+ };
+
+ PREPARE (pg,
+ "update_legitimization_process_start",
+ "UPDATE legitimization_processes"
+ " SET provider_user_id=$5"
+ " ,provider_legitimization_id=$6"
+ " ,redirect_url=$7"
+ " ,process_expiration_time=$8"
+ " ,error_code=$9"
+ " ,error_message=$10"
+ " ,finished=$11"
+ " WHERE legitimization_process_serial_id=$1"
+ " AND start_time=$2"
+ " AND provider_name=$3"
+ " AND h_payto=$4;");
+ return GNUNET_PQ_eval_prepared_non_select (
+ pg->conn,
+ "update_legitimization_process_start",
+ params);
+}
diff --git a/src/include/exchange-database/complete_legitimization_process_start.h b/src/include/exchange-database/complete_legitimization_process_start.h
@@ -1,65 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2026 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 src/include/exchange-database/complete_legitimization_process_start.h
- * @brief conditionally complete external KYC process initiation
- */
-#ifndef EXCHANGE_DATABASE_COMPLETE_LEGITIMIZATION_PROCESS_START_H
-#define EXCHANGE_DATABASE_COMPLETE_LEGITIMIZATION_PROCESS_START_H
-
-#include "taler/taler_error_codes.h"
-#include "taler/taler_util.h"
-#include "exchangedb_lib.h"
-
-
-/**
- * Store the result of provider initiation if the caller still owns the
- * process generation. Matching @a expected_start_time prevents a late
- * callback from overwriting a newer initiation in the same row.
- *
- * Primary test table: `legitimization_processes` (see
- * test_legitimization_processes.c).
- *
- * @param pg database context
- * @param process_row process row to update
- * @param expected_start_time generation the caller reserved
- * @param provider_name expected provider configuration name
- * @param h_payto expected account
- * @param provider_account_id account identifier returned by provider, or NULL
- * @param provider_legitimization_id process identifier returned by provider, or NULL
- * @param redirect_url provider redirect URL, or NULL on failure
- * @param process_expiration time until the unfinished process may be reused
- * @param ec initiation result
- * @param error_message_hint optional human-readable error details
- * @param finished true if initiation failed and the process is finished
- * @return one result if updated, no results if superseded, negative on error
- */
-enum GNUNET_DB_QueryStatus
-TALER_EXCHANGEDB_complete_legitimization_process_start (
- struct TALER_EXCHANGEDB_PostgresContext *pg,
- uint64_t process_row,
- struct GNUNET_TIME_Absolute expected_start_time,
- const char *provider_name,
- const struct TALER_NormalizedPaytoHashP *h_payto,
- const char *provider_account_id,
- const char *provider_legitimization_id,
- const char *redirect_url,
- struct GNUNET_TIME_Absolute process_expiration,
- enum TALER_ErrorCode ec,
- const char *error_message_hint,
- bool finished);
-
-#endif
diff --git a/src/include/exchange-database/update_legitimization_process_start.h b/src/include/exchange-database/update_legitimization_process_start.h
@@ -0,0 +1,65 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2026 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 src/include/exchange-database/update_legitimization_process_start.h
+ * @brief conditionally complete external KYC process initiation
+ */
+#ifndef EXCHANGE_DATABASE_UPDATE_LEGITIMIZATION_PROCESS_START_H
+#define EXCHANGE_DATABASE_UPDATE_LEGITIMIZATION_PROCESS_START_H
+
+#include "taler/taler_error_codes.h"
+#include "taler/taler_util.h"
+#include "exchangedb_lib.h"
+
+
+/**
+ * Store the result of provider initiation if the caller still owns the
+ * process generation. Matching @a expected_start_time prevents a late
+ * callback from overwriting a newer initiation in the same row.
+ *
+ * Primary test table: `legitimization_processes` (see
+ * test_legitimization_processes.c).
+ *
+ * @param pg database context
+ * @param process_row process row to update
+ * @param expected_start_time generation the caller reserved
+ * @param provider_name expected provider configuration name
+ * @param h_payto expected account
+ * @param provider_account_id account identifier returned by provider, or NULL
+ * @param provider_legitimization_id process identifier returned by provider, or NULL
+ * @param redirect_url provider redirect URL, or NULL on failure
+ * @param process_expiration time until the unfinished process may be reused
+ * @param ec initiation result
+ * @param error_message_hint optional human-readable error details
+ * @param finished true if initiation failed and the process is finished
+ * @return one result if updated, no results if superseded, negative on error
+ */
+enum GNUNET_DB_QueryStatus
+TALER_EXCHANGEDB_update_legitimization_process_start (
+ struct TALER_EXCHANGEDB_PostgresContext *pg,
+ uint64_t process_row,
+ struct GNUNET_TIME_Absolute expected_start_time,
+ const char *provider_name,
+ const struct TALER_NormalizedPaytoHashP *h_payto,
+ const char *provider_account_id,
+ const char *provider_legitimization_id,
+ const char *redirect_url,
+ struct GNUNET_TIME_Absolute process_expiration,
+ enum TALER_ErrorCode ec,
+ const char *error_message_hint,
+ bool finished);
+
+#endif