get_aggregation_deferral_by_wtid.c (2673B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2026 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/get_aggregation_deferral_by_wtid.c 18 * @brief Implementation of the get_aggregation_deferral_by_wtid function for Postgres 19 * @author Christian Grothoff 20 */ 21 #include "taler/taler_error_codes.h" 22 #include "taler/taler_pq_lib.h" 23 #include "exchange-database/get_aggregation_deferral_by_wtid.h" 24 #include "helper.h" 25 26 27 enum GNUNET_DB_QueryStatus 28 TALER_EXCHANGEDB_get_aggregation_deferral_by_wtid ( 29 struct TALER_EXCHANGEDB_PostgresContext *pg, 30 const struct TALER_WireTransferIdentifierRawP *wtid, 31 struct TALER_Amount *amount, 32 enum TALER_EXCHANGEDB_DeferralReason *reason, 33 uint64_t *kyc_requirement_row, 34 struct GNUNET_TIME_Timestamp *deferral_time) 35 { 36 struct GNUNET_PQ_QueryParam params[] = { 37 GNUNET_PQ_query_param_auto_from_type (wtid), 38 GNUNET_PQ_query_param_end 39 }; 40 uint32_t reason32; 41 struct GNUNET_PQ_ResultSpec rs[] = { 42 TALER_PQ_RESULT_SPEC_AMOUNT ("amount", 43 amount), 44 GNUNET_PQ_result_spec_uint32 ("deferral_reason", 45 &reason32), 46 GNUNET_PQ_result_spec_uint64 ("legitimization_requirement_serial_id", 47 kyc_requirement_row), 48 GNUNET_PQ_result_spec_timestamp ("deferral_time", 49 deferral_time), 50 GNUNET_PQ_result_spec_end 51 }; 52 enum GNUNET_DB_QueryStatus qs; 53 54 PREPARE (pg, 55 "get_aggregation_deferral_by_wtid", 56 "SELECT" 57 " amount" 58 ",deferral_reason" 59 ",legitimization_requirement_serial_id" 60 ",deferral_time" 61 " FROM aggregation_deferrals" 62 " WHERE wtid_raw=$1" 63 " ORDER BY aggregation_deferral_serial_id DESC" 64 " LIMIT 1;"); 65 qs = GNUNET_PQ_eval_prepared_singleton_select ( 66 pg->conn, 67 "get_aggregation_deferral_by_wtid", 68 params, 69 rs); 70 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) 71 *reason = (enum TALER_EXCHANGEDB_DeferralReason) reason32; 72 return qs; 73 }