commit 638c6f5599d546abc35a66befe4685faddd74b53
parent f94c1ce254e3b8f2af82b4864c3580ec4c7aebb4
Author: Özgür Kesim <oec@codeblau.de>
Date: Wed, 7 May 2025 14:26:19 +0200
[exchangedb] Finish removal of batch_withdraw
Diffstat:
15 files changed, 0 insertions(+), 801 deletions(-)
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
@@ -171,8 +171,6 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \
pg_delete_shard_locks.h pg_delete_shard_locks.c \
pg_disable_rules.h pg_disable_rules.c \
pg_do_withdraw.h pg_do_withdraw.c \
- pg_do_batch_withdraw.h pg_do_batch_withdraw.c \
- pg_do_batch_withdraw_insert.h pg_do_batch_withdraw_insert.c \
pg_do_check_deposit_idempotent.h pg_do_check_deposit_idempotent.c \
pg_do_deposit.h pg_do_deposit.c \
pg_do_melt.h pg_do_melt.c \
@@ -195,7 +193,6 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \
pg_expire_purse.h pg_expire_purse.c \
pg_find_aggregation_transient.h pg_find_aggregation_transient.c \
pg_gc.h pg_gc.c \
- pg_get_batch_withdraw_info.h pg_get_batch_withdraw_info.c \
pg_get_coin_denomination.h pg_get_coin_denomination.c \
pg_get_coin_transactions.c pg_get_coin_transactions.h \
pg_get_denomination_info.h pg_get_denomination_info.c \
diff --git a/src/exchangedb/exchange_do_batch_withdraw.sql b/src/exchangedb/exchange_do_batch_withdraw.sql
@@ -1,126 +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/>
---
--- @author Christian Grothoff
--- @author Özgür Kesim
-
-CREATE OR REPLACE FUNCTION exchange_do_batch_withdraw(
- IN amount taler_amount,
- IN rpub BYTEA,
- IN now INT8,
- IN min_reserve_gc INT8,
- IN do_age_check BOOLEAN,
- OUT reserve_found BOOLEAN,
- OUT balance_ok BOOLEAN,
- OUT reserve_balance taler_amount,
- OUT age_ok BOOLEAN,
- OUT allowed_maximum_age INT2, -- in years
- OUT ruuid INT8)
-LANGUAGE plpgsql
-AS $$
-DECLARE
- reserve RECORD;
- balance taler_amount;
- not_before date;
-BEGIN
--- Shards: reserves by reserve_pub (SELECT)
--- reserves_out (INSERT, with CONFLICT detection) by wih
--- reserves by reserve_pub (UPDATE)
--- reserves_in by reserve_pub (SELECT)
--- wire_targets by wire_target_h_payto
-
-SELECT current_balance
- ,reserve_uuid
- ,birthday
- ,gc_date
- INTO reserve
- FROM exchange.reserves
- WHERE reserves.reserve_pub=rpub;
-
-IF NOT FOUND
-THEN
- -- reserve unknown
- reserve_found=FALSE;
- balance_ok=FALSE;
- reserve_balance.frac = 0;
- reserve_balance.val = 0;
- age_ok=FALSE;
- allowed_maximum_age=0;
- ruuid=2;
- RETURN;
-END IF;
-reserve_found=TRUE;
-reserve_balance = reserve.current_balance;
-ruuid = reserve.reserve_uuid;
-
--- Check if age requirements are present
-IF ((NOT do_age_check) OR (reserve.birthday = 0))
-THEN
- age_ok = TRUE;
- allowed_maximum_age = -1;
-ELSE
- -- Age requirements are formally not met: The exchange is setup to support
- -- age restrictions (do_age_check == TRUE) and the reserve has a
- -- birthday set (reserve_birthday != 0), but the client called the
- -- batch-withdraw endpoint instead of the age-withdraw endpoint, which it
- -- should have.
- not_before=date '1970-01-01' + reserve.birthday;
- allowed_maximum_age = extract(year from age(current_date, not_before));
-
- balance_ok=FALSE;
- age_ok = FALSE;
- RETURN;
-END IF;
-
-
--- Check reserve balance is sufficient.
-IF (reserve_balance.val > amount.val)
-THEN
- IF (reserve_balance.frac >= amount.frac)
- THEN
- balance.val=reserve_balance.val - amount.val;
- balance.frac=reserve_balance.frac - amount.frac;
- ELSE
- balance.val=reserve_balance.val - amount.val - 1;
- balance.frac=reserve_balance.frac + 100000000 - amount.frac;
- END IF;
-ELSE
- IF (reserve_balance.val = amount.val) AND (reserve_balance.frac >= amount.frac)
- THEN
- balance.val=0;
- balance.frac=reserve_balance.frac - amount.frac;
- ELSE
- balance_ok=FALSE;
- RETURN;
- END IF;
-END IF;
-
--- Calculate new expiration dates.
-min_reserve_gc=GREATEST(min_reserve_gc,reserve.gc_date);
-
--- Update reserve balance.
-UPDATE reserves SET
- gc_date=min_reserve_gc
- ,current_balance=balance
-WHERE
- reserves.reserve_pub=rpub;
-
-balance_ok=TRUE;
-
-END $$;
-
-COMMENT ON FUNCTION exchange_do_batch_withdraw(taler_amount, BYTEA, INT8, INT8, BOOLEAN)
- IS 'Checks whether the reserve has sufficient balance for a withdraw operation (or the request is repeated and was previously approved) and that age requirements are formally met. If so updates the database with the result. Excludes storing the planchets.';
-
diff --git a/src/exchangedb/exchange_do_batch_withdraw_insert.sql b/src/exchangedb/exchange_do_batch_withdraw_insert.sql
@@ -1,120 +0,0 @@
---
--- This file is part of TALER
--- Copyright (C) 2014--2022 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 exchange_do_batch_withdraw_insert(
- IN cs_nonce BYTEA,
- IN amount taler_amount,
- IN h_denom_pub BYTEA, -- FIXME: denom_serials should really be a parameter to this FUNCTION.
- IN ruuid INT8,
- IN reserve_sig BYTEA,
- IN h_coin_envelope BYTEA,
- IN denom_sig BYTEA,
- IN now INT8,
- OUT out_denom_unknown BOOLEAN,
- OUT out_nonce_reuse BOOLEAN,
- OUT out_conflict BOOLEAN)
-LANGUAGE plpgsql
-AS $$
-DECLARE
- denom_serial INT8;
-BEGIN
--- Shards: reserves by reserve_pub (SELECT)
--- reserves_out (INSERT, with CONFLICT detection) by wih
--- reserves by reserve_pub (UPDATE)
--- reserves_in by reserve_pub (SELECT)
--- wire_targets by wire_target_h_payto
-
-out_denom_unknown=TRUE;
-out_conflict=TRUE;
-out_nonce_reuse=TRUE;
-
--- FIXME: denom_serials should really be a parameter to this FUNCTION.
-
-SELECT denominations_serial
- INTO denom_serial
- FROM exchange.denominations
- WHERE denom_pub_hash=h_denom_pub;
-
-IF NOT FOUND
-THEN
- -- denomination unknown, should be impossible!
- out_denom_unknown=TRUE;
- ASSERT false, 'denomination unknown';
- RETURN;
-END IF;
-out_denom_unknown=FALSE;
-
-INSERT INTO exchange.reserves_out
- (h_blind_ev
- ,denominations_serial
- ,denom_sig
- ,reserve_uuid
- ,reserve_sig
- ,execution_date
- ,amount_with_fee)
-VALUES
- (h_coin_envelope
- ,denom_serial
- ,denom_sig
- ,ruuid
- ,reserve_sig
- ,now
- ,amount)
-ON CONFLICT DO NOTHING;
-
-IF NOT FOUND
-THEN
- out_conflict=TRUE;
- RETURN;
-END IF;
-out_conflict=FALSE;
-
--- Special actions needed for a CS withdraw?
-out_nonce_reuse=FALSE;
-IF cs_nonce IS NOT NULL
-THEN
- -- Cache CS signature to prevent replays in the future
- -- (and check if cached signature exists at the same time).
- INSERT INTO exchange.cs_nonce_locks
- (nonce
- ,max_denomination_serial
- ,op_hash)
- VALUES
- (cs_nonce
- ,denom_serial
- ,h_coin_envelope)
- ON CONFLICT DO NOTHING;
-
- IF NOT FOUND
- THEN
- -- See if the existing entry is identical.
- SELECT 1
- FROM exchange.cs_nonce_locks
- WHERE nonce=cs_nonce
- AND op_hash=h_coin_envelope;
- IF NOT FOUND
- THEN
- out_nonce_reuse=TRUE;
- ASSERT false, 'nonce reuse attempted by client';
- RETURN;
- END IF;
- END IF;
-END IF;
-
-END $$;
-
-COMMENT ON FUNCTION exchange_do_batch_withdraw_insert(BYTEA, taler_amount, BYTEA, INT8, BYTEA, BYTEA, BYTEA, INT8)
- IS 'Stores information about a planchet for a batch withdraw operation. Checks if the planchet already exists, and in that case indicates a conflict';
diff --git a/src/exchangedb/pg_do_batch_withdraw.c b/src/exchangedb/pg_do_batch_withdraw.c
@@ -1,89 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 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_do_batch_withdraw.c
- * @brief Implementation of the do_batch_withdraw function for Postgres
- * @author Christian Grothoff
- * @author Özgür Kesim
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_do_batch_withdraw.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TEH_PG_do_batch_withdraw (
- void *cls,
- struct GNUNET_TIME_Timestamp now,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_Amount *amount,
- bool do_age_check,
- bool *found,
- bool *balance_ok,
- struct TALER_Amount *reserve_balance,
- bool *age_ok,
- uint16_t *allowed_maximum_age,
- uint64_t *ruuid)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Timestamp gc;
- struct GNUNET_PQ_QueryParam params[] = {
- TALER_PQ_query_param_amount (pg->conn,
- amount),
- GNUNET_PQ_query_param_auto_from_type (reserve_pub),
- GNUNET_PQ_query_param_timestamp (&now),
- GNUNET_PQ_query_param_timestamp (&gc),
- GNUNET_PQ_query_param_bool (do_age_check),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_bool ("reserve_found",
- found),
- GNUNET_PQ_result_spec_bool ("balance_ok",
- balance_ok),
- TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance",
- reserve_balance),
- GNUNET_PQ_result_spec_bool ("age_ok",
- age_ok),
- GNUNET_PQ_result_spec_uint16 ("allowed_maximum_age",
- allowed_maximum_age),
- GNUNET_PQ_result_spec_uint64 ("ruuid",
- ruuid),
- GNUNET_PQ_result_spec_end
- };
-
- gc = GNUNET_TIME_absolute_to_timestamp (
- GNUNET_TIME_absolute_add (now.abs_time,
- pg->legal_reserve_expiration_time));
- PREPARE (pg,
- "call_batch_withdraw",
- "SELECT "
- " reserve_found"
- ",balance_ok"
- ",reserve_balance"
- ",age_ok"
- ",allowed_maximum_age"
- ",ruuid"
- " FROM exchange_do_batch_withdraw"
- " ($1,$2,$3,$4,$5);");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "call_batch_withdraw",
- params,
- rs);
-}
diff --git a/src/exchangedb/pg_do_batch_withdraw.h b/src/exchangedb/pg_do_batch_withdraw.h
@@ -1,59 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 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_do_batch_withdraw.h
- * @brief implementation of the do_batch_withdraw function for Postgres
- * @author Christian Grothoff
- */
-#ifndef PG_DO_BATCH_WITHDRAW_H
-#define PG_DO_BATCH_WITHDRAW_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_exchangedb_plugin.h"
-/**
- * Perform reserve update as part of a batch withdraw operation, checking
- * for sufficient balance. Persisting the withdrawal details is done
- * separately!
- *
- * @param cls the `struct PostgresClosure` with the plugin-specific state
- * @param now current time (rounded)
- * @param reserve_pub public key of the reserve to debit
- * @param amount total amount to withdraw
- * @param age_check_required if true, fail if age requirements are set on the reserve
- * @param[out] found set to true if the reserve was found
- * @param[out] balance_ok set to true if the balance was sufficient
- * @param[out] reserve_balance set to the original reserve balance (at the start of this transaction)
- * @param[out] age_ok set to true if no age requirements are present on the reserve
- * @param[out] allowed_maximum_age if @e age_ok is false, set to the maximum allowed age when withdrawing from this reserve (client needs to call age-withdraw)
- * @param[out] ruuid set to the reserve's UUID (reserves table row)
- * @return query execution status
- */
-enum GNUNET_DB_QueryStatus
-TEH_PG_do_batch_withdraw (
- void *cls,
- struct GNUNET_TIME_Timestamp now,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_Amount *amount,
- bool age_check_required,
- bool *found,
- bool *balance_ok,
- struct TALER_Amount *reserve_balance,
- bool *age_ok,
- uint16_t *allowed_maximum_age,
- uint64_t *ruuid);
-
-#endif
diff --git a/src/exchangedb/pg_do_batch_withdraw_insert.c b/src/exchangedb/pg_do_batch_withdraw_insert.c
@@ -1,77 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 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_do_batch_withdraw_insert.c
- * @brief Implementation of the do_batch_withdraw_insert 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_do_batch_withdraw_insert.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TEH_PG_do_batch_withdraw_insert (
- void *cls,
- const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
- const struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable,
- struct GNUNET_TIME_Timestamp now,
- uint64_t ruuid,
- bool *denom_unknown,
- bool *conflict,
- bool *nonce_reuse)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- NULL == nonce
- ? GNUNET_PQ_query_param_null ()
- : GNUNET_PQ_query_param_auto_from_type (nonce),
- TALER_PQ_query_param_amount (pg->conn,
- &collectable->amount_with_fee),
- GNUNET_PQ_query_param_auto_from_type (&collectable->denom_pub_hash),
- GNUNET_PQ_query_param_uint64 (&ruuid),
- GNUNET_PQ_query_param_auto_from_type (&collectable->reserve_sig),
- GNUNET_PQ_query_param_auto_from_type (&collectable->h_coin_envelope),
- TALER_PQ_query_param_blinded_denom_sig (&collectable->sig),
- GNUNET_PQ_query_param_timestamp (&now),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_bool ("denom_unknown",
- denom_unknown),
- GNUNET_PQ_result_spec_bool ("conflict",
- conflict),
- GNUNET_PQ_result_spec_bool ("nonce_reuse",
- nonce_reuse),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "call_batch_withdraw_insert",
- "SELECT "
- " out_denom_unknown AS denom_unknown"
- ",out_conflict AS conflict"
- ",out_nonce_reuse AS nonce_reuse"
- " FROM exchange_do_batch_withdraw_insert"
- " ($1,$2,$3,$4,$5,$6,$7,$8);");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "call_batch_withdraw_insert",
- params,
- rs);
-}
diff --git a/src/exchangedb/pg_do_batch_withdraw_insert.h b/src/exchangedb/pg_do_batch_withdraw_insert.h
@@ -1,52 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 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_do_batch_withdraw_insert.h
- * @brief implementation of the do_batch_withdraw_insert function for Postgres
- * @author Christian Grothoff
- */
-#ifndef PG_DO_BATCH_WITHDRAW_INSERT_H
-#define PG_DO_BATCH_WITHDRAW_INSERT_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_exchangedb_plugin.h"
-/**
- * Perform insert as part of a batch withdraw operation, and persisting the
- * withdrawal details.
- *
- * @param cls the `struct PostgresClosure` with the plugin-specific state
- * @param nonce client-contributed input for CS denominations that must be checked for idempotency, or NULL for non-CS withdrawals
- * @param collectable corresponding collectable coin (blind signature)
- * @param now current time (rounded)
- * @param ruuid reserve UUID
- * @param[out] denom_unknown set if the denomination is unknown in the DB
- * @param[out] conflict if the envelope was already in the DB
- * @param[out] nonce_reuse if @a nonce was non-NULL and reused
- * @return query execution status
- */
-enum GNUNET_DB_QueryStatus
-TEH_PG_do_batch_withdraw_insert (
- void *cls,
- const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
- const struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable,
- struct GNUNET_TIME_Timestamp now,
- uint64_t ruuid,
- bool *denom_unknown,
- bool *conflict,
- bool *nonce_reuse);
-
-#endif
diff --git a/src/exchangedb/pg_get_batch_withdraw_info.c b/src/exchangedb/pg_get_batch_withdraw_info.c
@@ -1,79 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 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_get_batch_withdraw_info.c
- * @brief Implementation of the get_batch_withdraw_info 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_get_batch_withdraw_info.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_DB_QueryStatus
-TEH_PG_get_batch_withdraw_info (
- void *cls,
- const struct TALER_BlindedCoinHashP *bch,
- struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (bch),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
- &collectable->denom_pub_hash),
- TALER_PQ_result_spec_blinded_denom_sig ("denom_sig",
- &collectable->sig),
- GNUNET_PQ_result_spec_auto_from_type ("reserve_sig",
- &collectable->reserve_sig),
- GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
- &collectable->reserve_pub),
- GNUNET_PQ_result_spec_auto_from_type ("h_blind_ev",
- &collectable->h_coin_envelope),
- TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
- &collectable->amount_with_fee),
- TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
- &collectable->withdraw_fee),
- GNUNET_PQ_result_spec_end
- };
-
- PREPARE (pg,
- "get_batch_withdraw_info",
- "SELECT"
- " denom.denom_pub_hash"
- ",denom_sig"
- ",reserve_sig"
- ",reserves.reserve_pub"
- ",execution_date"
- ",h_blind_ev"
- ",amount_with_fee"
- ",denom.fee_withdraw"
- " FROM reserves_out"
- " JOIN reserves"
- " USING (reserve_uuid)"
- " JOIN denominations denom"
- " USING (denominations_serial)"
- " WHERE h_blind_ev=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "get_batch_withdraw_info",
- params,
- rs);
-}
diff --git a/src/exchangedb/pg_get_batch_withdraw_info.h b/src/exchangedb/pg_get_batch_withdraw_info.h
@@ -1,43 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2022 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_get_batch_withdraw_info.h
- * @brief implementation of the get_batch_withdraw_info function for Postgres
- * @author Christian Grothoff
- */
-#ifndef PG_GET_BATCH_WITHDRAW_INFO_H
-#define PG_GET_BATCH_WITHDRAW_INFO_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_exchangedb_plugin.h"
-/**
- * Locate the response for a /batch-withdraw request under the
- * key of the hash of the blinded message.
- *
- * @param cls the `struct PostgresClosure` with the plugin-specific state
- * @param bch hash that uniquely identifies the withdraw operation
- * @param collectable corresponding collectable coin (blind signature)
- * if a coin is found
- * @return statement execution status
- */
-enum GNUNET_DB_QueryStatus
-TEH_PG_get_batch_withdraw_info (
- void *cls,
- const struct TALER_BlindedCoinHashP *bch,
- struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable);
-
-#endif
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -98,7 +98,6 @@
#include "pg_get_wire_fee.h"
#include "pg_get_wire_fees.h"
#include "pg_get_wire_hash_for_contract.h"
-#include "pg_get_batch_withdraw_info.h"
#include "pg_have_deposit2.h"
#include "pg_helper.h"
#include "pg_inject_auditor_triggers.h"
diff --git a/src/exchangedb/procedures.sql.in b/src/exchangedb/procedures.sql.in
@@ -23,8 +23,6 @@ SET search_path TO exchange;
#include "exchange_do_comment_partitioned_column.sql"
#include "exchange_do_create_tables.sql"
#include "exchange_do_amount_specific.sql"
-#include "exchange_do_batch_withdraw.sql"
-#include "exchange_do_batch_withdraw_insert.sql"
#include "exchange_do_withdraw.sql"
#include "exchange_do_refresh.sql"
#include "exchange_do_deposit.sql"
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
@@ -1207,7 +1207,6 @@ run (void *cls)
struct TALER_EXCHANGEDB_ReserveHistory *rh = NULL;
struct TALER_EXCHANGEDB_ReserveHistory *rh_head;
struct TALER_EXCHANGEDB_BankTransfer *bt;
- struct TALER_EXCHANGEDB_CollectableBlindcoin *batch_withdraw;
struct TALER_EXCHANGEDB_Withdraw withdraw;
struct TALER_HashBlindedPlanchetsP h_planchets;
struct TALER_EXCHANGEDB_CoinDepositInformation deposit;
@@ -2036,15 +2035,6 @@ run (void *cls)
bt->amount.currency));
FAILIF (NULL == bt->sender_account_details.full_payto);
break;
- case TALER_EXCHANGEDB_RO_BATCH_WITHDRAW_COIN:
- batch_withdraw = rh_head->details.batch_withdraw;
- FAILIF (0 !=
- GNUNET_memcmp (&batch_withdraw->reserve_pub,
- &reserve_pub));
- FAILIF (0 !=
- GNUNET_memcmp (&batch_withdraw->h_coin_envelope,
- &cbc.h_coin_envelope));
- break;
case TALER_EXCHANGEDB_RO_WITHDRAW_COINS:
{
struct TALER_EXCHANGEDB_Withdraw *rh_withdraw =
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
@@ -2036,24 +2036,6 @@ struct TALER_EXCHANGE_ReserveHistoryEntry
} in_details;
/**
- * Information about batch withdraw operation.
- * @e type is #TALER_EXCHANGE_RTT_BATCH_WITHDRAWAL.
- */
- struct
- {
- /**
- * Signature authorizing the withdrawal for outgoing transaction.
- */
- json_t *out_authorization_sig;
-
- /**
- * Fee that was charged for the withdrawal.
- */
- struct TALER_Amount fee;
- } batch_withdraw;
-
-
- /**
* Information about withdraw operation with age-restriction.
* @e type is #TALER_EXCHANGE_RTT_WITHDRAWAL.
*/
diff --git a/src/lib/exchange_api_reserves_history.c b/src/lib/exchange_api_reserves_history.c
@@ -398,115 +398,6 @@ parse_withdraw (struct TALER_EXCHANGE_ReserveHistoryEntry *rh,
/**
- * Parse "batch withdraw" reserve history entry.
- *
- * @param[in,out] rh entry to parse
- * @param uc our context
- * @param transaction the transaction to parse
- * @return #GNUNET_OK on success
- */
-static enum GNUNET_GenericReturnValue
-parse_batch_withdraw (struct TALER_EXCHANGE_ReserveHistoryEntry *rh,
- struct HistoryParseContext *uc,
- const json_t *transaction)
-{
- struct TALER_ReserveSignatureP sig;
- struct TALER_DenominationHashP h_denom_pub;
- struct TALER_BlindedCoinHashP bch;
- struct TALER_Amount withdraw_fee;
- struct GNUNET_JSON_Specification withdraw_spec[] = {
- GNUNET_JSON_spec_fixed_auto ("reserve_sig",
- &sig),
- TALER_JSON_spec_amount_any ("withdraw_fee",
- &withdraw_fee),
- GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
- &h_denom_pub),
- GNUNET_JSON_spec_fixed_auto ("h_coin_envelope",
- &bch),
- GNUNET_JSON_spec_end ()
- };
-
- rh->type = TALER_EXCHANGE_RTT_BATCH_WITHDRAWAL;
- if (GNUNET_OK !=
- GNUNET_JSON_parse (transaction,
- withdraw_spec,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
-
- /* Check that the signature is a valid withdraw request */
- if (GNUNET_OK !=
- TALER_wallet_withdraw_verify_pre26 (&h_denom_pub,
- &rh->amount,
- &bch,
- uc->reserve_pub,
- &sig))
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (withdraw_spec);
- return GNUNET_SYSERR;
- }
- /* check that withdraw fee matches expectations! */
- {
- const struct TALER_EXCHANGE_Keys *key_state;
- const struct TALER_EXCHANGE_DenomPublicKey *dki;
-
- key_state = uc->keys;
- dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state,
- &h_denom_pub);
- if ( (GNUNET_YES !=
- TALER_amount_cmp_currency (&withdraw_fee,
- &dki->fees.withdraw)) ||
- (0 !=
- TALER_amount_cmp (&withdraw_fee,
- &dki->fees.withdraw)) )
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (withdraw_spec);
- return GNUNET_SYSERR;
- }
- rh->details.batch_withdraw.fee = withdraw_fee;
- }
- rh->details.batch_withdraw.out_authorization_sig
- = json_object_get (transaction,
- "signature");
- /* Check check that the same withdraw transaction
- isn't listed twice by the exchange. We use the
- "uuid" array to remember the hashes of all
- signatures, and compare the hashes to find
- duplicates. */
- GNUNET_CRYPTO_hash (&sig,
- sizeof (sig),
- &uc->uuids[uc->uuid_off]);
- for (unsigned int i = 0; i<uc->uuid_off; i++)
- {
- if (0 == GNUNET_memcmp (&uc->uuids[uc->uuid_off],
- &uc->uuids[i]))
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (withdraw_spec);
- return GNUNET_SYSERR;
- }
- }
- uc->uuid_off++;
-
- if (0 >
- TALER_amount_add (uc->total_out,
- uc->total_out,
- &rh->amount))
- {
- /* overflow in history already!? inconceivable! Bad exchange! */
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (withdraw_spec);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-/**
* Parse "recoup" reserve history entry.
*
* @param[in,out] rh entry to parse
@@ -931,7 +822,6 @@ parse_reserve_history (
ParseHelper helper;
} map[] = {
{ "CREDIT", &parse_credit },
- { "BATCH_WITHDRAW", &parse_batch_withdraw },
{ "WITHDRAW", &parse_withdraw },
{ "RECOUP", &parse_recoup },
{ "MERGE", &parse_merge },
diff --git a/src/testing/testing_api_cmd_reserve_history.c b/src/testing/testing_api_cmd_reserve_history.c
@@ -134,18 +134,6 @@ history_entry_cmp (
h2->details.in_details.timestamp)) )
return 0;
return 1;
- case TALER_EXCHANGE_RTT_BATCH_WITHDRAWAL:
- if ( (0 ==
- TALER_amount_cmp (&h1->amount,
- &h2->amount)) &&
- (0 ==
- TALER_amount_cmp (&h1->details.batch_withdraw.fee,
- &h2->details.batch_withdraw.fee)) )
- /* testing_api_cmd_withdraw doesn't set the out_authorization_sig,
- so we cannot test for it here. but if the amount matches,
- that should be good enough. */
- return 0;
- return 1;
case TALER_EXCHANGE_RTT_WITHDRAWAL:
if ( (0 ==
TALER_amount_cmp (&h1->amount,