aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/Makefile.am1
-rw-r--r--src/exchangedb/pg_insert_kyc_requirement_process.c8
-rw-r--r--src/exchangedb/pg_insert_kyc_requirement_process.h7
-rw-r--r--src/exchangedb/pg_lookup_aml_officer.c9
-rw-r--r--src/exchangedb/pg_lookup_pending_legitimization.c67
-rw-r--r--src/exchangedb/pg_lookup_pending_legitimization.h52
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c3
7 files changed, 142 insertions, 5 deletions
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index ff995508b..31ac50cf8 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -170,6 +170,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \
pg_insert_aml_officer.h pg_insert_aml_officer.c \
pg_test_aml_officer.h pg_test_aml_officer.c \
pg_lookup_aml_officer.h pg_lookup_aml_officer.c \
+ pg_lookup_pending_legitimization.h pg_lookup_pending_legitimization.c \
pg_trigger_aml_process.h pg_trigger_aml_process.c \
pg_insert_aml_decision.h pg_insert_aml_decision.c \
pg_select_aggregation_transient.h pg_select_aggregation_transient.c \
diff --git a/src/exchangedb/pg_insert_kyc_requirement_process.c b/src/exchangedb/pg_insert_kyc_requirement_process.c
index 8f5468b69..33e4b9f70 100644
--- a/src/exchangedb/pg_insert_kyc_requirement_process.c
+++ b/src/exchangedb/pg_insert_kyc_requirement_process.c
@@ -30,6 +30,8 @@ enum GNUNET_DB_QueryStatus
TEH_PG_insert_kyc_requirement_process (
void *cls,
const struct TALER_PaytoHashP *h_payto,
+ uint32_t measure_index,
+ uint64_t legitimization_measure_serial_id,
const char *provider_name,
const char *provider_account_id,
const char *provider_legitimization_id,
@@ -48,6 +50,8 @@ TEH_PG_insert_kyc_requirement_process (
(NULL != provider_legitimization_id)
? GNUNET_PQ_query_param_string (provider_legitimization_id)
: GNUNET_PQ_query_param_null (),
+ GNUNET_PQ_query_param_uint64 (&legitimization_measure_serial_id),
+ GNUNET_PQ_query_param_uint32 (&measure_index),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -64,8 +68,10 @@ TEH_PG_insert_kyc_requirement_process (
" ,provider_name"
" ,provider_user_id"
" ,provider_legitimization_id"
+ " ,legitimization_measure_serial_id"
+ " ,measure_index"
" ) VALUES "
- " ($1, $2, $3, $4, $5)"
+ " ($1, $2, $3, $4, $5, $6, $7)"
" RETURNING legitimization_process_serial_id");
return GNUNET_PQ_eval_prepared_singleton_select (
pg->conn,
diff --git a/src/exchangedb/pg_insert_kyc_requirement_process.h b/src/exchangedb/pg_insert_kyc_requirement_process.h
index 30e15555d..2181813fc 100644
--- a/src/exchangedb/pg_insert_kyc_requirement_process.h
+++ b/src/exchangedb/pg_insert_kyc_requirement_process.h
@@ -31,6 +31,11 @@
*
* @param cls closure
* @param h_payto account that must be KYC'ed
+ * @param measure_index which of the measures in
+ * jmeasures does this KYC process relate to
+ * @param legitimization_measure_serial_id which
+ * legitimization measure set does this KYC process
+ * relate to (uniquely identifies jmeasures)
* @param provider_name provider that must be checked
* @param provider_account_id provider account ID
* @param provider_legitimization_id provider legitimization ID
@@ -41,6 +46,8 @@ enum GNUNET_DB_QueryStatus
TEH_PG_insert_kyc_requirement_process (
void *cls,
const struct TALER_PaytoHashP *h_payto,
+ uint32_t measure_index,
+ uint64_t legitimization_measure_serial_id,
const char *provider_name,
const char *provider_account_id,
const char *provider_legitimization_id,
diff --git a/src/exchangedb/pg_lookup_aml_officer.c b/src/exchangedb/pg_lookup_aml_officer.c
index c18e47eaf..8ea6016de 100644
--- a/src/exchangedb/pg_lookup_aml_officer.c
+++ b/src/exchangedb/pg_lookup_aml_officer.c
@@ -64,8 +64,9 @@ TEH_PG_lookup_aml_officer (
",last_change"
" FROM aml_staff"
" WHERE decider_pub=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_aml_officer",
- params,
- rs);
+ return GNUNET_PQ_eval_prepared_singleton_select (
+ pg->conn,
+ "lookup_aml_officer",
+ params,
+ rs);
}
diff --git a/src/exchangedb/pg_lookup_pending_legitimization.c b/src/exchangedb/pg_lookup_pending_legitimization.c
new file mode 100644
index 000000000..a02a34315
--- /dev/null
+++ b/src/exchangedb/pg_lookup_pending_legitimization.c
@@ -0,0 +1,67 @@
+/*
+ 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_pending_legitimization.c
+ * @brief Implementation of the lookup_pending_legitimization 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_pending_legitimization.h"
+#include "pg_helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TEH_PG_lookup_pending_legitimization (
+ void *cls,
+ uint64_t legitimization_measure_serial_id,
+ const struct TALER_AccountAccessTokenP *access_token,
+ struct TALER_PaytoHashP *h_payto,
+ json_t **jmeasures)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_uint64 (&legitimization_measure_serial_id),
+ GNUNET_PQ_query_param_auto_from_type (access_token),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ TALER_PQ_result_spec_json ("jmeasures",
+ jmeasures),
+ GNUNET_PQ_result_spec_auto_from_type ("wire_target_h_payto",
+ h_payto),
+ GNUNET_PQ_result_spec_end
+ };
+
+ PREPARE (pg,
+ "lookup_pending_legitimization",
+ "SELECT "
+ " lm.jmeasures"
+ ",wt.wire_target_h_payto"
+ " FROM legitimization_measures lm"
+ " JOIN wire_targets wt"
+ " ON (lm.access_token = wt.access_token)"
+ " WHERE legitimization_measure_serial_id=$1"
+ " AND access_token=$1"
+ " AND NOT is_finished;");
+ return GNUNET_PQ_eval_prepared_singleton_select (
+ pg->conn,
+ "lookup_pending_legitimization",
+ params,
+ rs);
+}
diff --git a/src/exchangedb/pg_lookup_pending_legitimization.h b/src/exchangedb/pg_lookup_pending_legitimization.h
new file mode 100644
index 000000000..69f34594e
--- /dev/null
+++ b/src/exchangedb/pg_lookup_pending_legitimization.h
@@ -0,0 +1,52 @@
+/*
+ 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_pending_legitimization.h
+ * @brief implementation of the lookup_pending_legitimization function for Postgres
+ * @author Christian Grothoff
+ */
+#ifndef PG_LOOKUP_PENDING_LEGITIMIZATION_H
+#define PG_LOOKUP_PENDING_LEGITIMIZATION_H
+
+#include "taler_util.h"
+#include "taler_json_lib.h"
+#include "taler_exchangedb_plugin.h"
+
+
+/**
+ * Lookup measure data for a legitimization process.
+ *
+ * @param cls closure
+ * @param legitimization_measure_serial_id
+ * row in legitimization_measures table to access
+ * @param access_token
+ * token for access control that must match
+ * @param[out] h_payto set to the the hash of the
+ * payto URI of the account undergoing legitimization
+ * @param[out] jmeasures set to the legitimization
+ * measures that were put on the account
+ * @return database transaction status
+ */
+enum GNUNET_DB_QueryStatus
+TEH_PG_lookup_pending_legitimization (
+ void *cls,
+ uint64_t legitimization_measure_serial_id,
+ const struct TALER_AccountAccessTokenP *access_token,
+ struct TALER_PaytoHashP *h_payto,
+ json_t **jmeasures);
+
+
+#endif
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index e65f2ef3f..aad3e1cd9 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -53,6 +53,7 @@
#include "pg_lookup_records_by_table.h"
#include "pg_lookup_kyc_status_by_token.h"
#include "pg_lookup_serial_by_table.h"
+#include "pg_lookup_pending_legitimization.h"
#include "pg_select_account_merges_above_serial_id.h"
#include "pg_select_all_purse_decisions_above_serial_id.h"
#include "pg_select_purse.h"
@@ -740,6 +741,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
= &TEH_PG_lookup_signkey_revocation;
plugin->lookup_denomination_key
= &TEH_PG_lookup_denomination_key;
+ plugin->lookup_pending_legitimization
+ = &TEH_PG_lookup_pending_legitimization;
plugin->insert_auditor_denom_sig
= &TEH_PG_insert_auditor_denom_sig;
plugin->select_auditor_denom_sig