get_current_kyc_attributes.c (2124B)
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_current_kyc_attributes.c 18 * @brief Implementation of the get_current_kyc_attributes function for Postgres 19 */ 20 #include "taler/taler_pq_lib.h" 21 #include "exchange-database/get_current_kyc_attributes.h" 22 #include "helper.h" 23 24 25 enum GNUNET_DB_QueryStatus 26 TALER_EXCHANGEDB_get_current_kyc_attributes ( 27 struct TALER_EXCHANGEDB_PostgresContext *pg, 28 const struct TALER_NormalizedPaytoHashP *h_payto, 29 size_t *enc_attributes_size, 30 void **enc_attributes) 31 { 32 struct GNUNET_PQ_QueryParam params[] = { 33 GNUNET_PQ_query_param_auto_from_type (h_payto), 34 GNUNET_PQ_query_param_end 35 }; 36 struct GNUNET_PQ_ResultSpec rs[] = { 37 GNUNET_PQ_result_spec_variable_size ( 38 "encrypted_attributes", 39 enc_attributes, 40 enc_attributes_size), 41 GNUNET_PQ_result_spec_end 42 }; 43 44 PREPARE (pg, 45 "get_current_kyc_attributes", 46 "SELECT" 47 " ka.encrypted_attributes" 48 " FROM kyc_attributes ka" 49 " WHERE ka.h_payto=$1" 50 " AND ka.form_index=0" 51 " AND ka.legitimization_serial=" 52 " (SELECT kn.legitimization_serial" 53 " FROM kyc_attributes kn" 54 " WHERE kn.h_payto=$1" 55 " ORDER BY kn.kyc_attributes_serial_id DESC" 56 " LIMIT 1);"); 57 return GNUNET_PQ_eval_prepared_singleton_select ( 58 pg->conn, 59 "get_current_kyc_attributes", 60 params, 61 rs); 62 }