exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

lookup_pending_legitimization.c (2470B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2024, 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/lookup_pending_legitimization.c
     18  * @brief Implementation of the lookup_pending_legitimization function for Postgres
     19  * @author Christian Grothoff
     20  */
     21 #include "taler/taler_pq_lib.h"
     22 #include "exchange-database/lookup_pending_legitimization.h"
     23 #include "helper.h"
     24 
     25 
     26 enum GNUNET_DB_QueryStatus
     27 TALER_EXCHANGEDB_lookup_pending_legitimization (
     28   struct TALER_EXCHANGEDB_PostgresContext *pg,
     29   uint64_t legitimization_measure_serial_id,
     30   struct TALER_AccountAccessTokenP *access_token,
     31   struct TALER_NormalizedPaytoHashP *h_payto,
     32   json_t **jmeasures,
     33   bool *is_finished,
     34   bool *is_wallet)
     35 {
     36   struct GNUNET_PQ_QueryParam params[] = {
     37     GNUNET_PQ_query_param_uint64 (&legitimization_measure_serial_id),
     38     GNUNET_PQ_query_param_end
     39   };
     40   struct GNUNET_PQ_ResultSpec rs[] = {
     41     TALER_PQ_result_spec_json (
     42       "jmeasures",
     43       jmeasures),
     44     GNUNET_PQ_result_spec_auto_from_type (
     45       "h_normalized_payto",
     46       h_payto),
     47     GNUNET_PQ_result_spec_auto_from_type (
     48       "access_token",
     49       access_token),
     50     GNUNET_PQ_result_spec_bool (
     51       "is_finished",
     52       is_finished),
     53     GNUNET_PQ_result_spec_bool (
     54       "is_wallet",
     55       is_wallet),
     56     GNUNET_PQ_result_spec_end
     57   };
     58 
     59   PREPARE (pg,
     60            "lookup_pending_legitimization",
     61            "SELECT "
     62            " lm.jmeasures::TEXT"
     63            ",kt.h_normalized_payto"
     64            ",kt.is_wallet"
     65            ",lm.access_token"
     66            ",lm.is_finished"
     67            " FROM legitimization_measures lm"
     68            " JOIN kyc_targets kt"
     69            "   USING (access_token)"
     70            " WHERE lm.legitimization_measure_serial_id=$1;");
     71   return GNUNET_PQ_eval_prepared_singleton_select (
     72     pg->conn,
     73     "lookup_pending_legitimization",
     74     params,
     75     rs);
     76 }