diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-06-04 14:24:18 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-07-29 12:18:42 +0200 |
commit | 8d1e83097d360916c07552b7765339727760e2a8 (patch) | |
tree | b3bd2c50b2246400adf4d36a8b4339d88ba6e1b7 /src/exchangedb | |
parent | 9218606c55d80fcdd673fbacdb5b73a32793b6b3 (diff) |
work on kyc-info endpoint
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/Makefile.am | 1 | ||||
-rw-r--r-- | src/exchangedb/pg_insert_aml_decision.c | 10 | ||||
-rw-r--r-- | src/exchangedb/pg_insert_kyc_attributes.c | 7 | ||||
-rw-r--r-- | src/exchangedb/pg_insert_kyc_failure.c | 4 | ||||
-rw-r--r-- | src/exchangedb/pg_lookup_kyc_status_by_token.c | 65 | ||||
-rw-r--r-- | src/exchangedb/pg_lookup_kyc_status_by_token.h | 46 | ||||
-rw-r--r-- | src/exchangedb/pg_lookup_wire_fee_by_time.c | 2 | ||||
-rw-r--r-- | src/exchangedb/pg_update_kyc_process_by_row.c | 6 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 4 |
9 files changed, 142 insertions, 3 deletions
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index f846370cd..270171456 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -193,6 +193,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \ pg_start_deferred_wire_out.h pg_start_deferred_wire_out.c \ pg_store_wire_transfer_out.h pg_store_wire_transfer_out.c \ pg_gc.h pg_gc.c \ + pg_lookup_kyc_status_by_token.h pg_lookup_kyc_status_by_token.c \ pg_select_coin_deposits_above_serial_id.h pg_select_coin_deposits_above_serial_id.c \ pg_select_purse_decisions_above_serial_id.h pg_select_purse_decisions_above_serial_id.c \ pg_select_purse_deposits_by_purse.h pg_select_purse_deposits_by_purse.c \ diff --git a/src/exchangedb/pg_insert_aml_decision.c b/src/exchangedb/pg_insert_aml_decision.c index b0edceefa..d12f34af4 100644 --- a/src/exchangedb/pg_insert_aml_decision.c +++ b/src/exchangedb/pg_insert_aml_decision.c @@ -43,12 +43,20 @@ TEH_PG_insert_aml_decision ( struct GNUNET_TIME_Timestamp *last_date) { struct PostgresClosure *pg = cls; +#if FIXME + /* We used to do h_payto, now we need the + account access token! */ struct TALER_KycCompletedEventP rep = { .header.size = htons (sizeof (rep)), .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), .h_payto = *h_payto }; - char *notify_s = GNUNET_PQ_get_event_notify_channel (&rep.header); + char *notify_s + = GNUNET_PQ_get_event_notify_channel (&rep.header); +#else + char *notify_s + = GNUNET_strdup ("FIXME"); +#endif struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (h_payto), GNUNET_PQ_query_param_timestamp (&decision_time), diff --git a/src/exchangedb/pg_insert_kyc_attributes.c b/src/exchangedb/pg_insert_kyc_attributes.c index 45d53347a..a72e4e67b 100644 --- a/src/exchangedb/pg_insert_kyc_attributes.c +++ b/src/exchangedb/pg_insert_kyc_attributes.c @@ -44,6 +44,9 @@ TEH_PG_insert_kyc_attributes ( struct PostgresClosure *pg = cls; struct GNUNET_TIME_Timestamp expiration = GNUNET_TIME_absolute_to_timestamp (expiration_time); +#if FIXME + /* We used to do h_payto, now we need the + account access token! */ struct TALER_KycCompletedEventP rep = { .header.size = htons (sizeof (rep)), .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), @@ -51,6 +54,10 @@ TEH_PG_insert_kyc_attributes ( }; char *kyc_completed_notify_s = GNUNET_PQ_get_event_notify_channel (&rep.header); +#else + char *kyc_completed_notify_s + = GNUNET_strdup ("FIXME"); +#endif struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&process_row), GNUNET_PQ_query_param_auto_from_type (h_payto), diff --git a/src/exchangedb/pg_insert_kyc_failure.c b/src/exchangedb/pg_insert_kyc_failure.c index c5d1a7085..903c717ad 100644 --- a/src/exchangedb/pg_insert_kyc_failure.c +++ b/src/exchangedb/pg_insert_kyc_failure.c @@ -67,6 +67,9 @@ TEH_PG_insert_kyc_failure ( if (qs > 0) { /* FIXME: might want to do this eventually in the same transaction... */ +#if FIXME + /* We used to do h_payto, now we need the + account access token! */ struct TALER_KycCompletedEventP rep = { .header.size = htons (sizeof (rep)), .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), @@ -77,6 +80,7 @@ TEH_PG_insert_kyc_failure ( &rep.header, NULL, 0); +#endif } return qs; } diff --git a/src/exchangedb/pg_lookup_kyc_status_by_token.c b/src/exchangedb/pg_lookup_kyc_status_by_token.c new file mode 100644 index 000000000..6d3cc4bec --- /dev/null +++ b/src/exchangedb/pg_lookup_kyc_status_by_token.c @@ -0,0 +1,65 @@ +/* + 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 exchangedb/pg_lookup_kyc_status_by_token.c + * @brief Implementation of the lookup_kyc_status_by_token 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_lookup_kyc_status_by_token.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TEH_PG_lookup_kyc_status_by_token ( + void *cls, + const struct TALER_AccountAccessTokenP *access_token, + uint64_t *row, + json_t **jmeasures) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (access_token), + GNUNET_PQ_query_param_end + }; + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ( + "legitimization_measure_serial_id", + row), + TALER_PQ_result_spec_json ( + "jmeasures", + jmeasures), + GNUNET_PQ_result_spec_end + }; + + PREPARE (pg, + "lookup_kyc_status_by_token", + "SELECT" + " legitimization_measure_serial_id" + ",jmeasures" + " FROM legitimization_measures" + " WHERE access_token=$1" + " AND NOT is_finished" + " ORDER BY display_priority DESC" + " LIMIT 1;"); + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "lookup_kyc_status_by_token", + params, + rs); +} diff --git a/src/exchangedb/pg_lookup_kyc_status_by_token.h b/src/exchangedb/pg_lookup_kyc_status_by_token.h new file mode 100644 index 000000000..77c845228 --- /dev/null +++ b/src/exchangedb/pg_lookup_kyc_status_by_token.h @@ -0,0 +1,46 @@ +/* + 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 exchangedb/pg_lookup_kyc_status_by_token.h + * @brief implementation of the lookup_kyc_status_by_token function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_LOOKUP_KYC_STATUS_BY_TOKEN_H +#define PG_LOOKUP_KYC_STATUS_BY_TOKEN_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_exchangedb_plugin.h" + + +/** + * Lookup KYC status by account access token. + * + * @param cls closure + * @param access_token key to look under + * @param[out] row set to requirement row that matches + * @param[out] jmeasures set to the LegitimizationMeasures for the @a access_token; must be freed by caller! + * @return database transaction status + */ +enum GNUNET_DB_QueryStatus +TEH_PG_lookup_kyc_status_by_token ( + void *cls, + const struct TALER_AccountAccessTokenP *access_token, + uint64_t *row, + json_t **jmeasures); + + +#endif diff --git a/src/exchangedb/pg_lookup_wire_fee_by_time.c b/src/exchangedb/pg_lookup_wire_fee_by_time.c index 775232a48..1f136b135 100644 --- a/src/exchangedb/pg_lookup_wire_fee_by_time.c +++ b/src/exchangedb/pg_lookup_wire_fee_by_time.c @@ -138,7 +138,7 @@ TEH_PG_lookup_wire_fee_by_time ( .fees = fees, .pg = pg }; - /* used in #postgres_lookup_wire_fee_by_time() */ + PREPARE (pg, "lookup_wire_fee_by_time", "SELECT" diff --git a/src/exchangedb/pg_update_kyc_process_by_row.c b/src/exchangedb/pg_update_kyc_process_by_row.c index 448ac2154..2f6724810 100644 --- a/src/exchangedb/pg_update_kyc_process_by_row.c +++ b/src/exchangedb/pg_update_kyc_process_by_row.c @@ -86,11 +86,13 @@ TEH_PG_update_kyc_process_by_row ( if (GNUNET_TIME_absolute_is_future (expiration)) { enum GNUNET_DB_QueryStatus qs2; +#if FIXME struct TALER_KycCompletedEventP rep = { .header.size = htons (sizeof (rep)), .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), .h_payto = *h_payto }; +#endif uint32_t trigger_type = 1; struct GNUNET_PQ_QueryParam params2[] = { GNUNET_PQ_query_param_auto_from_type (h_payto), @@ -98,10 +100,14 @@ TEH_PG_update_kyc_process_by_row ( GNUNET_PQ_query_param_end }; +#if FIXME + /* We used to do h_payto, now we need the + account access token! */ GNUNET_PQ_event_notify (pg->conn, &rep.header, NULL, 0); +#endif PREPARE (pg, "alert_kyc_status_change", "INSERT INTO kyc_alerts" diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index d26db2029..897d09bef 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -50,6 +50,7 @@ #include "pg_iterate_kyc_reference.h" #include "pg_iterate_reserve_close_info.h" #include "pg_lookup_records_by_table.h" +#include "pg_lookup_kyc_status_by_token.h" #include "pg_lookup_serial_by_table.h" #include "pg_select_account_merges_above_serial_id.h" #include "pg_select_all_purse_decisions_above_serial_id.h" @@ -782,7 +783,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) = &TEH_PG_lookup_kyc_requirement_by_row; plugin->trigger_kyc_rule_for_account = &TEH_PG_trigger_kyc_rule_for_account; - + plugin->lookup_kyc_status_by_token + = &TEH_PG_lookup_kyc_status_by_token; plugin->batch_ensure_coin_known = &TEH_PG_batch_ensure_coin_known; plugin->inject_auditor_triggers |