diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-09-14 17:37:53 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-09-14 17:37:53 +0200 |
commit | 6e5092d83473dc1b0200d82744cf0f0056b0c110 (patch) | |
tree | 3a402d87e500fd4e85efb2ec19dfae6d942d9265 /src/auditordb | |
parent | 1d088120a5c378ec5fe2d9cfd86353f9b75220c4 (diff) | |
download | exchange-6e5092d83473dc1b0200d82744cf0f0056b0c110.tar.xz |
more work towards auditor support for AML/KYC
Diffstat (limited to 'src/auditordb')
-rw-r--r-- | src/auditordb/Makefile.am | 3 | ||||
-rw-r--r-- | src/auditordb/auditor-0001.sql | 26 | ||||
-rw-r--r-- | src/auditordb/pg_delete_pending_deposit.c | 51 | ||||
-rw-r--r-- | src/auditordb/pg_delete_pending_deposit.h | 46 | ||||
-rw-r--r-- | src/auditordb/pg_get_wire_auditor_progress.c | 13 | ||||
-rw-r--r-- | src/auditordb/pg_insert_pending_deposit.c | 61 | ||||
-rw-r--r-- | src/auditordb/pg_insert_pending_deposit.h | 50 | ||||
-rw-r--r-- | src/auditordb/pg_insert_wire_auditor_progress.c | 10 | ||||
-rw-r--r-- | src/auditordb/pg_select_pending_deposits.c | 152 | ||||
-rw-r--r-- | src/auditordb/pg_select_pending_deposits.h | 46 | ||||
-rw-r--r-- | src/auditordb/pg_template.c | 2 | ||||
-rw-r--r-- | src/auditordb/pg_template.h | 2 | ||||
-rw-r--r-- | src/auditordb/pg_update_wire_auditor_progress.c | 12 | ||||
-rw-r--r-- | src/auditordb/plugin_auditordb_postgres.c | 10 |
14 files changed, 467 insertions, 17 deletions
diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am index 98b19f894..abdba5c2b 100644 --- a/src/auditordb/Makefile.am +++ b/src/auditordb/Makefile.am @@ -62,6 +62,9 @@ libtaler_plugin_auditordb_postgres_la_SOURCES = \ pg_get_reserve_info.h pg_get_reserve_info.c \ pg_insert_reserve_summary.h pg_insert_reserve_summary.c \ pg_update_reserve_summary.h pg_update_reserve_summary.c \ + pg_select_pending_deposits.h pg_select_pending_deposits.c \ + pg_delete_pending_deposit.h pg_delete_pending_deposit.c \ + pg_insert_pending_deposit.h pg_insert_pending_deposit.c \ pg_get_reserve_summary.h pg_get_reserve_summary.c \ pg_insert_wire_fee_summary.h pg_insert_wire_fee_summary.c \ pg_update_wire_fee_summary.h pg_update_wire_fee_summary.c \ diff --git a/src/auditordb/auditor-0001.sql b/src/auditordb/auditor-0001.sql index c5c037c31..2fe322b1f 100644 --- a/src/auditordb/auditor-0001.sql +++ b/src/auditordb/auditor-0001.sql @@ -139,8 +139,9 @@ COMMENT ON TABLE wire_auditor_account_progress CREATE TABLE IF NOT EXISTS wire_auditor_progress (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE - ,last_timestamp INT8 NOT NULL ,last_reserve_close_uuid INT8 NOT NULL + ,last_batch_deposit_uuid INT8 NOT NULL + ,last_aggregation_serial INT8 NOT NULL ,PRIMARY KEY (master_pub) ); @@ -309,5 +310,28 @@ COMMENT ON TABLE auditor_predicted_result IS 'Table with the sum of the ledger, auditor_historic_revenue and the auditor_reserve_balance and the drained profits. This is the final amount that the exchange should have in its bank account right now (and the total amount drained as profits to non-escrow accounts).'; +CREATE TABLE IF NOT EXISTS auditor_pending_deposits + (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE + ,total_amount taler_amount NOT NULL + ,wire_target_h_payto BYTEA CHECK (LENGTH(wire_target_h_payto)=64) + ,batch_deposit_serial_id INT8 NOT NULL + ,deadline INT8 NOT NULL + ,PRIMARY KEY(master_pub, batch_deposit_serial_id) + ); +COMMENT ON TABLE auditor_pending_deposits + IS 'Table with the sum of the (batch) deposits we have seen but not yet checked that they have been aggregated and wired for a particular target bank account'; +COMMENT ON COLUMN auditor_pending_deposits.total_amount + IS 'Amount we expect to be wired in total for the batch. Includes deposit fees, not the actual expected net wire transfer amount.'; +COMMENT ON COLUMN auditor_pending_deposits.wire_target_h_payto + IS 'Hash of the payto URI of the bank account to be credited by the deadline'; +COMMENT ON COLUMN auditor_pending_deposits.batch_deposit_serial_id + IS 'Entry in the batch_deposits table of the exchange this entry is for'; +COMMENT ON COLUMN auditor_pending_deposits.deadline + IS 'Deadline by which funds should be wired (may be in the future)'; +CREATE INDEX IF NOT EXISTS auditor_pending_deposits_by_deadline + ON auditor_pending_deposits + (master_pub + ,deadline ASC); + -- Finally, commit everything COMMIT; diff --git a/src/auditordb/pg_delete_pending_deposit.c b/src/auditordb/pg_delete_pending_deposit.c new file mode 100644 index 000000000..3dfd467c5 --- /dev/null +++ b/src/auditordb/pg_delete_pending_deposit.c @@ -0,0 +1,51 @@ +/* + This file is part of TALER + Copyright (C) 2023 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 auditordb/pg_delete_pending_deposit.c + * @brief Implementation of the delete_pending_deposit 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_delete_pending_deposit.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TAH_PG_delete_pending_deposit ( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + uint64_t batch_deposit_serial_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (master_pub), + GNUNET_PQ_query_param_uint64 (&batch_deposit_serial_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_pending_deposit", + "DELETE" + " FROM auditor_pending_deposits" + " WHERE master_pub=$1" + " AND batch_deposit_serial_id=$2;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_pending_deposit", + params); +} diff --git a/src/auditordb/pg_delete_pending_deposit.h b/src/auditordb/pg_delete_pending_deposit.h new file mode 100644 index 000000000..fb39ef199 --- /dev/null +++ b/src/auditordb/pg_delete_pending_deposit.h @@ -0,0 +1,46 @@ +/* + This file is part of TALER + Copyright (C) 2023 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 auditordb/pg_delete_pending_deposit.h + * @brief implementation of the delete_pending_deposit function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_DELETE_PENDING_DEPOSIT_H +#define PG_DELETE_PENDING_DEPOSIT_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + + +/** + * Delete a row from the pending deposit table. + * Usually done when the respective wire transfer + * was finally detected. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param master_pub master key of the exchange + * @param batch_deposit_serial_id which entry to delete + * @return transaction status code + */ +enum GNUNET_DB_QueryStatus +TAH_PG_delete_pending_deposit ( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + uint64_t batch_deposit_serial_id); + + +#endif diff --git a/src/auditordb/pg_get_wire_auditor_progress.c b/src/auditordb/pg_get_wire_auditor_progress.c index c5caf3f01..a0eaefc65 100644 --- a/src/auditordb/pg_get_wire_auditor_progress.c +++ b/src/auditordb/pg_get_wire_auditor_progress.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-2023 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 @@ -38,18 +38,21 @@ TAH_PG_get_wire_auditor_progress ( GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_timestamp ("last_timestamp", - &pp->last_timestamp), GNUNET_PQ_result_spec_uint64 ("last_reserve_close_uuid", &pp->last_reserve_close_uuid), + GNUNET_PQ_result_spec_uint64 ("last_batch_deposit_uuid", + &pp->last_batch_deposit_uuid), + GNUNET_PQ_result_spec_uint64 ("last_aggregation_serial", + &pp->last_aggregation_serial), GNUNET_PQ_result_spec_end }; PREPARE (pg, "wire_auditor_progress_select", "SELECT" - " last_timestamp" - ",last_reserve_close_uuid" + " last_reserve_close_uuid" + ",last_batch_deposit_uuid" + ",last_aggregation_serial" " FROM wire_auditor_progress" " WHERE master_pub=$1;"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, diff --git a/src/auditordb/pg_insert_pending_deposit.c b/src/auditordb/pg_insert_pending_deposit.c new file mode 100644 index 000000000..11b3e48e1 --- /dev/null +++ b/src/auditordb/pg_insert_pending_deposit.c @@ -0,0 +1,61 @@ +/* + This file is part of TALER + Copyright (C) 2023 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 auditordb/pg_insert_pending_deposit.c + * @brief Implementation of the insert_pending_deposit 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_insert_pending_deposit.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_pending_deposit ( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + uint64_t batch_deposit_serial_id, + const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_Amount *total_amount, + struct GNUNET_TIME_Timestamp deadline) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (master_pub), + TALER_PQ_query_param_amount (pg->conn, + total_amount), + GNUNET_PQ_query_param_auto_from_type (wire_target_h_payto), + GNUNET_PQ_query_param_uint64 (&batch_deposit_serial_id), + GNUNET_PQ_query_param_timestamp (&deadline), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_insert_pending_deposit", + "INSERT INTO auditor_pending_deposits " + "(master_pub" + ",total_amount" + ",wire_target_h_payto" + ",batch_deposit_serial_id" + ",deadline" + ") VALUES ($1,$2,$3,$4,$5);"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_insert_pending_deposit", + params); +} diff --git a/src/auditordb/pg_insert_pending_deposit.h b/src/auditordb/pg_insert_pending_deposit.h new file mode 100644 index 000000000..2f867e87e --- /dev/null +++ b/src/auditordb/pg_insert_pending_deposit.h @@ -0,0 +1,50 @@ +/* + This file is part of TALER + Copyright (C) 2023 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 auditordb/pg_insert_pending_deposit.h + * @brief implementation of the insert_pending_deposit function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_INSERT_PENDING_DEPOSIT_H +#define PG_INSERT_PENDING_DEPOSIT_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert new row into the pending deposits table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param master_pub master key of the exchange + * @param batch_deposit_serial_id where in the table are we + * @param total_amount value of all missing deposits, including fees + * @param wire_target_h_payto hash of the recipient account's payto URI + * @param deadline what was the requested wire transfer deadline + * @return transaction status code + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_pending_deposit ( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + uint64_t batch_deposit_serial_id, + const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_Amount *total_amount, + struct GNUNET_TIME_Timestamp deadline); + + +#endif diff --git a/src/auditordb/pg_insert_wire_auditor_progress.c b/src/auditordb/pg_insert_wire_auditor_progress.c index 7853d3ff6..c9e302773 100644 --- a/src/auditordb/pg_insert_wire_auditor_progress.c +++ b/src/auditordb/pg_insert_wire_auditor_progress.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-2023 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 @@ -35,8 +35,9 @@ TAH_PG_insert_wire_auditor_progress ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), - GNUNET_PQ_query_param_timestamp (&pp->last_timestamp), GNUNET_PQ_query_param_uint64 (&pp->last_reserve_close_uuid), + GNUNET_PQ_query_param_uint64 (&pp->last_batch_deposit_uuid), + GNUNET_PQ_query_param_uint64 (&pp->last_aggregation_serial), GNUNET_PQ_query_param_end }; @@ -44,9 +45,10 @@ TAH_PG_insert_wire_auditor_progress ( "wire_auditor_progress_insert", "INSERT INTO wire_auditor_progress " "(master_pub" - ",last_timestamp" ",last_reserve_close_uuid" - ") VALUES ($1,$2,$3);"); + ",last_batch_deposit_uuid" + ",last_aggregation_serial" + ") VALUES ($1,$2,$3,$4);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "wire_auditor_progress_insert", params); diff --git a/src/auditordb/pg_select_pending_deposits.c b/src/auditordb/pg_select_pending_deposits.c new file mode 100644 index 000000000..a5d1c6ae8 --- /dev/null +++ b/src/auditordb/pg_select_pending_deposits.c @@ -0,0 +1,152 @@ +/* + This file is part of TALER + Copyright (C) 2023 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 auditordb/pg_select_pending_deposits.c + * @brief Implementation of the select_pending_deposits 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_select_pending_deposits.h" +#include "pg_helper.h" + + +/** + * Closure for #wire_missing_cb(). + */ +struct WireMissingContext +{ + + /** + * Function to call for each pending deposit. + */ + TALER_AUDITORDB_WireMissingCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_select_purse_expired(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct WireMissingContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +wire_missing_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct WireMissingContext *eic = cls; + struct PostgresClosure *pg = eic->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t batch_deposit_serial_id; + struct TALER_Amount total_amount; + struct TALER_PaytoHashP wire_target_h_payto; + struct GNUNET_TIME_Timestamp deadline; + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("batch_deposit_serial_id", + &batch_deposit_serial_id), + TALER_PQ_RESULT_SPEC_AMOUNT ("total_amount", + &total_amount), + GNUNET_PQ_result_spec_auto_from_type ("wire_target_h_payto", + &wire_target_h_payto), + GNUNET_PQ_result_spec_timestamp ("deadline", + &deadline), + GNUNET_PQ_result_spec_end + }; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + eic->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + eic->cb (eic->cb_cls, + batch_deposit_serial_id, + &total_amount, + &wire_target_h_payto, + deadline); + } + eic->qs = num_results; +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_select_pending_deposits ( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + struct GNUNET_TIME_Absolute deadline, + TALER_AUDITORDB_WireMissingCallback cb, + void *cb_cls) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (master_pub), + GNUNET_PQ_query_param_absolute_time (&deadline), + GNUNET_PQ_query_param_end + }; + struct WireMissingContext eic = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_select_pending_deposits", + "SELECT" + " batch_deposit_serial_id" + ",total_amount" + ",wire_target_h_payto" + ",deadline" + " FROM auditor_pending_deposits" + " WHERE master_pub=$1" + " AND deadline<$2;"); + qs = GNUNET_PQ_eval_prepared_multi_select ( + pg->conn, + "auditor_select_pending_deposits", + params, + &wire_missing_cb, + &eic); + if (0 > qs) + return qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != eic.qs); + return eic.qs; +} diff --git a/src/auditordb/pg_select_pending_deposits.h b/src/auditordb/pg_select_pending_deposits.h new file mode 100644 index 000000000..bbf3e843a --- /dev/null +++ b/src/auditordb/pg_select_pending_deposits.h @@ -0,0 +1,46 @@ +/* + This file is part of TALER + Copyright (C) 2023 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 auditordb/pg_select_pending_deposits.h + * @brief implementation of the select_pending_deposits function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_SELECT_PENDING_DEPOSITS_H +#define PG_SELECT_PENDING_DEPOSITS_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + + +/** + * Return (batch) deposits for which we have not yet + * seen the required wire transfer. + * + * @param deadline only return up to this deadline + * @param cb function to call on each entry + * @param cb_cls closure for @a cb + * @return transaction status code + */ +enum GNUNET_DB_QueryStatus +TAH_PG_select_pending_deposits ( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + struct GNUNET_TIME_Absolute deadline, + TALER_AUDITORDB_WireMissingCallback cb, + void *cb_cls); + +#endif diff --git a/src/auditordb/pg_template.c b/src/auditordb/pg_template.c index 3e9cb642e..ab1f968e6 100644 --- a/src/auditordb/pg_template.c +++ b/src/auditordb/pg_template.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2023 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 diff --git a/src/auditordb/pg_template.h b/src/auditordb/pg_template.h index acada6059..3910115b1 100644 --- a/src/auditordb/pg_template.h +++ b/src/auditordb/pg_template.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2023 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 diff --git a/src/auditordb/pg_update_wire_auditor_progress.c b/src/auditordb/pg_update_wire_auditor_progress.c index 5fb0ff31a..a4b991543 100644 --- a/src/auditordb/pg_update_wire_auditor_progress.c +++ b/src/auditordb/pg_update_wire_auditor_progress.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-2023 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 @@ -34,8 +34,9 @@ TAH_PG_update_wire_auditor_progress ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_timestamp (&pp->last_timestamp), GNUNET_PQ_query_param_uint64 (&pp->last_reserve_close_uuid), + GNUNET_PQ_query_param_uint64 (&pp->last_batch_deposit_uuid), + GNUNET_PQ_query_param_uint64 (&pp->last_aggregation_serial), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; @@ -43,9 +44,10 @@ TAH_PG_update_wire_auditor_progress ( PREPARE (pg, "wire_auditor_progress_update", "UPDATE wire_auditor_progress SET " - " last_timestamp=$1" - ",last_reserve_close_uuid=$2" - " WHERE master_pub=$3"); + " last_reserve_close_uuid=$1" + ",last_batch_deposit_uuid=$2" + ",last_aggregation_serial=$3" + " WHERE master_pub=$4"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "wire_auditor_progress_update", params); diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 5ed01e5d2..24d1768bf 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -36,6 +36,9 @@ #include "pg_insert_auditor_progress_deposit_confirmation.h" #include "pg_update_auditor_progress_deposit_confirmation.h" #include "pg_get_auditor_progress_deposit_confirmation.h" +#include "pg_select_pending_deposits.h" +#include "pg_delete_pending_deposit.h" +#include "pg_insert_pending_deposit.h" #include "pg_insert_auditor_progress_coin.h" #include "pg_update_auditor_progress_coin.h" #include "pg_get_auditor_progress_coin.h" @@ -510,6 +513,13 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->insert_historic_reserve_revenue = &TAH_PG_insert_historic_reserve_revenue; + plugin->select_pending_deposits + = &TAH_PG_select_pending_deposits; + plugin->delete_pending_deposit + = &TAH_PG_delete_pending_deposit; + plugin->insert_pending_deposit + = &TAH_PG_insert_pending_deposit; + plugin->get_predicted_balance = &TAH_PG_get_predicted_balance; plugin->update_predicted_result |