commit 894aac44aa22cedcc3794369ac709c48d260a1d1
parent f3a762be1e18d1912ea5786a8b32443dcb6183ad
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 8 Aug 2026 22:16:22 +0200
Revert "kill dead denomination_pending table, endpoint, etc."
This reverts commit e6b6340f23f98d5e8889c43448d90df79720f7c8.
Diffstat:
10 files changed, 471 insertions(+), 21 deletions(-)
diff --git a/src/auditor/meson.build b/src/auditor/meson.build
@@ -251,6 +251,7 @@ taler_auditor_httpd_SOURCES = [
'taler-auditor-httpd_get-monitoring-reserves.c',
'taler-auditor-httpd_get-monitoring-purses.c',
'taler-auditor-httpd_get-monitoring-historic-denomination-revenue.c',
+ 'taler-auditor-httpd_get-monitoring-denomination-pending.c',
'taler-auditor-httpd_get-monitoring-historic-reserve-summary.c',
'taler-auditor-httpd_get-monitoring-wire-format-inconsistency.c',
'taler-auditor-httpd_get-monitoring-wire-out-inconsistency.c',
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c
@@ -86,7 +86,7 @@
* release version, and the format is NOT the same that semantic
* versioning uses either.
*/
-#define AUDITOR_PROTOCOL_VERSION "3:0:0"
+#define AUDITOR_PROTOCOL_VERSION "1:0:1"
/**
* Salt we use when doing the KDF for access.
@@ -826,6 +826,14 @@ handle_mhd_request (void *cls,
.response_code = MHD_HTTP_OK,
.requires_auth = true },
{ .url = "/monitoring/denomination-pending",
+ .method = MHD_HTTP_METHOD_GET,
+ .mime_type = "application/json",
+ .data = NULL,
+ .data_size = 0,
+ .handler = &TAH_get_monitoring_denomination_pending,
+ .response_code = MHD_HTTP_OK,
+ .requires_auth = true },
+ { .url = "/monitoring/denomination-pending",
.method = MHD_HTTP_METHOD_DELETE,
.mime_type = "application/json",
.data = NULL,
diff --git a/src/auditor/taler-auditor-httpd_get-monitoring-denomination-pending.c b/src/auditor/taler-auditor-httpd_get-monitoring-denomination-pending.c
@@ -0,0 +1,129 @@
+/*
+ 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/>
+ */
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_json_lib.h>
+#include <jansson.h>
+#include <microhttpd.h>
+#include <pthread.h>
+#include "taler/taler_json_lib.h"
+#include "taler/taler_mhd_lib.h"
+#include "taler-auditor-httpd.h"
+#include "taler-auditor-httpd_get-monitoring-denomination-pending.h"
+#define TALER_AUDITORDB_DENOMINATION_PENDING_RESULT_CLOSURE json_t
+#include "auditor-database/iterate_denomination_pending.h"
+#include "auditor-database/preflight.h"
+
+/**
+ * Add denomination-pending to the list.
+ *
+ * @param[in,out] list a `json_t *` array to extend
+ * @param serial_id location of the @a dc in the database
+ * @param dc struct of inconsistencies
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
+ */
+static enum GNUNET_GenericReturnValue
+process_denomination_pending (
+ json_t *list,
+ uint64_t serial_id,
+ const struct TALER_AUDITORDB_DenominationPending *dc)
+{
+ json_t *obj;
+
+ obj = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_data_auto ("denom_pub_hash",
+ &dc->denom_pub_hash),
+ TALER_JSON_pack_amount ("denom_balance",
+ &dc->denom_balance),
+ TALER_JSON_pack_amount ("denom_loss",
+ &dc->denom_loss),
+ GNUNET_JSON_pack_int64 ("num_issued",
+ dc->num_issued),
+ TALER_JSON_pack_amount ("denom_risk",
+ &dc->denom_risk),
+ TALER_JSON_pack_amount ("recoup_loss",
+ &dc->recoup_loss)
+ );
+ GNUNET_break (0 ==
+ json_array_append_new (list,
+ obj));
+ return GNUNET_OK;
+}
+
+
+enum MHD_Result
+TAH_get_monitoring_denomination_pending (
+ struct TAH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size,
+ const char *const args[])
+{
+ json_t *ja;
+ enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+
+ (void) rh;
+ (void) connection_cls;
+ (void) upload_data;
+ (void) upload_data_size;
+ if (GNUNET_SYSERR ==
+ TALER_AUDITORDB_preflight (TAH_apg))
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_SETUP_FAILED,
+ NULL);
+ }
+ TALER_MHD_parse_request_snumber (connection,
+ "limit",
+ &limit);
+ if (limit < 0)
+ offset = INT64_MAX;
+ else
+ offset = 0;
+ TALER_MHD_parse_request_number (connection,
+ "offset",
+ &offset);
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
+ qs = TALER_AUDITORDB_iterate_denomination_pending (
+ TAH_apg,
+ limit,
+ offset,
+ &process_denomination_pending,
+ ja);
+
+ if (0 > qs)
+ {
+ GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+ json_decref (ja);
+ TALER_LOG_WARNING (
+ "Failed to handle GET /denomination-pending");
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "get_denomination_pending");
+ }
+ return TALER_MHD_REPLY_JSON_PACK (
+ connection,
+ MHD_HTTP_OK,
+ GNUNET_JSON_pack_array_steal ("denomination_pending",
+ ja));
+}
diff --git a/src/auditordb/0004-auditor_denomination_pending.sql b/src/auditordb/0004-auditor_denomination_pending.sql
@@ -1,18 +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/>
---
-
--- This was never used
-DROP TABLE auditor_denomination_pending;
diff --git a/src/auditordb/insert_denomination_pending.c b/src/auditordb/insert_denomination_pending.c
@@ -0,0 +1,59 @@
+/*
+ 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/>
+ */
+
+
+#include "taler/taler_pq_lib.h"
+#include "pg_helper.h"
+
+#include "auditor-database/insert_denomination_pending.h"
+
+enum GNUNET_DB_QueryStatus
+TALER_AUDITORDB_insert_denomination_pending (
+ struct TALER_AUDITORDB_PostgresContext *pg,
+ const struct TALER_AUDITORDB_DenominationPending *dc)
+{
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (&dc->denom_pub_hash),
+ TALER_PQ_query_param_amount (pg->conn, &dc->denom_balance),
+ TALER_PQ_query_param_amount (pg->conn, &dc->denom_loss),
+ GNUNET_PQ_query_param_uint64 (&dc->num_issued),
+ TALER_PQ_query_param_amount (pg->conn, &dc->denom_risk),
+ TALER_PQ_query_param_amount (pg->conn, &dc->recoup_loss),
+ GNUNET_PQ_query_param_end
+ };
+
+ PREPARE (pg,
+ "insert_denomination_pending",
+ "INSERT INTO auditor_denomination_pending "
+ "( denom_pub_hash,"
+ " denom_balance,"
+ " denom_loss,"
+ " num_issued,"
+ " denom_risk,"
+ " recoup_loss"
+ ") VALUES ($1,$2,$3,$4,$5,$6)"
+ " ON CONFLICT (denom_pub_hash) DO UPDATE"
+ " SET denom_balance = excluded.denom_balance, "
+ " denom_loss = excluded.denom_loss,"
+ " num_issued = excluded.num_issued,"
+ " denom_risk = excluded.denom_risk,"
+ " recoup_loss = excluded.recoup_loss;"
+ );
+ return GNUNET_PQ_eval_prepared_non_select (
+ pg->conn,
+ "insert_denomination_pending",
+ params);
+}
diff --git a/src/auditordb/iterate_denomination_pending.c b/src/auditordb/iterate_denomination_pending.c
@@ -0,0 +1,169 @@
+/*
+ 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/>
+ */
+#include "taler/taler_pq_lib.h"
+#include "pg_helper.h"
+#include "auditor-database/iterate_denomination_pending.h"
+
+
+struct DenominationPendingContext
+{
+
+ /**
+ * Function to call for each bad sig loss.
+ */
+ TALER_AUDITORDB_DenominationPendingCallback cb;
+
+ /**
+ * Closure for @e cb
+ */
+ void *cb_cls;
+
+ /**
+ * Plugin context.
+ */
+ struct TALER_AUDITORDB_PostgresContext *pg;
+
+ /**
+ * Query status to return.
+ */
+ enum GNUNET_DB_QueryStatus qs;
+};
+
+
+/**
+ * Helper function for #TALER_AUDITORDB_iterate_denomination_pending().
+ * To be called with the results of a SELECT statement
+ * that has returned @a num_results results.
+ *
+ * @param cls closure of type `struct DenominationPendingContext *`
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+denomination_pending_cb (void *cls,
+ PGresult *result,
+ unsigned int num_results)
+{
+ struct DenominationPendingContext *dcc = cls;
+ struct TALER_AUDITORDB_PostgresContext *pg = dcc->pg;
+
+ for (unsigned int i = 0; i < num_results; i++)
+ {
+ uint64_t serial_id;
+ struct TALER_AUDITORDB_DenominationPending dc;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_uint64 ("row_id",
+ &serial_id),
+ GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
+ &dc.denom_pub_hash),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_balance",
+ &dc.denom_balance),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_loss",
+ &dc.denom_loss),
+ GNUNET_PQ_result_spec_uint64 ("num_issued",
+ &dc.num_issued),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("denom_risk",
+ &dc.denom_risk),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("recoup_loss",
+ &dc.recoup_loss),
+ GNUNET_PQ_result_spec_end
+ };
+ enum GNUNET_GenericReturnValue rval;
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ i))
+ {
+ GNUNET_break (0);
+ dcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
+ return;
+ }
+ dcc->qs = i + 1;
+ rval = dcc->cb (dcc->cb_cls,
+ serial_id,
+ &dc);
+ GNUNET_PQ_cleanup_result (rs);
+ if (GNUNET_OK != rval)
+ break;
+ }
+}
+
+
+enum GNUNET_DB_QueryStatus
+TALER_AUDITORDB_iterate_denomination_pending (
+ struct TALER_AUDITORDB_PostgresContext *pg,
+ int64_t limit,
+ uint64_t offset,
+ TALER_AUDITORDB_DenominationPendingCallback cb,
+ void *cb_cls)
+{
+ uint64_t plimit = (uint64_t) ((limit < 0) ? -limit : limit);
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_uint64 (&offset),
+ GNUNET_PQ_query_param_uint64 (&plimit),
+ GNUNET_PQ_query_param_end
+ };
+ struct DenominationPendingContext dcc = {
+ .cb = cb,
+ .cb_cls = cb_cls,
+ .pg = pg
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ PREPARE (pg,
+ "iterate_denomination_pending_desc",
+ "SELECT"
+ " row_id,"
+ " denom_pub_hash,"
+ " denom_balance,"
+ " denom_loss,"
+ " num_issued,"
+ " denom_risk,"
+ " recoup_loss"
+ " FROM auditor_denomination_pending"
+ " WHERE (row_id < $1)"
+ " ORDER BY row_id DESC"
+ " LIMIT $2"
+ );
+ PREPARE (pg,
+ "iterate_denomination_pending_asc",
+ "SELECT"
+ " row_id,"
+ " denom_pub_hash,"
+ " denom_balance,"
+ " denom_loss,"
+ " num_issued,"
+ " denom_risk,"
+ " recoup_loss"
+ " FROM auditor_denomination_pending"
+ " WHERE (row_id > $1)"
+ " ORDER BY row_id ASC"
+ " LIMIT $2"
+ );
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ (limit > 0)
+ ? "iterate_denomination_pending_asc"
+ : "iterate_denomination_pending_desc",
+ params,
+ &denomination_pending_cb,
+ &dcc);
+ if (qs > 0)
+ return dcc.qs;
+ GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
+ return qs;
+}
diff --git a/src/auditordb/meson.build b/src/auditordb/meson.build
@@ -64,7 +64,6 @@ auditor_0004_sql = [
'0004-auditor_kycauth_in_inconsistency.sql',
'0004-auditor_pending_deposits.sql',
'0004-auditor_purse_not_closed_inconsistencies.sql',
- '0004-auditor_denomination_pending.sql',
'commit.sql',
]
@@ -122,6 +121,7 @@ libtalerauditordb = library(
'iterate_coin_inconsistencies.c',
'get_denomination_balance.c',
'iterate_denomination_key_validity_withdraw_inconsistencies.c',
+ 'iterate_denomination_pending.c',
'iterate_denominations_without_sigs.c',
'iterate_deposit_confirmations.c',
'iterate_emergencies_by_count.c',
@@ -156,6 +156,7 @@ libtalerauditordb = library(
'insert_coin_inconsistency.c',
'insert_denomination_balance.c',
'insert_denomination_key_validity_withdraw_inconsistency.c',
+ 'insert_denomination_pending.c',
'insert_denominations_without_sigs.c',
'insert_deposit_confirmation.c',
'insert_early_aggregation.c',
diff --git a/src/include/auditor-database/insert_denomination_pending.h b/src/include/auditor-database/insert_denomination_pending.h
@@ -0,0 +1,36 @@
+/*
+ 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/>
+ */
+
+
+#ifndef AUDITOR_DATABASE_INSERT_DENOMINATION_PENDING_H
+#define AUDITOR_DATABASE_INSERT_DENOMINATION_PENDING_H
+
+#include "auditordb_lib.h"
+
+
+/**
+ * Insert information about a bad sig loss into the database.
+ *
+ * @param pg the database context
+ * @param dc deposit confirmation information to store
+ * @return query result status
+ */
+enum GNUNET_DB_QueryStatus
+TALER_AUDITORDB_insert_denomination_pending (
+ struct TALER_AUDITORDB_PostgresContext *pg,
+ const struct TALER_AUDITORDB_DenominationPending *dc);
+
+#endif // AUDITOR_DATABASE_INSERT_DENOMINATION_PENDING_H
diff --git a/src/include/auditor-database/iterate_denomination_pending.h b/src/include/auditor-database/iterate_denomination_pending.h
@@ -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/>
+ */
+#ifndef AUDITOR_DATABASE_ITERATE_DENOMINATION_PENDING_H
+#define AUDITOR_DATABASE_ITERATE_DENOMINATION_PENDING_H
+
+#include "taler/taler_util.h"
+#include "taler/taler_json_lib.h"
+#include "auditordb_lib.h"
+
+
+#ifndef TALER_AUDITORDB_DENOMINATION_PENDING_RESULT_CLOSURE
+/**
+ * Type of the closure for #TALER_AUDITORDB_DenominationPendingCallback.
+ */
+#define TALER_AUDITORDB_DENOMINATION_PENDING_RESULT_CLOSURE void
+#endif
+typedef enum GNUNET_GenericReturnValue
+(*TALER_AUDITORDB_DenominationPendingCallback)(
+ TALER_AUDITORDB_DENOMINATION_PENDING_RESULT_CLOSURE *cls,
+ uint64_t serial_id,
+ const struct TALER_AUDITORDB_DenominationPending *dc);
+
+
+/* Callback typedefs */
+typedef enum GNUNET_GenericReturnValue
+(*TALER_AUDITORDB_DenominationPendingCallback)(
+ TALER_AUDITORDB_DENOMINATION_PENDING_RESULT_CLOSURE *cls,
+ uint64_t serial_id,
+ const struct TALER_AUDITORDB_DenominationPending *dc);
+
+/**
+ * Get information about denomination-pending from the database.
+ *
+ * @param pg the database context
+ * @param limit number of records to return, negative for descending
+ * @param offset table row to start from, exclusive, direction determined by @a limit
+ * @param cb function to call with results
+ * @param cb_cls closure for @a cb
+ * @return query result status
+ */
+enum GNUNET_DB_QueryStatus
+TALER_AUDITORDB_iterate_denomination_pending (struct
+ TALER_AUDITORDB_PostgresContext *
+ pg,
+ int64_t limit,
+ uint64_t offset,
+ TALER_AUDITORDB_DenominationPendingCallback
+ cb,
+ TALER_AUDITORDB_DENOMINATION_PENDING_RESULT_CLOSURE
+ *cb_cls);
+
+#endif
diff --git a/src/lib/auditor_api_get_config.c b/src/lib/auditor_api_get_config.c
@@ -32,7 +32,7 @@
* Which revision of the Taler auditor protocol is implemented
* by this library? Used to determine compatibility.
*/
-#define TALER_PROTOCOL_CURRENT 3
+#define TALER_PROTOCOL_CURRENT 1
/**
* How many revisions back are we compatible to?