aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2024-08-02 12:00:07 +0200
committerChristian Grothoff <grothoff@gnunet.org>2024-08-02 12:00:07 +0200
commit830ebef2ea959ccbec0d62a04b947a020ff278c8 (patch)
treea87bf000b8c77e4495aef548745415e409280c36 /src
parent3883a0e98a2d3c6421f9aca958ee77b97bd4d5c8 (diff)
add kycauths_in table support to taler-auditor-sync
Diffstat (limited to 'src')
-rw-r--r--src/exchangedb/pg_insert_records_by_table.c47
-rw-r--r--src/exchangedb/pg_lookup_records_by_table.c76
-rw-r--r--src/exchangedb/pg_lookup_serial_by_table.c8
-rw-r--r--src/include/taler_exchangedb_plugin.h11
4 files changed, 142 insertions, 0 deletions
diff --git a/src/exchangedb/pg_insert_records_by_table.c b/src/exchangedb/pg_insert_records_by_table.c
index 592ea01a4..097e6275e 100644
--- a/src/exchangedb/pg_insert_records_by_table.c
+++ b/src/exchangedb/pg_insert_records_by_table.c
@@ -416,6 +416,50 @@ irbt_cb_table_reserves_in (struct PostgresClosure *pg,
/**
+ * Function called with kycauth_in records to insert into table.
+ *
+ * @param pg plugin context
+ * @param td record to insert
+ */
+static enum GNUNET_DB_QueryStatus
+irbt_cb_table_kycauths_in (struct PostgresClosure *pg,
+ const struct TALER_EXCHANGEDB_TableData *td)
+{
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_uint64 (&td->serial),
+ GNUNET_PQ_query_param_uint64 (&td->details.kycauth_in.wire_reference),
+ TALER_PQ_query_param_amount (
+ pg->conn,
+ &td->details.reserves_in.credit),
+ GNUNET_PQ_query_param_auto_from_type (
+ &td->details.reserves_in.sender_account_h_payto),
+ GNUNET_PQ_query_param_string (
+ td->details.reserves_in.exchange_account_section),
+ GNUNET_PQ_query_param_timestamp (
+ &td->details.reserves_in.execution_date),
+ GNUNET_PQ_query_param_auto_from_type (&td->details.kycauth_in.account_pub),
+ GNUNET_PQ_query_param_end
+ };
+
+ PREPARE (pg,
+ "insert_into_table_kycauth_in",
+ "INSERT INTO kycauths_in"
+ "(kycauth_in_serial_id"
+ ",wire_reference"
+ ",credit"
+ ",wire_source_h_payto"
+ ",exchange_account_section"
+ ",execution_date"
+ ",account_pub"
+ ") VALUES "
+ "($1, $2, $3, $4, $5, $6, $7);");
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "insert_into_table_kycauth_in",
+ params);
+}
+
+
+/**
* Function called with reserves_open_requests records to insert into table.
*
* @param pg plugin context
@@ -2270,6 +2314,9 @@ TEH_PG_insert_records_by_table (void *cls,
case TALER_EXCHANGEDB_RT_RESERVES_IN:
rh = &irbt_cb_table_reserves_in;
break;
+ case TALER_EXCHANGEDB_RT_KYCAUTHS_IN:
+ rh = &irbt_cb_table_kycauths_in;
+ break;
case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
rh = &irbt_cb_table_reserves_close;
break;
diff --git a/src/exchangedb/pg_lookup_records_by_table.c b/src/exchangedb/pg_lookup_records_by_table.c
index b98c5963d..cbd972424 100644
--- a/src/exchangedb/pg_lookup_records_by_table.c
+++ b/src/exchangedb/pg_lookup_records_by_table.c
@@ -347,6 +347,67 @@ lrbt_cb_table_reserves_in (void *cls,
/**
+ * Function called with kycauth_in table entries.
+ *
+ * @param cls closure
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+lrbt_cb_table_kycauth_in (void *cls,
+ PGresult *result,
+ unsigned int num_results)
+{
+ struct LookupRecordsByTableContext *ctx = cls;
+ struct PostgresClosure *pg = ctx->pg;
+ struct TALER_EXCHANGEDB_TableData td = {
+ .table = TALER_EXCHANGEDB_RT_KYCAUTHS_IN
+ };
+
+ for (unsigned int i = 0; i<num_results; i++)
+ {
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_uint64 (
+ "serial",
+ &td.serial),
+ GNUNET_PQ_result_spec_auto_from_type (
+ "account_pub",
+ &td.details.kycauth_in.account_pub),
+ GNUNET_PQ_result_spec_uint64 (
+ "wire_reference",
+ &td.details.kycauth_in.wire_reference),
+ TALER_PQ_RESULT_SPEC_AMOUNT (
+ "credit",
+ &td.details.kycauth_in.credit),
+ GNUNET_PQ_result_spec_auto_from_type (
+ "wire_source_h_payto",
+ &td.details.kycauth_in.sender_account_h_payto),
+ GNUNET_PQ_result_spec_string (
+ "exchange_account_section",
+ &td.details.kycauth_in.exchange_account_section),
+ GNUNET_PQ_result_spec_timestamp (
+ "execution_date",
+ &td.details.kycauth_in.execution_date),
+ GNUNET_PQ_result_spec_end
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ i))
+ {
+ GNUNET_break (0);
+ ctx->error = true;
+ return;
+ }
+ ctx->cb (ctx->cb_cls,
+ &td);
+ GNUNET_PQ_cleanup_result (rs);
+ }
+}
+
+
+/**
* Function called with reserves_close table entries.
*
* @param cls closure
@@ -3087,6 +3148,21 @@ TEH_PG_lookup_records_by_table (void *cls,
" ORDER BY reserve_in_serial_id ASC;");
rh = &lrbt_cb_table_reserves_in;
break;
+ case TALER_EXCHANGEDB_RT_KYCAUTHS_IN:
+ XPREPARE ("select_above_serial_by_table_kycauth_in",
+ "SELECT"
+ " kycauth_in_serial_id AS serial"
+ ",account_pub"
+ ",wire_reference"
+ ",credit"
+ ",wire_source_h_payto"
+ ",exchange_account_section"
+ ",execution_date"
+ " FROM kycauths_in"
+ " WHERE kycauth_in_serial_id > $1"
+ " ORDER BY kycauth_in_serial_id ASC;");
+ rh = &lrbt_cb_table_kycauth_in;
+ break;
case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
XPREPARE ("select_above_serial_by_table_reserves_close",
"SELECT"
diff --git a/src/exchangedb/pg_lookup_serial_by_table.c b/src/exchangedb/pg_lookup_serial_by_table.c
index 4f1d47d55..c4d81adcb 100644
--- a/src/exchangedb/pg_lookup_serial_by_table.c
+++ b/src/exchangedb/pg_lookup_serial_by_table.c
@@ -93,6 +93,14 @@ TEH_PG_lookup_serial_by_table (void *cls,
" ORDER BY reserve_in_serial_id DESC"
" LIMIT 1;");
break;
+ case TALER_EXCHANGEDB_RT_KYCAUTHS_IN:
+ XPREPARE ("select_serial_by_table_kycauths_in",
+ "SELECT"
+ " kycauth_in_serial_id AS serial"
+ " FROM kycauths_in"
+ " ORDER BY kycauths_in_serial_id DESC"
+ " LIMIT 1;");
+ break;
case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
XPREPARE ("select_serial_by_table_reserves_close",
"SELECT"
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index 9b582ddcc..69bb66f03 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -332,6 +332,7 @@ enum TALER_EXCHANGEDB_ReplicatedTable
TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES,
TALER_EXCHANGEDB_RT_AML_HISTORY,
TALER_EXCHANGEDB_RT_KYC_EVENTS,
+ TALER_EXCHANGEDB_RT_KYCAUTHS_IN,
};
@@ -472,6 +473,16 @@ struct TALER_EXCHANGEDB_TableData
struct
{
+ uint64_t wire_reference;
+ struct TALER_Amount credit;
+ struct TALER_PaytoHashP sender_account_h_payto;
+ char *exchange_account_section;
+ struct GNUNET_TIME_Timestamp execution_date;
+ union TALER_AccountPublicKeyP account_pub;
+ } kycauth_in;
+
+ struct
+ {
struct TALER_ReservePublicKeyP reserve_pub;
struct GNUNET_TIME_Timestamp request_timestamp;
struct GNUNET_TIME_Timestamp expiration_date;