pg_do_recoup_refresh.c (3001B)
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/pg_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/platform.h" 23 #include "taler/taler_error_codes.h" 24 #include "taler/taler_dbevents.h" 25 #include "taler/taler_pq_lib.h" 26 #include "pg_do_recoup_refresh.h" 27 #include "pg_helper.h" 28 29 enum GNUNET_DB_QueryStatus 30 TEH_PG_do_recoup_refresh ( 31 void *cls, 32 const struct TALER_CoinSpendPublicKeyP *old_coin_pub, 33 uint64_t refresh_id, 34 const union GNUNET_CRYPTO_BlindingSecretP *coin_bks, 35 const struct TALER_CoinSpendPublicKeyP *coin_pub, 36 uint64_t known_coin_id, 37 const struct TALER_CoinSpendSignatureP *coin_sig, 38 struct GNUNET_TIME_Timestamp *recoup_timestamp, 39 bool *recoup_ok, 40 bool *internal_failure) 41 { 42 struct PostgresClosure *pg = cls; 43 struct GNUNET_PQ_QueryParam params[] = { 44 GNUNET_PQ_query_param_auto_from_type (old_coin_pub), 45 GNUNET_PQ_query_param_uint64 (&refresh_id), 46 GNUNET_PQ_query_param_auto_from_type (coin_bks), 47 GNUNET_PQ_query_param_auto_from_type (coin_pub), 48 GNUNET_PQ_query_param_uint64 (&known_coin_id), 49 GNUNET_PQ_query_param_auto_from_type (coin_sig), 50 GNUNET_PQ_query_param_timestamp (recoup_timestamp), 51 GNUNET_PQ_query_param_end 52 }; 53 bool is_null; 54 struct GNUNET_PQ_ResultSpec rs[] = { 55 GNUNET_PQ_result_spec_allow_null ( 56 GNUNET_PQ_result_spec_timestamp ("recoup_timestamp", 57 recoup_timestamp), 58 &is_null), 59 GNUNET_PQ_result_spec_bool ("recoup_ok", 60 recoup_ok), 61 GNUNET_PQ_result_spec_bool ("internal_failure", 62 internal_failure), 63 GNUNET_PQ_result_spec_end 64 }; 65 66 67 PREPARE (pg, 68 "call_recoup_refresh", 69 "SELECT " 70 " out_recoup_timestamp AS recoup_timestamp" 71 ",out_recoup_ok AS recoup_ok" 72 ",out_internal_failure AS internal_failure" 73 " FROM exchange_do_recoup_to_coin" 74 " ($1,$2,$3,$4,$5,$6,$7);"); 75 76 return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, 77 "call_recoup_refresh", 78 params, 79 rs); 80 }