commit 39b420fda915fdf56312fd71c4ce6fa454ec9117 parent c9fcf19af29a9428d1521471a0acffe8b25390e5 Author: Christian Grothoff <christian@grothoff.org> Date: Tue, 27 May 2025 15:30:09 +0200 fix #10035: reserves_out table is dead, make sure we use new withdraw table in KYC threshold checks Diffstat:
21 files changed, 135 insertions(+), 418 deletions(-)
diff --git a/src/auditor/taler-auditor-sync.c b/src/auditor/taler-auditor-sync.c @@ -100,7 +100,7 @@ static struct Table tables[] = { { .rt = TALER_EXCHANGEDB_RT_RESERVES_CLOSE}, { .rt = TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS}, { .rt = TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS}, - { .rt = TALER_EXCHANGEDB_RT_RESERVES_OUT}, + { .rt = TALER_EXCHANGEDB_RT_WITHDRAW}, { .rt = TALER_EXCHANGEDB_RT_AUDITORS}, { .rt = TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS}, { .rt = TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS}, diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c @@ -231,7 +231,7 @@ report_row_inconsistency (const char *table, /* ***************************** Analyze reserves ************************ */ -/* This logic checks the reserves_in, reserves_out and reserves-tables */ +/* This logic checks the reserves_in, withdraw and reserves-tables */ /** * Summary data we keep per reserve. diff --git a/src/exchangedb/0002-reserves_out.sql b/src/exchangedb/0002-reserves_out.sql @@ -1,151 +0,0 @@ --- --- This file is part of TALER --- Copyright (C) 2014--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/> --- - -CREATE FUNCTION create_table_reserves_out( - IN partition_suffix TEXT DEFAULT NULL -) -RETURNS VOID -LANGUAGE plpgsql -AS $$ -DECLARE - table_name TEXT default 'reserves_out'; -BEGIN - PERFORM create_partitioned_table( - 'CREATE TABLE %I' - '(reserve_out_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY' - ',h_blind_ev BYTEA CHECK (LENGTH(h_blind_ev)=64) UNIQUE' - ',denominations_serial INT8 NOT NULL' - ',denom_sig BYTEA NOT NULL' - ',reserve_uuid INT8 NOT NULL' - ',reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64)' - ',execution_date INT8 NOT NULL' - ',amount_with_fee taler_amount NOT NULL' - ') %s ;' - ,'reserves_out' - ,'PARTITION BY HASH (h_blind_ev)' - ,partition_suffix - ); - PERFORM comment_partitioned_table ( - 'Withdraw operations performed on reserves.' - ,'reserves_out' - ,partition_suffix - ); - PERFORM comment_partitioned_column ( - 'Hash of the blinded coin, used as primary key here so that broken clients that use a non-random coin or blinding factor fail to withdraw (otherwise they would fail on deposit when the coin is not unique there).' - ,'h_blind_ev' - ,'reserves_out' - ,partition_suffix - ); - PERFORM comment_partitioned_column ( - 'We do not CASCADE ON DELETE for the foreign constrain here, as we may keep the denomination data alive' - ,'denominations_serial' - ,'reserves_out' - ,partition_suffix - ); -END -$$; - - -CREATE FUNCTION constrain_table_reserves_out( - IN partition_suffix TEXT -) -RETURNS void -LANGUAGE plpgsql -AS $$ -DECLARE - table_name TEXT default 'reserves_out'; -BEGIN - table_name = concat_ws('_', table_name, partition_suffix); - EXECUTE FORMAT ( - 'ALTER TABLE ' || table_name || - ' ADD CONSTRAINT ' || table_name || '_reserve_out_serial_id_key' - ' UNIQUE (reserve_out_serial_id)' - ); - EXECUTE FORMAT ( - 'CREATE INDEX ' || table_name || '_by_reserve_uuid_and_execution_date_index ' - 'ON ' || table_name || ' ' - '(reserve_uuid, execution_date);' - ); - EXECUTE FORMAT ( - 'COMMENT ON INDEX ' || table_name || '_by_reserve_uuid_and_execution_date_index ' - 'IS ' || quote_literal('for do_gc, do_recoup_by_reserve, select_kyc_relevant_withdraw_events and a few others') || ';' - ); -END -$$; - - -CREATE FUNCTION foreign_table_reserves_out() -RETURNS void -LANGUAGE plpgsql -AS $$ -DECLARE - table_name TEXT default 'reserves_out'; -BEGIN - EXECUTE FORMAT ( - 'ALTER TABLE ' || table_name || - ' ADD CONSTRAINT ' || table_name || '_foreign_denom' - ' FOREIGN KEY (denominations_serial)' - ' REFERENCES denominations (denominations_serial)' - ',ADD CONSTRAINT ' || table_name || '_foreign_reserve ' - ' FOREIGN KEY (reserve_uuid)' - ' REFERENCES reserves (reserve_uuid) ON DELETE CASCADE' - ); -END -$$; - - -CREATE FUNCTION master_table_reserves_out() -RETURNS void -LANGUAGE plpgsql -AS $$ -BEGIN - CREATE TRIGGER reserves_out_on_insert - AFTER INSERT - ON reserves_out - FOR EACH ROW EXECUTE FUNCTION reserves_out_insert_trigger(); -END $$; -COMMENT ON FUNCTION master_table_reserves_out() - IS 'Setup triggers to replicate reserve_out into reserve_history.'; - - - -INSERT INTO exchange_tables - (name - ,version - ,action - ,partitioned - ,by_range) - VALUES - ('reserves_out' - ,'exchange-0002' - ,'create' - ,TRUE - ,FALSE), - ('reserves_out' - ,'exchange-0002' - ,'constrain' - ,TRUE - ,FALSE), - ('reserves_out' - ,'exchange-0002' - ,'foreign' - ,TRUE - ,FALSE), - ('reserves_out' - ,'exchange-0002' - ,'master' - ,TRUE - ,FALSE); diff --git a/src/exchangedb/0002-withdraw.sql b/src/exchangedb/0002-withdraw.sql @@ -175,38 +175,6 @@ BEGIN END $$; --- Trigger to update the reserve_history table -CREATE FUNCTION withdraw_insert_trigger() - RETURNS trigger - LANGUAGE plpgsql - AS $$ -BEGIN - INSERT INTO reserve_history - (reserve_pub - ,table_name - ,serial_id) - VALUES - (NEW.reserve_pub - ,'withdraw' - ,NEW.withdraw_id); - RETURN NEW; -END $$; -COMMENT ON FUNCTION withdraw_insert_trigger() - IS 'Keep track of a particular withdraw in the reserve_history table.'; - --- Trigger to update the unique_withdraw_blinding_seed table -CREATE FUNCTION withdraw_delete_trigger() - RETURNS trigger - LANGUAGE plpgsql - AS $$ -BEGIN - DELETE FROM unique_withdraw_blinding_seed - WHERE blinding_seed = OLD.blinding_seed; - RETURN OLD; -END $$; -COMMENT ON FUNCTION withdraw_delete_trigger() - IS 'Delete blinding_seed from unique_withdraw_blinding_seed table.'; - -- Put the triggers into the master table CREATE FUNCTION master_table_withdraw() RETURNS void diff --git a/src/exchangedb/0003-reserves_out.sql b/src/exchangedb/0003-reserves_out.sql @@ -0,0 +1,40 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2025 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/> +-- + + +CREATE FUNCTION master_table_reserves_out3() +RETURNS void +LANGUAGE plpgsql +AS $$ +BEGIN + DROP TABLE IF EXISTS reserves_out; +END $$; +COMMENT ON FUNCTION master_table_reserves_out3() + IS 'Deletes the obsolete reserves_out table.'; + + +INSERT INTO exchange_tables + (name + ,version + ,action + ,partitioned + ,by_range) + VALUES + ('reserves_out3' + ,'exchange-0003' + ,'master' + ,TRUE + ,FALSE); diff --git a/src/exchangedb/auditor-triggers-0001.sql b/src/exchangedb/auditor-triggers-0001.sql @@ -163,7 +163,7 @@ EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger(); CREATE OR REPLACE TRIGGER auditor_exchange_notify_helper_aggregation9 - AFTER INSERT ON exchange.reserves_out + AFTER INSERT ON exchange.withdraw EXECUTE FUNCTION auditor_wake_aggregation_helper_trigger(); @@ -264,7 +264,7 @@ EXECUTE FUNCTION auditor_wake_coins_helper_trigger(); CREATE OR REPLACE TRIGGER auditor_exchange_notify_helper_coins10 - AFTER INSERT ON exchange.reserves_out + AFTER INSERT ON exchange.withdraw EXECUTE FUNCTION auditor_wake_coins_helper_trigger(); @@ -395,7 +395,7 @@ EXECUTE FUNCTION auditor_wake_reserves_helper_trigger(); CREATE OR REPLACE TRIGGER auditor_exchange_notify_helper_reserves5 - AFTER INSERT ON exchange.reserves_out + AFTER INSERT ON exchange.withdraw EXECUTE FUNCTION auditor_wake_reserves_helper_trigger(); diff --git a/src/exchangedb/exchange-0002.sql.in b/src/exchangedb/exchange-0002.sql.in @@ -88,7 +88,6 @@ COMMENT ON TYPE exchange_do_select_aggregations_above_serial_return_type #include "0002-close_requests.sql" #include "0002-reserves_open_deposits.sql" #include "0002-reserves_open_requests.sql" -#include "0002-reserves_out.sql" #include "0002-known_coins.sql" #include "0002-coin_history.sql" #include "0002-batch_deposits.sql" diff --git a/src/exchangedb/exchange-0003.sql.in b/src/exchangedb/exchange-0003.sql.in @@ -28,5 +28,7 @@ SET search_path TO exchange; -- as we first need to create kyc_targets and migrate the -- data before dropping it in wire_targets! #include "0003-wire_targets.sql" +-- This table was already dead in v1.0, drop it for real +#include "0003-reserves_out.sql" COMMIT; diff --git a/src/exchangedb/exchange_do_main_gc.sql b/src/exchangedb/exchange_do_main_gc.sql @@ -20,7 +20,6 @@ CREATE OR REPLACE PROCEDURE exchange_do_main_gc( LANGUAGE plpgsql AS $$ DECLARE - reserve_uuid_min INT8; -- minimum reserve UUID still alive coin_min INT8; -- minimum known_coin still alive batch_deposit_min INT8; -- minimum deposit still alive withdraw_min INT8; -- minimum withdraw still alive @@ -46,9 +45,19 @@ DELETE FROM batch_deposits WHERE wire_deadline < in_ancient_date; -- FIXME: use closing fee as threshold? -DELETE FROM reserves - WHERE gc_date < in_now - AND current_balance = (0, 0); +DELETE FROM withdraw + WHERE reserve_pub IN ( + SELECT reserve_pub + FROM reserves + WHERE gc_date < in_now + AND current_balance = (0, 0)); + +DELETE FROM reserves_close + WHERE reserve_pub IN ( + SELECT reserve_pub + FROM reserves + WHERE gc_date < in_now + AND current_balance = (0, 0)); SELECT withdraw_id INTO withdraw_min @@ -59,22 +68,17 @@ SELECT withdraw_id DELETE FROM recoup WHERE withdraw_id < withdraw_min; -SELECT reserve_uuid - INTO reserve_uuid_min - FROM reserves - ORDER BY reserve_uuid ASC - LIMIT 1; - -DELETE FROM reserves_out - WHERE reserve_uuid < reserve_uuid_min; +DELETE FROM reserves + WHERE gc_date < in_now + AND current_balance = (0, 0); -- FIXME: this query will be horribly slow; -- need to find another way to formulate it... DELETE FROM denominations WHERE expire_legal < in_now AND denominations_serial NOT IN - (SELECT DISTINCT denominations_serial - FROM reserves_out) + (SELECT DISTINCT UNNEST(denomin_serials) + FROM withdraw) AND denominations_serial NOT IN (SELECT DISTINCT denominations_serial FROM known_coins diff --git a/src/exchangedb/exchange_trigger_reserves_out_insert.sql b/src/exchangedb/exchange_trigger_reserves_out_insert.sql @@ -1,37 +0,0 @@ --- --- 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/> --- - -CREATE OR REPLACE FUNCTION reserves_out_insert_trigger() - RETURNS trigger - LANGUAGE plpgsql - AS $$ -BEGIN - INSERT INTO exchange.reserve_history - (reserve_pub - ,table_name - ,serial_id) - SELECT - res.reserve_pub - ,'reserves_out' - ,NEW.reserve_out_serial_id - FROM - exchange.reserves res - WHERE res.reserve_uuid = NEW.reserve_uuid; - RETURN NEW; -END $$; -COMMENT ON FUNCTION reserves_out_insert_trigger() - IS 'Replicate reserve_out inserts into reserve_history table.'; - diff --git a/src/exchangedb/exchange_trigger_withdraw_delete.sql b/src/exchangedb/exchange_trigger_withdraw_delete.sql @@ -0,0 +1,29 @@ +-- +-- 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/> +-- + +-- Trigger to update the unique_withdraw_blinding_seed table + +CREATE OR REPLACE FUNCTION withdraw_delete_trigger() + RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + DELETE FROM unique_withdraw_blinding_seed + WHERE blinding_seed = OLD.blinding_seed; + RETURN OLD; +END $$; +COMMENT ON FUNCTION withdraw_delete_trigger() + IS 'Delete blinding_seed from unique_withdraw_blinding_seed table.'; diff --git a/src/exchangedb/exchange_trigger_withdraw_insert.sql b/src/exchangedb/exchange_trigger_withdraw_insert.sql @@ -0,0 +1,34 @@ +-- +-- 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/> +-- + +CREATE OR REPLACE FUNCTION withdraw_insert_trigger() + RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + INSERT INTO exchange.reserve_history + (reserve_pub + ,table_name + ,serial_id + ) VALUES ( + NEW.reserve_pub + ,'withdraw' + ,NEW.withdraw_id + ); + RETURN NEW; +END $$; +COMMENT ON FUNCTION withdraw_insert_trigger() + IS 'Replicate withdraw inserts into reserve_history table.'; diff --git a/src/exchangedb/pg_get_reserve_history.c b/src/exchangedb/pg_get_reserve_history.c @@ -815,24 +815,6 @@ TEH_PG_get_reserve_history ( " FROM withdraw " " WHERE withdraw_id=$2" " AND reserve_pub=$1;"); -/* FIXME: remove "get_reserves_out" etc. once reserves_out is phased out */ - PREPARE (pg, - "get_reserves_out", - "SELECT" - " ro.h_blind_ev" - ",denom.denom_pub_hash" - ",ro.denom_sig" - ",ro.reserve_sig" - ",ro.execution_date" - ",ro.amount_with_fee" - ",denom.fee_withdraw" - " FROM reserves_out ro" - " JOIN denominations denom" - " USING (denominations_serial)" - " JOIN reserves res" - " USING (reserve_uuid)" - " WHERE ro.reserve_out_serial_id=$2" - " AND res.reserve_pub=$1;"); PREPARE (pg, "recoup_by_reserve", "SELECT" diff --git a/src/exchangedb/pg_insert_records_by_table.c b/src/exchangedb/pg_insert_records_by_table.c @@ -637,55 +637,6 @@ irbt_cb_table_reserves_close (struct PostgresClosure *pg, /** - * Function called with reserves_out records to insert into table. - * - * @param pg plugin context - * @param td record to insert - */ -static enum GNUNET_DB_QueryStatus -irbt_cb_table_reserves_out (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_auto_from_type ( - &td->details.reserves_out.h_blind_ev), - GNUNET_PQ_query_param_uint64 ( - &td->details.reserves_out.denominations_serial), - TALER_PQ_query_param_blinded_denom_sig ( - &td->details.reserves_out.denom_sig), - GNUNET_PQ_query_param_uint64 ( - &td->details.reserves_out.reserve_uuid), - GNUNET_PQ_query_param_auto_from_type ( - &td->details.reserves_out.reserve_sig), - GNUNET_PQ_query_param_timestamp ( - &td->details.reserves_out.execution_date), - TALER_PQ_query_param_amount ( - pg->conn, - &td->details.reserves_out.amount_with_fee), - GNUNET_PQ_query_param_end - }; - - PREPARE (pg, - "insert_into_table_reserves_out", - "INSERT INTO reserves_out" - "(reserve_out_serial_id" - ",h_blind_ev" - ",denominations_serial" - ",denom_sig" - ",reserve_uuid" - ",reserve_sig" - ",execution_date" - ",amount_with_fee" - ") VALUES " - "($1, $2, $3, $4, $5, $6, $7, $8);"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "insert_into_table_reserves_out", - params); -} - - -/** * Function called with auditors records to insert into table. * * @param pg plugin context @@ -2334,9 +2285,6 @@ TEH_PG_insert_records_by_table (void *cls, case TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS: rh = &irbt_cb_table_reserves_open_deposits; break; - case TALER_EXCHANGEDB_RT_RESERVES_OUT: - rh = &irbt_cb_table_reserves_out; - break; case TALER_EXCHANGEDB_RT_AUDITORS: rh = &irbt_cb_table_auditors; break; diff --git a/src/exchangedb/pg_lookup_records_by_table.c b/src/exchangedb/pg_lookup_records_by_table.c @@ -639,70 +639,6 @@ lrbt_cb_table_reserves_open_deposits (void *cls, /** - * Function called with reserves_out 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_reserves_out (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_RESERVES_OUT - }; - - 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 ( - "h_blind_ev", - &td.details.reserves_out.h_blind_ev), - GNUNET_PQ_result_spec_uint64 ( - "denominations_serial", - &td.details.reserves_out.denominations_serial), - TALER_PQ_result_spec_blinded_denom_sig ( - "denom_sig", - &td.details.reserves_out.denom_sig), - GNUNET_PQ_result_spec_uint64 ( - "reserve_uuid", - &td.details.reserves_out.reserve_uuid), - GNUNET_PQ_result_spec_auto_from_type ( - "reserve_sig", - &td.details.reserves_out.reserve_sig), - GNUNET_PQ_result_spec_timestamp ( - "execution_date", - &td.details.reserves_out.execution_date), - TALER_PQ_RESULT_SPEC_AMOUNT ( - "amount_with_fee", - &td.details.reserves_out.amount_with_fee), - 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 auditors table entries. * * @param cls closure @@ -3248,23 +3184,6 @@ TEH_PG_lookup_records_by_table (void *cls, " ORDER BY reserves_open_deposit_uuid ASC;"); rh = &lrbt_cb_table_reserves_open_deposits; break; - case TALER_EXCHANGEDB_RT_RESERVES_OUT: - XPREPARE ("select_above_serial_by_table_reserves_out", - "SELECT" - " reserve_out_serial_id AS serial" - ",h_blind_ev" - ",denominations_serial" - ",denom_sig" - ",reserve_uuid" - ",reserve_sig" - ",execution_date" - ",amount_with_fee" - " FROM reserves_out" - " JOIN reserves USING (reserve_uuid)" - " WHERE reserve_out_serial_id > $1" - " ORDER BY reserve_out_serial_id ASC;"); - rh = &lrbt_cb_table_reserves_out; - break; case TALER_EXCHANGEDB_RT_AUDITORS: XPREPARE ("select_above_serial_by_table_auditors", "SELECT" diff --git a/src/exchangedb/pg_lookup_serial_by_table.c b/src/exchangedb/pg_lookup_serial_by_table.c @@ -133,14 +133,6 @@ TEH_PG_lookup_serial_by_table (void *cls, " ORDER BY reserve_open_deposit_uuid DESC" " LIMIT 1;"); break; - case TALER_EXCHANGEDB_RT_RESERVES_OUT: - XPREPARE ("select_serial_by_table_reserves_out", - "SELECT" - " reserve_out_serial_id AS serial" - " FROM reserves_out" - " ORDER BY reserve_out_serial_id DESC" - " LIMIT 1;"); - break; case TALER_EXCHANGEDB_RT_AUDITORS: XPREPARE ("select_serial_by_table_auditors", "SELECT" diff --git a/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.c b/src/exchangedb/pg_select_withdraw_amounts_for_kyc_check.c @@ -147,7 +147,7 @@ TEH_PG_select_withdraw_amounts_for_kyc_check ( " FROM wire_targets" " WHERE h_normalized_payto=$1" " )" - " AND rh.table_name='reserves_out'" + " AND rh.table_name='withdraw'" " AND wd.execution_date >= $2" " ORDER BY rh.reserve_history_serial_id DESC"); qs = GNUNET_PQ_eval_prepared_multi_select ( diff --git a/src/exchangedb/procedures.sql.in b/src/exchangedb/procedures.sql.in @@ -60,7 +60,8 @@ SET search_path TO exchange; #include "exchange_do_insert_sanction_list_hit.sql" #include "exchange_statistics_helpers.sql" #include "exchange_trigger_purse_requests_insert.sql" -#include "exchange_trigger_reserves_out_insert.sql" +#include "exchange_trigger_withdraw_delete.sql" +#include "exchange_trigger_withdraw_insert.sql" #include "exchange_trigger_reserves_in_insert.sql" #include "exchange_trigger_purse_decision_insert.sql" diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h @@ -288,7 +288,6 @@ enum TALER_EXCHANGEDB_ReplicatedTable TALER_EXCHANGEDB_RT_RESERVES_CLOSE, TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS, TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS, - TALER_EXCHANGEDB_RT_RESERVES_OUT, TALER_EXCHANGEDB_RT_AUDITORS, TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS, TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS, @@ -515,17 +514,6 @@ struct TALER_EXCHANGEDB_TableData struct { - struct TALER_BlindedCoinHashP h_blind_ev; - uint64_t denominations_serial; - struct TALER_BlindedDenominationSignature denom_sig; - uint64_t reserve_uuid; - struct TALER_ReserveSignatureP reserve_sig; - struct GNUNET_TIME_Timestamp execution_date; - struct TALER_Amount amount_with_fee; - } reserves_out; - - struct - { struct TALER_AuditorPublicKeyP auditor_pub; char *auditor_url; char *auditor_name; @@ -5745,7 +5733,7 @@ struct TALER_EXCHANGEDB_Plugin /** - * Select withdraw operations from reserves_out above @a serial_id + * Select withdraw operations from withdraw table above @a serial_id * in monotonically increasing order. * * @param cls closure diff --git a/src/testing/test_exchange_api_age_restriction.c b/src/testing/test_exchange_api_age_restriction.c @@ -195,7 +195,6 @@ run (void *cls, TALER_TESTING_cmd_end () }; - struct TALER_TESTING_Command refresh_age[] = { /* Fill reserve with EUR:5, 1ct is for fees. */ CMD_TRANSFER_TO_EXCHANGE ( @@ -212,7 +211,7 @@ run (void *cls, */ CMD_EXEC_WIREWATCH ("wirewatch-age-2"), /** - * Withdraw EUR:7 with age restriction for age 13. + * Withdraw EUR:5 with age restriction for age 13. */ TALER_TESTING_cmd_withdraw_amount ( "refresh-withdraw-coin-age-1", diff --git a/src/testing/test_exchange_api_age_restriction.conf b/src/testing/test_exchange_api_age_restriction.conf @@ -191,8 +191,8 @@ EXPOSED = YES IS_AND_COMBINATOR = YES # This happens if the reserve is closed. OPERATION_TYPE = WITHDRAW -# Threshold is 0, so any amount. -THRESHOLD = EUR:10 +# Threshold is EUR:12. +THRESHOLD = EUR:12 # Timeframe doesn't exactly matter with a threshold of EUR:0. TIMEFRAME = 1d # If the rule is triggered, ask the user to provide