commit fc42920ac83729a3181ff6a27c75b77c05dd1f76
parent 99d671b4f2c1f543c7016892038c170f4dc5674e
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 22 Jul 2026 03:16:08 +0200
merchantdb: name the account_kyc functions verb-first
Diffstat:
27 files changed, 920 insertions(+), 920 deletions(-)
diff --git a/src/backend/taler-merchant-depositcheck.c b/src/backend/taler-merchant-depositcheck.c
@@ -33,7 +33,7 @@ struct ExchangeInteraction;
#include "merchant-database/lookup_pending_deposits.h"
#include "merchant-database/select_exchange_keys.h"
#include "merchant-database/preflight.h"
-#include "merchant-database/account_kyc_set_failed.h"
+#include "merchant-database/insert_kyc_failure.h"
#include "merchant-database/set_instance.h"
#include "merchant-database/insert_deposit_to_transfer.h"
#include "merchant-database/update_deposit_confirmation_status.h"
@@ -473,7 +473,7 @@ deposit_get_cb (
dr->details.accepted.kyc_ok,
TALER_B2S (&w->coin_pub));
now = GNUNET_TIME_timestamp_get ();
- qs = TALER_MERCHANTDB_account_kyc_set_failed (
+ qs = TALER_MERCHANTDB_insert_kyc_failure (
pg,
w->instance_id,
&w->h_wire,
diff --git a/src/backend/taler-merchant-httpd_get-private-kyc.c b/src/backend/taler-merchant-httpd_get-private-kyc.c
@@ -31,7 +31,7 @@
#include <taler/taler_templating_lib.h>
#include <taler/taler_dbevents.h>
#include <regex.h>
-#include "merchant-database/account_kyc_get_status.h"
+#include "merchant-database/iterate_kyc_statuses.h"
#include "merchant-database/event_listen.h"
#include "merchant-database/set_instance.h"
#include "merchant-database/lookup_tos_accepted_early.h"
@@ -1403,7 +1403,7 @@ phase_database_kyc_check (struct KycContext *kc)
GNUNET_break (0 ==
json_array_clear (kc->kycs_data));
kc->in_db = true;
- qs = TALER_MERCHANTDB_account_kyc_get_status (
+ qs = TALER_MERCHANTDB_iterate_kyc_statuses (
TMH_db,
kc->mi->settings.id,
kc->have_h_wire
diff --git a/src/backend/taler-merchant-kyccheck.c b/src/backend/taler-merchant-kyccheck.c
@@ -36,8 +36,8 @@ struct Inquiry;
#include "taler/taler_merchant_bank_lib.h"
#include "merchantdb_lib.h"
#include "merchantdb_lib.h"
-#include "merchant-database/account_kyc_get_outdated.h"
-#include "merchant-database/account_kyc_set_status.h"
+#include "merchant-database/iterate_outdated_kyc_statuses.h"
+#include "merchant-database/insert_kyc_status.h"
#include "merchant-database/delete_tos_accepted_early.h"
#include "merchant-database/get_kyc_status.h"
#include "merchant-database/lookup_tos_accepted_early.h"
@@ -1074,7 +1074,7 @@ exchange_check_cb (
GNUNET_SCHEDULER_shutdown ();
return;
}
- qs = TALER_MERCHANTDB_account_kyc_set_status (
+ qs = TALER_MERCHANTDB_insert_kyc_status (
pg,
i->a->instance_id,
&i->a->h_wire,
@@ -1404,7 +1404,7 @@ flag_ineligible (const char *instance_id,
GNUNET_SCHEDULER_shutdown ();
return;
}
- qs = TALER_MERCHANTDB_account_kyc_set_status (
+ qs = TALER_MERCHANTDB_insert_kyc_status (
pg,
instance_id,
h_wire,
@@ -2050,7 +2050,7 @@ update_forced (void *cls,
(void) cls;
(void) extra;
(void) extra_size;
- qs = TALER_MERCHANTDB_account_kyc_get_outdated (
+ qs = TALER_MERCHANTDB_iterate_outdated_kyc_statuses (
pg,
&force_check_now,
NULL);
diff --git a/src/backenddb/account_kyc_get_outdated.c b/src/backenddb/account_kyc_get_outdated.c
@@ -1,146 +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/backenddb/account_kyc_get_outdated.c
- * @brief Implementation of the account_kyc_get_outdated function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include <taler/taler_error_codes.h>
-#include <taler/taler_dbevents.h>
-#include <taler/taler_pq_lib.h>
-#include "merchant-database/account_kyc_get_outdated.h"
-#include "helper.h"
-
-/**
- * Closure for kyc_status_cb().
- */
-struct KycStatusContext
-{
- /**
- * Function to call with results.
- */
- TALER_MERCHANTDB_KycOutdatedCallback kyc_cb;
-
- /**
- * Closure for @e kyc_cb.
- */
- void *kyc_cb_cls;
-
- /**
- * Number of results found.
- */
- unsigned int count;
-
- /**
- * Set to true on failure(s).
- */
- bool failure;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results about accounts.
- *
- * @param[in,out] cls of type `struct KycStatusContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-kyc_status_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct KycStatusContext *ksc = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Got %u outdated KYC records\n",
- num_results);
- for (unsigned int i = 0; i < num_results; i++)
- {
- struct TALER_MerchantWireHashP h_wire;
- char *exchange_url;
- char *instance_id;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("out_h_wire",
- &h_wire),
- GNUNET_PQ_result_spec_string ("out_exchange_url",
- &exchange_url),
- GNUNET_PQ_result_spec_string ("out_merchant_id",
- &instance_id),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- ksc->failure = true;
- return;
- }
- ksc->count++;
- ksc->kyc_cb (ksc->kyc_cb_cls,
- instance_id,
- exchange_url,
- &h_wire);
- GNUNET_PQ_cleanup_result (rs);
- }
-}
-
-
-enum GNUNET_DB_QueryStatus
-TALER_MERCHANTDB_account_kyc_get_outdated (
- struct TALER_MERCHANTDB_PostgresContext *pg,
- TALER_MERCHANTDB_KycOutdatedCallback kyc_cb,
- void *kyc_cb_cls)
-{
- struct KycStatusContext ksc = {
- .kyc_cb = kyc_cb,
- .kyc_cb_cls = kyc_cb_cls
- };
- struct GNUNET_TIME_Absolute now
- = GNUNET_TIME_absolute_get ();
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_absolute_time (&now),
- GNUNET_PQ_query_param_end
- };
- enum GNUNET_DB_QueryStatus qs;
-
- PREPARE (pg,
- "account_kyc_get_outdated",
- "SELECT"
- " out_merchant_id"
- " ,out_h_wire"
- " ,out_exchange_url"
- " FROM merchant.account_kyc_get_outdated($1)");
- qs = GNUNET_PQ_eval_prepared_multi_select (
- pg->conn,
- "account_kyc_get_outdated",
- params,
- &kyc_status_cb,
- &ksc);
- if (ksc.failure)
- {
- GNUNET_break (0);
- return GNUNET_DB_STATUS_HARD_ERROR;
- }
- if (0 > qs)
- return qs;
- return ksc.count;
-}
diff --git a/src/backenddb/account_kyc_get_status.c b/src/backenddb/account_kyc_get_status.c
@@ -1,215 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022, 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/backenddb/account_kyc_get_status.c
- * @brief Implementation of the account_kyc_get_status function for Postgres
- * @author Iván Ávalos
- */
-#include "platform.h"
-#include <taler/taler_pq_lib.h>
-#include "merchant-database/account_kyc_get_status.h"
-#include "helper.h"
-
-/**
- * Closure for kyc_status_cb().
- */
-struct KycStatusContext
-{
- /**
- * Function to call with results.
- */
- TALER_MERCHANTDB_KycCallback kyc_cb;
-
- /**
- * Closure for @e kyc_cb.
- */
- void *kyc_cb_cls;
-
- /**
- * Number of results found.
- */
- unsigned int count;
-
- /**
- * Set to true on failure(s).
- */
- bool failure;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results about accounts.
- *
- * @param[in,out] cls of type `struct KycStatusContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-kyc_status_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct KycStatusContext *ksc = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Got %u KYC records\n",
- num_results);
- for (unsigned int i = 0; i < num_results; i++)
- {
- struct TALER_MerchantWireHashP h_wire;
- char *exchange_url = NULL;
- struct TALER_FullPayto payto_uri;
- struct GNUNET_TIME_Timestamp last_check
- = GNUNET_TIME_UNIT_ZERO_TS;
- bool kyc_ok = false;
- struct TALER_AccountAccessTokenP access_token;
- bool no_auth = false;
- uint32_t h32 = 0;
- uint32_t e32 = 0;
- bool in_aml_review = false;
- bool no_mk; /* left join on merchant_kyc table yielded nothing */
- json_t *jlimits = NULL;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("h_wire",
- &h_wire),
- GNUNET_PQ_result_spec_string ("payto_uri",
- &payto_uri.full_payto),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_string ("exchange_url",
- &exchange_url),
- &no_mk),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_timestamp ("kyc_timestamp",
- &last_check),
- &no_mk),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_bool ("kyc_ok",
- &kyc_ok),
- &no_mk),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_auto_from_type ("access_token",
- &access_token),
- &no_auth),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_uint32 ("exchange_http_status",
- &h32),
- &no_mk),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_uint32 ("exchange_ec_code",
- &e32),
- &no_mk),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_bool ("aml_review",
- &in_aml_review),
- &no_mk),
- GNUNET_PQ_result_spec_allow_null (
- TALER_PQ_result_spec_json ("jaccount_limits",
- &jlimits),
- NULL),
- GNUNET_PQ_result_spec_end
- };
- unsigned int last_http_status;
- enum TALER_ErrorCode last_ec;
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- ksc->failure = true;
- return;
- }
- last_http_status = (unsigned int) h32;
- last_ec = (enum TALER_ErrorCode) (int) e32;
- ksc->count++;
- ksc->kyc_cb (ksc->kyc_cb_cls,
- &h_wire,
- payto_uri,
- exchange_url,
- last_check,
- kyc_ok,
- (no_auth)
- ? NULL
- : &access_token,
- last_http_status,
- last_ec,
- in_aml_review,
- jlimits);
- GNUNET_PQ_cleanup_result (rs);
- }
-}
-
-
-enum GNUNET_DB_QueryStatus
-TALER_MERCHANTDB_account_kyc_get_status (
- struct TALER_MERCHANTDB_PostgresContext *pg,
- const char *merchant_id,
- const struct TALER_MerchantWireHashP *h_wire,
- const char *exchange_url,
- TALER_MERCHANTDB_KycCallback kyc_cb,
- void *kyc_cb_cls)
-{
- struct KycStatusContext ksc = {
- .kyc_cb = kyc_cb,
- .kyc_cb_cls = kyc_cb_cls
- };
- struct GNUNET_TIME_Absolute now
- = GNUNET_TIME_absolute_get ();
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_absolute_time (&now),
- NULL == exchange_url
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_string (exchange_url),
- NULL == h_wire
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_auto_from_type (h_wire),
- GNUNET_PQ_query_param_end
- };
- enum GNUNET_DB_QueryStatus qs;
-
- GNUNET_assert (NULL != pg->current_merchant_id);
- GNUNET_assert (0 == strcmp (merchant_id,
- pg->current_merchant_id));
- TMH_PQ_prepare_anon (pg,
- "SELECT "
- " out_h_wire AS h_wire"
- " ,out_payto_uri AS payto_uri"
- " ,out_exchange_url AS exchange_url"
- " ,out_kyc_timestamp AS kyc_timestamp"
- " ,out_kyc_ok AS kyc_ok"
- " ,out_access_token AS access_token"
- " ,out_exchange_http_status AS exchange_http_status"
- " ,out_exchange_ec_code AS exchange_ec_code"
- " ,out_aml_review AS aml_review"
- " ,out_jaccount_limits::TEXT AS jaccount_limits"
- " FROM merchant_do_account_kyc_get_status($1, $2, $3);");
- qs = GNUNET_PQ_eval_prepared_multi_select (
- pg->conn,
- "",
- params,
- &kyc_status_cb,
- &ksc);
- if (ksc.failure)
- {
- GNUNET_break (0);
- return GNUNET_DB_STATUS_HARD_ERROR;
- }
- if (0 > qs)
- return qs;
- return ksc.count;
-}
diff --git a/src/backenddb/account_kyc_set_failed.c b/src/backenddb/account_kyc_set_failed.c
@@ -1,94 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 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 src/backenddb/account_kyc_set_failed.c
- * @brief Implementation of the account_kyc_set_failed function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include <taler/taler_dbevents.h>
-#include <taler/taler_pq_lib.h>
-#include "merchant-database/account_kyc_set_failed.h"
-#include "helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TALER_MERCHANTDB_account_kyc_set_failed (
- struct TALER_MERCHANTDB_PostgresContext *pg,
- const char *merchant_id,
- const struct TALER_MerchantWireHashP *h_wire,
- const char *exchange_url,
- struct GNUNET_TIME_Timestamp timestamp,
- unsigned int exchange_http_status,
- bool kyc_ok)
-{
- struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = {
- .header.size = htons (sizeof (ev)),
- .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED),
- .h_wire = *h_wire
- };
- struct GNUNET_DB_EventHeaderP hdr = {
- .size = htons (sizeof (hdr)),
- .type = htons (TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED)
- };
- char *notify_s
- = GNUNET_PQ_get_event_notify_channel (&ev.header);
- char *notify2_s
- = GNUNET_PQ_get_event_notify_channel (&hdr);
- uint32_t http_status32 = (uint32_t) exchange_http_status;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (h_wire),
- GNUNET_PQ_query_param_string (exchange_url),
- GNUNET_PQ_query_param_timestamp (×tamp),
- GNUNET_PQ_query_param_uint32 (&http_status32),
- GNUNET_PQ_query_param_bool (kyc_ok),
- GNUNET_PQ_query_param_string (notify_s),
- GNUNET_PQ_query_param_string (notify2_s),
- GNUNET_PQ_query_param_end
- };
- bool no_account;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_bool ("no_account",
- &no_account),
- GNUNET_PQ_result_spec_end
- };
- enum GNUNET_DB_QueryStatus qs;
-
- GNUNET_assert (NULL != pg->current_merchant_id);
- GNUNET_assert (0 == strcmp (merchant_id,
- pg->current_merchant_id));
- TMH_PQ_prepare_anon (pg,
- "SELECT "
- " out_no_account AS no_account"
- " FROM merchant_do_account_kyc_set_failed"
- "($1, $2, $3, $4, $5, $6, $7);");
- qs = GNUNET_PQ_eval_prepared_singleton_select (
- pg->conn,
- "",
- params,
- rs);
- GNUNET_free (notify_s);
- GNUNET_free (notify2_s);
- if (qs <= 0)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
- GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
- GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
- return qs;
- }
- GNUNET_break (! no_account);
- return qs;
-}
diff --git a/src/backenddb/account_kyc_set_status.c b/src/backenddb/account_kyc_set_status.c
@@ -1,115 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022-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 src/backenddb/account_kyc_set_status.c
- * @brief Implementation of the account_kyc_set_status function for Postgres
- * @author Iván Ávalos
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include <taler/taler_dbevents.h>
-#include <taler/taler_pq_lib.h>
-#include "merchant-database/account_kyc_set_status.h"
-#include "helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TALER_MERCHANTDB_account_kyc_set_status (
- struct TALER_MERCHANTDB_PostgresContext *pg,
- const char *merchant_id,
- const struct TALER_MerchantWireHashP *h_wire,
- const char *exchange_url,
- struct GNUNET_TIME_Timestamp timestamp,
- struct GNUNET_TIME_Absolute next_time,
- struct GNUNET_TIME_Relative kyc_backoff,
- unsigned int exchange_http_status,
- enum TALER_ErrorCode exchange_ec_code,
- uint64_t rule_gen,
- const struct TALER_AccountAccessTokenP *access_token,
- const json_t *jlimits,
- bool in_aml_review,
- bool kyc_ok)
-{
- struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = {
- .header.size = htons (sizeof (ev)),
- .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED),
- .h_wire = *h_wire
- };
- struct GNUNET_DB_EventHeaderP hdr = {
- .size = htons (sizeof (hdr)),
- .type = htons (TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED)
- };
- char *notify_s
- = GNUNET_PQ_get_event_notify_channel (&ev.header);
- char *notify2_s
- = GNUNET_PQ_get_event_notify_channel (&hdr);
- uint32_t http_status32 = (uint32_t) exchange_http_status;
- uint32_t ec_code32 = (uint32_t) exchange_ec_code;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (h_wire),
- GNUNET_PQ_query_param_string (exchange_url),
- GNUNET_PQ_query_param_timestamp (×tamp),
- GNUNET_PQ_query_param_uint32 (&http_status32),
- GNUNET_PQ_query_param_uint32 (&ec_code32),
- NULL != access_token
- ? GNUNET_PQ_query_param_auto_from_type (access_token)
- : GNUNET_PQ_query_param_null (),
- NULL != jlimits
- ? TALER_PQ_query_param_json (jlimits)
- : GNUNET_PQ_query_param_null (),
- GNUNET_PQ_query_param_bool (in_aml_review),
- GNUNET_PQ_query_param_bool (kyc_ok),
- GNUNET_PQ_query_param_string (notify_s),
- GNUNET_PQ_query_param_string (notify2_s),
- GNUNET_PQ_query_param_uint64 (&rule_gen),
- GNUNET_PQ_query_param_absolute_time (&next_time),
- GNUNET_PQ_query_param_relative_time (&kyc_backoff),
- GNUNET_PQ_query_param_end
- };
- bool no_account;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_bool ("no_account",
- &no_account),
- GNUNET_PQ_result_spec_end
- };
- enum GNUNET_DB_QueryStatus qs;
-
- GNUNET_assert (NULL != pg->current_merchant_id);
- GNUNET_assert (0 == strcmp (merchant_id,
- pg->current_merchant_id));
- TMH_PQ_prepare_anon (pg,
- "SELECT "
- " out_no_account AS no_account"
- " FROM merchant_do_account_kyc_set_status"
- "($1, $2, $3, $4, $5, $6, $7::TEXT::JSONB"
- ",$8, $9, $10, $11, $12, $13, $14);");
- qs = GNUNET_PQ_eval_prepared_singleton_select (
- pg->conn,
- "",
- params,
- rs);
- GNUNET_free (notify_s);
- GNUNET_free (notify2_s);
- if (qs <= 0)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
- GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
- GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
- return qs;
- }
- GNUNET_break (! no_account);
- return qs;
-}
diff --git a/src/backenddb/insert_kyc_failure.c b/src/backenddb/insert_kyc_failure.c
@@ -0,0 +1,94 @@
+/*
+ This file is part of TALER
+ Copyright (C) 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 src/backenddb/insert_kyc_failure.c
+ * @brief Implementation of the insert_kyc_failure function for Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
+#include "merchant-database/insert_kyc_failure.h"
+#include "helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_insert_kyc_failure (
+ struct TALER_MERCHANTDB_PostgresContext *pg,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp timestamp,
+ unsigned int exchange_http_status,
+ bool kyc_ok)
+{
+ struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = {
+ .header.size = htons (sizeof (ev)),
+ .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED),
+ .h_wire = *h_wire
+ };
+ struct GNUNET_DB_EventHeaderP hdr = {
+ .size = htons (sizeof (hdr)),
+ .type = htons (TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED)
+ };
+ char *notify_s
+ = GNUNET_PQ_get_event_notify_channel (&ev.header);
+ char *notify2_s
+ = GNUNET_PQ_get_event_notify_channel (&hdr);
+ uint32_t http_status32 = (uint32_t) exchange_http_status;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (h_wire),
+ GNUNET_PQ_query_param_string (exchange_url),
+ GNUNET_PQ_query_param_timestamp (×tamp),
+ GNUNET_PQ_query_param_uint32 (&http_status32),
+ GNUNET_PQ_query_param_bool (kyc_ok),
+ GNUNET_PQ_query_param_string (notify_s),
+ GNUNET_PQ_query_param_string (notify2_s),
+ GNUNET_PQ_query_param_end
+ };
+ bool no_account;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_bool ("no_account",
+ &no_account),
+ GNUNET_PQ_result_spec_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ GNUNET_assert (NULL != pg->current_merchant_id);
+ GNUNET_assert (0 == strcmp (merchant_id,
+ pg->current_merchant_id));
+ TMH_PQ_prepare_anon (pg,
+ "SELECT "
+ " out_no_account AS no_account"
+ " FROM merchant_do_account_kyc_set_failed"
+ "($1, $2, $3, $4, $5, $6, $7);");
+ qs = GNUNET_PQ_eval_prepared_singleton_select (
+ pg->conn,
+ "",
+ params,
+ rs);
+ GNUNET_free (notify_s);
+ GNUNET_free (notify2_s);
+ if (qs <= 0)
+ {
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
+ GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
+ GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
+ return qs;
+ }
+ GNUNET_break (! no_account);
+ return qs;
+}
diff --git a/src/backenddb/account_kyc_set_failed.sql b/src/backenddb/insert_kyc_failure.sql
diff --git a/src/backenddb/insert_kyc_status.c b/src/backenddb/insert_kyc_status.c
@@ -0,0 +1,115 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2022-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 src/backenddb/insert_kyc_status.c
+ * @brief Implementation of the insert_kyc_status function for Postgres
+ * @author Iván Ávalos
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
+#include "merchant-database/insert_kyc_status.h"
+#include "helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_insert_kyc_status (
+ struct TALER_MERCHANTDB_PostgresContext *pg,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp timestamp,
+ struct GNUNET_TIME_Absolute next_time,
+ struct GNUNET_TIME_Relative kyc_backoff,
+ unsigned int exchange_http_status,
+ enum TALER_ErrorCode exchange_ec_code,
+ uint64_t rule_gen,
+ const struct TALER_AccountAccessTokenP *access_token,
+ const json_t *jlimits,
+ bool in_aml_review,
+ bool kyc_ok)
+{
+ struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = {
+ .header.size = htons (sizeof (ev)),
+ .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED),
+ .h_wire = *h_wire
+ };
+ struct GNUNET_DB_EventHeaderP hdr = {
+ .size = htons (sizeof (hdr)),
+ .type = htons (TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED)
+ };
+ char *notify_s
+ = GNUNET_PQ_get_event_notify_channel (&ev.header);
+ char *notify2_s
+ = GNUNET_PQ_get_event_notify_channel (&hdr);
+ uint32_t http_status32 = (uint32_t) exchange_http_status;
+ uint32_t ec_code32 = (uint32_t) exchange_ec_code;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (h_wire),
+ GNUNET_PQ_query_param_string (exchange_url),
+ GNUNET_PQ_query_param_timestamp (×tamp),
+ GNUNET_PQ_query_param_uint32 (&http_status32),
+ GNUNET_PQ_query_param_uint32 (&ec_code32),
+ NULL != access_token
+ ? GNUNET_PQ_query_param_auto_from_type (access_token)
+ : GNUNET_PQ_query_param_null (),
+ NULL != jlimits
+ ? TALER_PQ_query_param_json (jlimits)
+ : GNUNET_PQ_query_param_null (),
+ GNUNET_PQ_query_param_bool (in_aml_review),
+ GNUNET_PQ_query_param_bool (kyc_ok),
+ GNUNET_PQ_query_param_string (notify_s),
+ GNUNET_PQ_query_param_string (notify2_s),
+ GNUNET_PQ_query_param_uint64 (&rule_gen),
+ GNUNET_PQ_query_param_absolute_time (&next_time),
+ GNUNET_PQ_query_param_relative_time (&kyc_backoff),
+ GNUNET_PQ_query_param_end
+ };
+ bool no_account;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_bool ("no_account",
+ &no_account),
+ GNUNET_PQ_result_spec_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ GNUNET_assert (NULL != pg->current_merchant_id);
+ GNUNET_assert (0 == strcmp (merchant_id,
+ pg->current_merchant_id));
+ TMH_PQ_prepare_anon (pg,
+ "SELECT "
+ " out_no_account AS no_account"
+ " FROM merchant_do_account_kyc_set_status"
+ "($1, $2, $3, $4, $5, $6, $7::TEXT::JSONB"
+ ",$8, $9, $10, $11, $12, $13, $14);");
+ qs = GNUNET_PQ_eval_prepared_singleton_select (
+ pg->conn,
+ "",
+ params,
+ rs);
+ GNUNET_free (notify_s);
+ GNUNET_free (notify2_s);
+ if (qs <= 0)
+ {
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
+ GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
+ GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
+ return qs;
+ }
+ GNUNET_break (! no_account);
+ return qs;
+}
diff --git a/src/backenddb/account_kyc_set_status.sql b/src/backenddb/insert_kyc_status.sql
diff --git a/src/backenddb/iterate_kyc_statuses.c b/src/backenddb/iterate_kyc_statuses.c
@@ -0,0 +1,215 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2022, 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/backenddb/iterate_kyc_statuses.c
+ * @brief Implementation of the iterate_kyc_statuses function for Postgres
+ * @author Iván Ávalos
+ */
+#include "platform.h"
+#include <taler/taler_pq_lib.h>
+#include "merchant-database/iterate_kyc_statuses.h"
+#include "helper.h"
+
+/**
+ * Closure for kyc_status_cb().
+ */
+struct KycStatusContext
+{
+ /**
+ * Function to call with results.
+ */
+ TALER_MERCHANTDB_KycCallback kyc_cb;
+
+ /**
+ * Closure for @e kyc_cb.
+ */
+ void *kyc_cb_cls;
+
+ /**
+ * Number of results found.
+ */
+ unsigned int count;
+
+ /**
+ * Set to true on failure(s).
+ */
+ bool failure;
+};
+
+
+/**
+ * Function to be called with the results of a SELECT statement
+ * that has returned @a num_results results about accounts.
+ *
+ * @param[in,out] cls of type `struct KycStatusContext *`
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+kyc_status_cb (void *cls,
+ PGresult *result,
+ unsigned int num_results)
+{
+ struct KycStatusContext *ksc = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Got %u KYC records\n",
+ num_results);
+ for (unsigned int i = 0; i < num_results; i++)
+ {
+ struct TALER_MerchantWireHashP h_wire;
+ char *exchange_url = NULL;
+ struct TALER_FullPayto payto_uri;
+ struct GNUNET_TIME_Timestamp last_check
+ = GNUNET_TIME_UNIT_ZERO_TS;
+ bool kyc_ok = false;
+ struct TALER_AccountAccessTokenP access_token;
+ bool no_auth = false;
+ uint32_t h32 = 0;
+ uint32_t e32 = 0;
+ bool in_aml_review = false;
+ bool no_mk; /* left join on merchant_kyc table yielded nothing */
+ json_t *jlimits = NULL;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_auto_from_type ("h_wire",
+ &h_wire),
+ GNUNET_PQ_result_spec_string ("payto_uri",
+ &payto_uri.full_payto),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_string ("exchange_url",
+ &exchange_url),
+ &no_mk),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_timestamp ("kyc_timestamp",
+ &last_check),
+ &no_mk),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_bool ("kyc_ok",
+ &kyc_ok),
+ &no_mk),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_auto_from_type ("access_token",
+ &access_token),
+ &no_auth),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_uint32 ("exchange_http_status",
+ &h32),
+ &no_mk),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_uint32 ("exchange_ec_code",
+ &e32),
+ &no_mk),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_bool ("aml_review",
+ &in_aml_review),
+ &no_mk),
+ GNUNET_PQ_result_spec_allow_null (
+ TALER_PQ_result_spec_json ("jaccount_limits",
+ &jlimits),
+ NULL),
+ GNUNET_PQ_result_spec_end
+ };
+ unsigned int last_http_status;
+ enum TALER_ErrorCode last_ec;
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ i))
+ {
+ GNUNET_break (0);
+ ksc->failure = true;
+ return;
+ }
+ last_http_status = (unsigned int) h32;
+ last_ec = (enum TALER_ErrorCode) (int) e32;
+ ksc->count++;
+ ksc->kyc_cb (ksc->kyc_cb_cls,
+ &h_wire,
+ payto_uri,
+ exchange_url,
+ last_check,
+ kyc_ok,
+ (no_auth)
+ ? NULL
+ : &access_token,
+ last_http_status,
+ last_ec,
+ in_aml_review,
+ jlimits);
+ GNUNET_PQ_cleanup_result (rs);
+ }
+}
+
+
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_iterate_kyc_statuses (
+ struct TALER_MERCHANTDB_PostgresContext *pg,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ TALER_MERCHANTDB_KycCallback kyc_cb,
+ void *kyc_cb_cls)
+{
+ struct KycStatusContext ksc = {
+ .kyc_cb = kyc_cb,
+ .kyc_cb_cls = kyc_cb_cls
+ };
+ struct GNUNET_TIME_Absolute now
+ = GNUNET_TIME_absolute_get ();
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_absolute_time (&now),
+ NULL == exchange_url
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (exchange_url),
+ NULL == h_wire
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_auto_from_type (h_wire),
+ GNUNET_PQ_query_param_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ GNUNET_assert (NULL != pg->current_merchant_id);
+ GNUNET_assert (0 == strcmp (merchant_id,
+ pg->current_merchant_id));
+ TMH_PQ_prepare_anon (pg,
+ "SELECT "
+ " out_h_wire AS h_wire"
+ " ,out_payto_uri AS payto_uri"
+ " ,out_exchange_url AS exchange_url"
+ " ,out_kyc_timestamp AS kyc_timestamp"
+ " ,out_kyc_ok AS kyc_ok"
+ " ,out_access_token AS access_token"
+ " ,out_exchange_http_status AS exchange_http_status"
+ " ,out_exchange_ec_code AS exchange_ec_code"
+ " ,out_aml_review AS aml_review"
+ " ,out_jaccount_limits::TEXT AS jaccount_limits"
+ " FROM merchant_do_account_kyc_get_status($1, $2, $3);");
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ "",
+ params,
+ &kyc_status_cb,
+ &ksc);
+ if (ksc.failure)
+ {
+ GNUNET_break (0);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+ if (0 > qs)
+ return qs;
+ return ksc.count;
+}
diff --git a/src/backenddb/account_kyc_get_status.sql b/src/backenddb/iterate_kyc_statuses.sql
diff --git a/src/backenddb/iterate_outdated_kyc_statuses.c b/src/backenddb/iterate_outdated_kyc_statuses.c
@@ -0,0 +1,146 @@
+/*
+ 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/backenddb/iterate_outdated_kyc_statuses.c
+ * @brief Implementation of the iterate_outdated_kyc_statuses function for Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <taler/taler_error_codes.h>
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
+#include "merchant-database/iterate_outdated_kyc_statuses.h"
+#include "helper.h"
+
+/**
+ * Closure for kyc_status_cb().
+ */
+struct KycStatusContext
+{
+ /**
+ * Function to call with results.
+ */
+ TALER_MERCHANTDB_KycOutdatedCallback kyc_cb;
+
+ /**
+ * Closure for @e kyc_cb.
+ */
+ void *kyc_cb_cls;
+
+ /**
+ * Number of results found.
+ */
+ unsigned int count;
+
+ /**
+ * Set to true on failure(s).
+ */
+ bool failure;
+};
+
+
+/**
+ * Function to be called with the results of a SELECT statement
+ * that has returned @a num_results results about accounts.
+ *
+ * @param[in,out] cls of type `struct KycStatusContext *`
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+kyc_status_cb (void *cls,
+ PGresult *result,
+ unsigned int num_results)
+{
+ struct KycStatusContext *ksc = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Got %u outdated KYC records\n",
+ num_results);
+ for (unsigned int i = 0; i < num_results; i++)
+ {
+ struct TALER_MerchantWireHashP h_wire;
+ char *exchange_url;
+ char *instance_id;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_auto_from_type ("out_h_wire",
+ &h_wire),
+ GNUNET_PQ_result_spec_string ("out_exchange_url",
+ &exchange_url),
+ GNUNET_PQ_result_spec_string ("out_merchant_id",
+ &instance_id),
+ GNUNET_PQ_result_spec_end
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ i))
+ {
+ GNUNET_break (0);
+ ksc->failure = true;
+ return;
+ }
+ ksc->count++;
+ ksc->kyc_cb (ksc->kyc_cb_cls,
+ instance_id,
+ exchange_url,
+ &h_wire);
+ GNUNET_PQ_cleanup_result (rs);
+ }
+}
+
+
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_iterate_outdated_kyc_statuses (
+ struct TALER_MERCHANTDB_PostgresContext *pg,
+ TALER_MERCHANTDB_KycOutdatedCallback kyc_cb,
+ void *kyc_cb_cls)
+{
+ struct KycStatusContext ksc = {
+ .kyc_cb = kyc_cb,
+ .kyc_cb_cls = kyc_cb_cls
+ };
+ struct GNUNET_TIME_Absolute now
+ = GNUNET_TIME_absolute_get ();
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ PREPARE (pg,
+ "account_kyc_get_outdated",
+ "SELECT"
+ " out_merchant_id"
+ " ,out_h_wire"
+ " ,out_exchange_url"
+ " FROM merchant.account_kyc_get_outdated($1)");
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ "account_kyc_get_outdated",
+ params,
+ &kyc_status_cb,
+ &ksc);
+ if (ksc.failure)
+ {
+ GNUNET_break (0);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+ if (0 > qs)
+ return qs;
+ return ksc.count;
+}
diff --git a/src/backenddb/account_kyc_get_outdated.sql b/src/backenddb/iterate_outdated_kyc_statuses.sql
diff --git a/src/backenddb/meson.build b/src/backenddb/meson.build
@@ -15,10 +15,10 @@ libtalermerchantdb = library(
'event_notify.c',
'preflight.c',
'set_instance.c',
- 'account_kyc_get_outdated.c',
- 'account_kyc_get_status.c',
- 'account_kyc_set_failed.c',
- 'account_kyc_set_status.c',
+ 'iterate_outdated_kyc_statuses.c',
+ 'iterate_kyc_statuses.c',
+ 'insert_kyc_failure.c',
+ 'insert_kyc_status.c',
'activate_account.c',
'check_transfer_exists.c',
'delete_category.c',
diff --git a/src/backenddb/sql-schema/meson.build b/src/backenddb/sql-schema/meson.build
@@ -10,7 +10,7 @@ sql_global_procedures = [
'../check_report.sql',
'../create_tables.sql',
'../pg_fixup_instance_schema.sql',
- '../account_kyc_get_outdated.sql',
+ '../iterate_outdated_kyc_statuses.sql',
'../select_wirewatch_accounts.sql',
'../select_open_transfers.sql',
'../select_all_donau_instances.sql',
@@ -47,12 +47,12 @@ sql_instance_procedures = [
'../insert_spent_token.sql',
'../insert_transfer_details.sql',
'../update_product.sql',
- '../account_kyc_set_status.sql',
- '../account_kyc_set_failed.sql',
+ '../insert_kyc_status.sql',
+ '../insert_kyc_failure.sql',
'../update_product_group.sql',
'../update_money_pot.sql',
'../increment_money_pots.sql',
- '../account_kyc_get_status.sql',
+ '../iterate_kyc_statuses.sql',
'../insert_transfer.sql',
'../insert_unclaim_signature.sql',
'../insert_deposit_confirmation.sql',
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
@@ -27,8 +27,8 @@
#include <taler/taler_signatures.h>
#include "taler/taler_merchant_util.h"
#include "merchantdb_lib.h"
-#include "merchant-database/account_kyc_get_status.h"
-#include "merchant-database/account_kyc_set_status.h"
+#include "merchant-database/iterate_kyc_statuses.h"
+#include "merchant-database/insert_kyc_status.h"
#include "merchant-database/delete_contract_terms.h"
#include "merchant-database/delete_instance_private_key.h"
#include "merchant-database/delete_order.h"
@@ -5854,85 +5854,85 @@ test_kyc (void)
GNUNET_DB_STATUS_SUCCESS_ONE_RESULT));
now = GNUNET_TIME_timestamp_get ();
TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- TALER_MERCHANTDB_account_kyc_set_status (pg,
- instance.instance.id,
- &account.h_wire,
- "https://exchange.net/",
- now,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- GNUNET_TIME_UNIT_HOURS,
- MHD_HTTP_OK,
- TALER_EC_NONE,
- 42,
- NULL,
- NULL,
- false,
- false));
+ TALER_MERCHANTDB_insert_kyc_status (pg,
+ instance.instance.id,
+ &account.h_wire,
+ "https://exchange.net/",
+ now,
+ GNUNET_TIME_UNIT_FOREVER_ABS,
+ GNUNET_TIME_UNIT_HOURS,
+ MHD_HTTP_OK,
+ TALER_EC_NONE,
+ 42,
+ NULL,
+ NULL,
+ false,
+ false));
TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- TALER_MERCHANTDB_account_kyc_set_status (pg,
- instance.instance.id,
- &account.h_wire,
- "https://exchange2.com/",
- now,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- GNUNET_TIME_UNIT_HOURS,
- MHD_HTTP_OK,
- TALER_EC_NONE,
- 42,
- NULL,
- NULL,
- false,
- false));
+ TALER_MERCHANTDB_insert_kyc_status (pg,
+ instance.instance.id,
+ &account.h_wire,
+ "https://exchange2.com/",
+ now,
+ GNUNET_TIME_UNIT_FOREVER_ABS,
+ GNUNET_TIME_UNIT_HOURS,
+ MHD_HTTP_OK,
+ TALER_EC_NONE,
+ 42,
+ NULL,
+ NULL,
+ false,
+ false));
TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- TALER_MERCHANTDB_account_kyc_set_status (pg,
- instance.instance.id,
- &account.h_wire,
- "https://exchange.net/",
- now,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- GNUNET_TIME_UNIT_HOURS,
- MHD_HTTP_OK,
- TALER_EC_NONE,
- 42,
- NULL,
- NULL,
- false,
- true));
+ TALER_MERCHANTDB_insert_kyc_status (pg,
+ instance.instance.id,
+ &account.h_wire,
+ "https://exchange.net/",
+ now,
+ GNUNET_TIME_UNIT_FOREVER_ABS,
+ GNUNET_TIME_UNIT_HOURS,
+ MHD_HTTP_OK,
+ TALER_EC_NONE,
+ 42,
+ NULL,
+ NULL,
+ false,
+ true));
fail = true;
TEST_RET_ON_FAIL (1 !=
- TALER_MERCHANTDB_account_kyc_get_status (pg,
- instance.instance.id,
- &account.h_wire,
- "https://exchange.net/",
- &kyc_status_ok,
- &fail));
+ TALER_MERCHANTDB_iterate_kyc_statuses (pg,
+ instance.instance.id,
+ &account.h_wire,
+ "https://exchange.net/",
+ &kyc_status_ok,
+ &fail));
TEST_RET_ON_FAIL (fail);
fail = true;
TEST_RET_ON_FAIL (1 !=
- TALER_MERCHANTDB_account_kyc_get_status (pg,
- instance.instance.id,
- NULL,
- "https://exchange2.com/",
- &kyc_status_fail,
- &fail));
+ TALER_MERCHANTDB_iterate_kyc_statuses (pg,
+ instance.instance.id,
+ NULL,
+ "https://exchange2.com/",
+ &kyc_status_fail,
+ &fail));
TEST_RET_ON_FAIL (fail);
fail = true;
TEST_RET_ON_FAIL (2 !=
- TALER_MERCHANTDB_account_kyc_get_status (pg,
- instance.instance.id,
- NULL,
- NULL,
- &kyc_status_fail,
- &fail));
+ TALER_MERCHANTDB_iterate_kyc_statuses (pg,
+ instance.instance.id,
+ NULL,
+ NULL,
+ &kyc_status_fail,
+ &fail));
TEST_RET_ON_FAIL (fail);
fail = true;
TEST_RET_ON_FAIL (2 !=
- TALER_MERCHANTDB_account_kyc_get_status (pg,
- instance.instance.id,
- NULL,
- NULL,
- &kyc_status_ok,
- &fail));
+ TALER_MERCHANTDB_iterate_kyc_statuses (pg,
+ instance.instance.id,
+ NULL,
+ NULL,
+ &kyc_status_ok,
+ &fail));
TEST_RET_ON_FAIL (fail);
json_decref (instance.instance.address);
json_decref (instance.instance.jurisdiction);
diff --git a/src/include/merchant-database/account_kyc_get_outdated.h b/src/include/merchant-database/account_kyc_get_outdated.h
@@ -1,60 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2025 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/merchant-database/account_kyc_get_outdated.h
- * @brief implementation of the account_kyc_get_outdated function for Postgres
- * @author Christian Grothoff
- */
-#ifndef MERCHANT_DATABASE_ACCOUNT_KYC_GET_OUTDATED_H
-#define MERCHANT_DATABASE_ACCOUNT_KYC_GET_OUTDATED_H
-
-#include <taler/taler_util.h>
-#include <taler/taler_json_lib.h>
-#include "merchantdb_lib.h"
-
-
-struct TALER_MERCHANTDB_PostgresContext;
-/* Callback typedefs */
-/**
- * Function called from ``account_kyc_get_outdated``
- * with information about outdated KYC status information.
- *
- * @param cls closure
- * @param instance_id which instance is this about
- * @param exchange_url base URL of the exchange for which the status is dated
- * @param h_wire hash of the wire account for which the status is dated
- */
-typedef void
-(*TALER_MERCHANTDB_KycOutdatedCallback)(
- void *cls,
- const char *instance_id,
- const char *exchange_url,
- const struct TALER_MerchantWireHashP *h_wire);
-
-/**
- * Find accounts requiring KYC checks.
- *
- * @param pg database context
- * @param kyc_cb status callback to invoke
- * @param kyc_cb_cls closure for @a kyc_cb
- * @return database result code
- */
-enum GNUNET_DB_QueryStatus
-TALER_MERCHANTDB_account_kyc_get_outdated (struct TALER_MERCHANTDB_PostgresContext *pg,
- TALER_MERCHANTDB_KycOutdatedCallback kyc_cb,
- void *kyc_cb_cls);
-
-#endif
diff --git a/src/include/merchant-database/account_kyc_get_status.h b/src/include/merchant-database/account_kyc_get_status.h
@@ -1,84 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022, 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/merchant-database/account_kyc_get_status.h
- * @brief implementation of the account_kyc_get_status function for Postgres
- * @author Christian Grothoff
- */
-#ifndef MERCHANT_DATABASE_ACCOUNT_KYC_GET_STATUS_H
-#define MERCHANT_DATABASE_ACCOUNT_KYC_GET_STATUS_H
-
-#include <taler/taler_util.h>
-#include <taler/taler_json_lib.h>
-#include "merchantdb_lib.h"
-
-
-struct TALER_MERCHANTDB_PostgresContext;
-/* Callback typedefs */
-/**
- * Function called from ``account_kyc_get_status``
- * with KYC status information for this merchant.
- *
- * @param cls closure
- * @param h_wire hash of the wire account
- * @param payto_uri payto:// URI of the merchant's bank account
- * @param exchange_url base URL of the exchange for which this is a status
- * @param last_check when did we last get an update on our KYC status from the exchange
- * @param kyc_ok true if we satisfied the KYC requirements
- * @param access_token access token for the KYC SPA, NULL if we cannot access it yet (need KYC auth wire transfer)
- * @param last_http_status last HTTP status from /kyc-check
- * @param last_ec last Taler error code from /kyc-check
- * @param in_aml_review true if the account is pending review
- * @param jlimits JSON array of applicable AccountLimits, or NULL if unknown (like defaults apply)
- */
-typedef void
-(*TALER_MERCHANTDB_KycCallback)(
- void *cls,
- const struct TALER_MerchantWireHashP *h_wire,
- struct TALER_FullPayto payto_uri,
- const char *exchange_url,
- struct GNUNET_TIME_Timestamp last_check,
- bool kyc_ok,
- const struct TALER_AccountAccessTokenP *access_token,
- unsigned int last_http_status,
- enum TALER_ErrorCode last_ec,
- bool in_aml_review,
- const json_t *jlimits);
-
-/**
- * Check an instance's account's KYC status. Triggers
- * a request to taler-merchant-kyccheck to get a
- * KYC status update as a side-effect!
- *
- * @param pg database context
- * @param merchant_id merchant backend instance ID
- * @param h_wire hash of the wire account to check,
- * NULL to check all accounts of the merchant
- * @param exchange_url base URL of the exchange to check,
- * NULL to check all exchanges
- * @param kyc_cb KYC status callback to invoke
- * @param kyc_cb_cls closure for @a kyc_cb
- * @return database result code
- */
-enum GNUNET_DB_QueryStatus
-TALER_MERCHANTDB_account_kyc_get_status (struct TALER_MERCHANTDB_PostgresContext *pg,
- const char *merchant_id,
- const struct TALER_MerchantWireHashP *h_wire,
- const char *exchange_url,
- TALER_MERCHANTDB_KycCallback kyc_cb,
- void *kyc_cb_cls);
-
-#endif
diff --git a/src/include/merchant-database/account_kyc_set_failed.h b/src/include/merchant-database/account_kyc_set_failed.h
@@ -1,51 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 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 src/include/merchant-database/account_kyc_set_failed.h
- * @brief implementation of the account_kyc_set_failed function for Postgres
- * @author Christian Grothoff
- */
-#ifndef MERCHANT_DATABASE_ACCOUNT_KYC_SET_FAILED_H
-#define MERCHANT_DATABASE_ACCOUNT_KYC_SET_FAILED_H
-
-#include <taler/taler_util.h>
-#include <taler/taler_json_lib.h>
-#include "merchantdb_lib.h"
-
-
-struct TALER_MERCHANTDB_PostgresContext;
-/**
- * Set an instance's account's KYC status to failed.
- *
- * @param pg database context
- * @param merchant_id merchant backend instance ID
- * @param h_wire hash of the wire account to check
- * @param exchange_url base URL of the exchange to check
- * @param timestamp timestamp to store
- * @param exchange_http_status HTTP status code returned last by the exchange
- * @param kyc_ok current KYC status (should be false)
- * @return database result code
- */
-enum GNUNET_DB_QueryStatus
-TALER_MERCHANTDB_account_kyc_set_failed (struct TALER_MERCHANTDB_PostgresContext *pg,
- const char *merchant_id,
- const struct TALER_MerchantWireHashP *h_wire,
- const char *exchange_url,
- struct GNUNET_TIME_Timestamp timestamp,
- unsigned int exchange_http_status,
- bool kyc_ok);
-
-#endif
diff --git a/src/include/merchant-database/account_kyc_set_status.h b/src/include/merchant-database/account_kyc_set_status.h
@@ -1,66 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 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/merchant-database/account_kyc_set_status.h
- * @brief implementation of the account_kyc_set_status function for Postgres
- * @author Christian Grothoff
- */
-#ifndef MERCHANT_DATABASE_ACCOUNT_KYC_SET_STATUS_H
-#define MERCHANT_DATABASE_ACCOUNT_KYC_SET_STATUS_H
-
-#include <taler/taler_util.h>
-#include <taler/taler_json_lib.h>
-#include "merchantdb_lib.h"
-
-
-struct TALER_MERCHANTDB_PostgresContext;
-/**
- * Update an instance's account's KYC status.
- *
- * @param pg database context
- * @param merchant_id merchant backend instance ID
- * @param h_wire hash of the wire account to check
- * @param exchange_url base URL of the exchange to check
- * @param timestamp timestamp to store
- * @param next_time when should we next check the KYC status
- * @param kyc_backoff what is the current backoff between KYC status checks
- * @param exchange_http_status HTTP status code returned last by the exchange
- * @param exchange_ec_code Taler error code returned last by the exchange
- * @param rule_gen generation of the rule in the exchange database
- * (useful for long-polling to wait for rule changes)
- * @param access_token access token for the KYC process, NULL for none
- * @param jlimits JSON array with AccountLimits returned by the exchange
- * @param in_aml_review true if the exchange says the account is under review
- * @param kyc_ok current KYC status (true for satisfied)
- * @return database result code
- */
-enum GNUNET_DB_QueryStatus
-TALER_MERCHANTDB_account_kyc_set_status (struct TALER_MERCHANTDB_PostgresContext *pg,
- const char *merchant_id,
- const struct TALER_MerchantWireHashP *h_wire,
- const char *exchange_url,
- struct GNUNET_TIME_Timestamp timestamp,
- struct GNUNET_TIME_Absolute next_time,
- struct GNUNET_TIME_Relative kyc_backoff,
- unsigned int exchange_http_status,
- enum TALER_ErrorCode exchange_ec_code,
- uint64_t rule_gen,
- const struct TALER_AccountAccessTokenP *access_token,
- const json_t *jlimits,
- bool in_aml_review,
- bool kyc_ok);
-
-#endif
diff --git a/src/include/merchant-database/all.h b/src/include/merchant-database/all.h
@@ -4,10 +4,10 @@
#define MERCHANT_DATABASE_ALL_H
#include "merchantdb_lib.h"
-#include "merchant-database/account_kyc_get_outdated.h"
-#include "merchant-database/account_kyc_get_status.h"
-#include "merchant-database/account_kyc_set_failed.h"
-#include "merchant-database/account_kyc_set_status.h"
+#include "merchant-database/iterate_outdated_kyc_statuses.h"
+#include "merchant-database/iterate_kyc_statuses.h"
+#include "merchant-database/insert_kyc_failure.h"
+#include "merchant-database/insert_kyc_status.h"
#include "merchant-database/activate_account.h"
#include "merchant-database/check_donau_instance.h"
#include "merchant-database/check_money_pots.h"
diff --git a/src/include/merchant-database/insert_kyc_failure.h b/src/include/merchant-database/insert_kyc_failure.h
@@ -0,0 +1,51 @@
+/*
+ This file is part of TALER
+ Copyright (C) 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 src/include/merchant-database/insert_kyc_failure.h
+ * @brief implementation of the insert_kyc_failure function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef MERCHANT_DATABASE_INSERT_KYC_FAILURE_H
+#define MERCHANT_DATABASE_INSERT_KYC_FAILURE_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "merchantdb_lib.h"
+
+
+struct TALER_MERCHANTDB_PostgresContext;
+/**
+ * Set an instance's account's KYC status to failed.
+ *
+ * @param pg database context
+ * @param merchant_id merchant backend instance ID
+ * @param h_wire hash of the wire account to check
+ * @param exchange_url base URL of the exchange to check
+ * @param timestamp timestamp to store
+ * @param exchange_http_status HTTP status code returned last by the exchange
+ * @param kyc_ok current KYC status (should be false)
+ * @return database result code
+ */
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_insert_kyc_failure (struct TALER_MERCHANTDB_PostgresContext *pg,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp timestamp,
+ unsigned int exchange_http_status,
+ bool kyc_ok);
+
+#endif
diff --git a/src/include/merchant-database/insert_kyc_status.h b/src/include/merchant-database/insert_kyc_status.h
@@ -0,0 +1,66 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2022 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/merchant-database/insert_kyc_status.h
+ * @brief implementation of the insert_kyc_status function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef MERCHANT_DATABASE_INSERT_KYC_STATUS_H
+#define MERCHANT_DATABASE_INSERT_KYC_STATUS_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "merchantdb_lib.h"
+
+
+struct TALER_MERCHANTDB_PostgresContext;
+/**
+ * Update an instance's account's KYC status.
+ *
+ * @param pg database context
+ * @param merchant_id merchant backend instance ID
+ * @param h_wire hash of the wire account to check
+ * @param exchange_url base URL of the exchange to check
+ * @param timestamp timestamp to store
+ * @param next_time when should we next check the KYC status
+ * @param kyc_backoff what is the current backoff between KYC status checks
+ * @param exchange_http_status HTTP status code returned last by the exchange
+ * @param exchange_ec_code Taler error code returned last by the exchange
+ * @param rule_gen generation of the rule in the exchange database
+ * (useful for long-polling to wait for rule changes)
+ * @param access_token access token for the KYC process, NULL for none
+ * @param jlimits JSON array with AccountLimits returned by the exchange
+ * @param in_aml_review true if the exchange says the account is under review
+ * @param kyc_ok current KYC status (true for satisfied)
+ * @return database result code
+ */
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_insert_kyc_status (struct TALER_MERCHANTDB_PostgresContext *pg,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp timestamp,
+ struct GNUNET_TIME_Absolute next_time,
+ struct GNUNET_TIME_Relative kyc_backoff,
+ unsigned int exchange_http_status,
+ enum TALER_ErrorCode exchange_ec_code,
+ uint64_t rule_gen,
+ const struct TALER_AccountAccessTokenP *access_token,
+ const json_t *jlimits,
+ bool in_aml_review,
+ bool kyc_ok);
+
+#endif
diff --git a/src/include/merchant-database/iterate_kyc_statuses.h b/src/include/merchant-database/iterate_kyc_statuses.h
@@ -0,0 +1,84 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2022, 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/merchant-database/iterate_kyc_statuses.h
+ * @brief implementation of the iterate_kyc_statuses function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef MERCHANT_DATABASE_ITERATE_KYC_STATUSES_H
+#define MERCHANT_DATABASE_ITERATE_KYC_STATUSES_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "merchantdb_lib.h"
+
+
+struct TALER_MERCHANTDB_PostgresContext;
+/* Callback typedefs */
+/**
+ * Function called from ``account_kyc_get_status``
+ * with KYC status information for this merchant.
+ *
+ * @param cls closure
+ * @param h_wire hash of the wire account
+ * @param payto_uri payto:// URI of the merchant's bank account
+ * @param exchange_url base URL of the exchange for which this is a status
+ * @param last_check when did we last get an update on our KYC status from the exchange
+ * @param kyc_ok true if we satisfied the KYC requirements
+ * @param access_token access token for the KYC SPA, NULL if we cannot access it yet (need KYC auth wire transfer)
+ * @param last_http_status last HTTP status from /kyc-check
+ * @param last_ec last Taler error code from /kyc-check
+ * @param in_aml_review true if the account is pending review
+ * @param jlimits JSON array of applicable AccountLimits, or NULL if unknown (like defaults apply)
+ */
+typedef void
+(*TALER_MERCHANTDB_KycCallback)(
+ void *cls,
+ const struct TALER_MerchantWireHashP *h_wire,
+ struct TALER_FullPayto payto_uri,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp last_check,
+ bool kyc_ok,
+ const struct TALER_AccountAccessTokenP *access_token,
+ unsigned int last_http_status,
+ enum TALER_ErrorCode last_ec,
+ bool in_aml_review,
+ const json_t *jlimits);
+
+/**
+ * Check an instance's account's KYC status. Triggers
+ * a request to taler-merchant-kyccheck to get a
+ * KYC status update as a side-effect!
+ *
+ * @param pg database context
+ * @param merchant_id merchant backend instance ID
+ * @param h_wire hash of the wire account to check,
+ * NULL to check all accounts of the merchant
+ * @param exchange_url base URL of the exchange to check,
+ * NULL to check all exchanges
+ * @param kyc_cb KYC status callback to invoke
+ * @param kyc_cb_cls closure for @a kyc_cb
+ * @return database result code
+ */
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_iterate_kyc_statuses (struct TALER_MERCHANTDB_PostgresContext *pg,
+ const char *merchant_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *exchange_url,
+ TALER_MERCHANTDB_KycCallback kyc_cb,
+ void *kyc_cb_cls);
+
+#endif
diff --git a/src/include/merchant-database/iterate_outdated_kyc_statuses.h b/src/include/merchant-database/iterate_outdated_kyc_statuses.h
@@ -0,0 +1,60 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2025 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/merchant-database/iterate_outdated_kyc_statuses.h
+ * @brief implementation of the iterate_outdated_kyc_statuses function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef MERCHANT_DATABASE_ITERATE_OUTDATED_KYC_STATUSES_H
+#define MERCHANT_DATABASE_ITERATE_OUTDATED_KYC_STATUSES_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "merchantdb_lib.h"
+
+
+struct TALER_MERCHANTDB_PostgresContext;
+/* Callback typedefs */
+/**
+ * Function called from ``account_kyc_get_outdated``
+ * with information about outdated KYC status information.
+ *
+ * @param cls closure
+ * @param instance_id which instance is this about
+ * @param exchange_url base URL of the exchange for which the status is dated
+ * @param h_wire hash of the wire account for which the status is dated
+ */
+typedef void
+(*TALER_MERCHANTDB_KycOutdatedCallback)(
+ void *cls,
+ const char *instance_id,
+ const char *exchange_url,
+ const struct TALER_MerchantWireHashP *h_wire);
+
+/**
+ * Find accounts requiring KYC checks.
+ *
+ * @param pg database context
+ * @param kyc_cb status callback to invoke
+ * @param kyc_cb_cls closure for @a kyc_cb
+ * @return database result code
+ */
+enum GNUNET_DB_QueryStatus
+TALER_MERCHANTDB_iterate_outdated_kyc_statuses (struct TALER_MERCHANTDB_PostgresContext *pg,
+ TALER_MERCHANTDB_KycOutdatedCallback kyc_cb,
+ void *kyc_cb_cls);
+
+#endif