do_recoup_refresh.c (2925B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022, 2025 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file exchangedb/do_recoup_refresh.c 18 * @brief Implementation of the do_recoup_refresh function for Postgres 19 * @author Christian Grothoff 20 * @author Özgür Kesim 21 */ 22 #include "taler/taler_pq_lib.h" 23 #include "exchange-database/do_recoup_refresh.h" 24 #include "helper.h" 25 26 enum GNUNET_DB_QueryStatus 27 TALER_TALER_EXCHANGEDB_do_recoup_refresh ( 28 struct TALER_EXCHANGEDB_PostgresContext *pg, 29 const struct TALER_CoinSpendPublicKeyP *old_coin_pub, 30 uint64_t refresh_id, 31 const union GNUNET_CRYPTO_BlindingSecretP *coin_bks, 32 const struct TALER_CoinSpendPublicKeyP *coin_pub, 33 uint64_t known_coin_id, 34 const struct TALER_CoinSpendSignatureP *coin_sig, 35 struct GNUNET_TIME_Timestamp *recoup_timestamp, 36 bool *recoup_ok, 37 bool *internal_failure) 38 { 39 struct GNUNET_PQ_QueryParam params[] = { 40 GNUNET_PQ_query_param_auto_from_type (old_coin_pub), 41 GNUNET_PQ_query_param_uint64 (&refresh_id), 42 GNUNET_PQ_query_param_auto_from_type (coin_bks), 43 GNUNET_PQ_query_param_auto_from_type (coin_pub), 44 GNUNET_PQ_query_param_uint64 (&known_coin_id), 45 GNUNET_PQ_query_param_auto_from_type (coin_sig), 46 GNUNET_PQ_query_param_timestamp (recoup_timestamp), 47 GNUNET_PQ_query_param_end 48 }; 49 bool is_null; 50 struct GNUNET_PQ_ResultSpec rs[] = { 51 GNUNET_PQ_result_spec_allow_null ( 52 GNUNET_PQ_result_spec_timestamp ("recoup_timestamp", 53 recoup_timestamp), 54 &is_null), 55 GNUNET_PQ_result_spec_bool ("recoup_ok", 56 recoup_ok), 57 GNUNET_PQ_result_spec_bool ("internal_failure", 58 internal_failure), 59 GNUNET_PQ_result_spec_end 60 }; 61 62 63 PREPARE (pg, 64 "call_recoup_refresh", 65 "SELECT " 66 " out_recoup_timestamp AS recoup_timestamp" 67 ",out_recoup_ok AS recoup_ok" 68 ",out_internal_failure AS internal_failure" 69 " FROM exchange_do_recoup_to_coin" 70 " ($1,$2,$3,$4,$5,$6,$7);"); 71 72 return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, 73 "call_recoup_refresh", 74 params, 75 rs); 76 }