exchange

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

select_reserve_close_request_info.c (2721B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2022, 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 select_reserve_close_request_info.c
     18  * @brief Low-level (statement-level) Postgres database access for the exchange
     19  * @author Christian Grothoff
     20  */
     21 #include "taler/taler_pq_lib.h"
     22 #include "exchange-database/select_reserve_close_request_info.h"
     23 #include "helper.h"
     24 
     25 enum GNUNET_DB_QueryStatus
     26 TALER_EXCHANGEDB_select_reserve_close_request_info (
     27   struct TALER_EXCHANGEDB_PostgresContext *pg,
     28   const struct TALER_ReservePublicKeyP *reserve_pub,
     29   uint64_t rowid,
     30   struct TALER_ReserveSignatureP *reserve_sig,
     31   struct GNUNET_TIME_Timestamp *request_timestamp,
     32   struct TALER_Amount *close_balance,
     33   struct TALER_Amount *close_fee,
     34   struct TALER_FullPayto *payto_uri)
     35 {
     36   struct GNUNET_PQ_QueryParam params[] = {
     37     GNUNET_PQ_query_param_auto_from_type (reserve_pub),
     38     GNUNET_PQ_query_param_uint64 (&rowid),
     39     GNUNET_PQ_query_param_end
     40   };
     41   struct GNUNET_PQ_ResultSpec rs[] = {
     42     GNUNET_PQ_result_spec_auto_from_type ("reserve_sig",
     43                                           reserve_sig),
     44     GNUNET_PQ_result_spec_timestamp ("close_timestamp",
     45                                      request_timestamp),
     46     TALER_PQ_result_spec_amount ("close",
     47                                  pg->currency,
     48                                  close_balance),
     49     TALER_PQ_result_spec_amount ("close_fee",
     50                                  pg->currency,
     51                                  close_fee),
     52     GNUNET_PQ_result_spec_string ("payto_uri",
     53                                   &payto_uri->full_payto),
     54     GNUNET_PQ_result_spec_end
     55   };
     56 
     57   PREPARE (pg,
     58            "select_reserve_close_request_info",
     59            "SELECT "
     60            "  cr.reserve_sig"
     61            " ,cr.close_timestamp"
     62            " ,cr.close"
     63            " ,cr.close_fee"
     64            " ,cr.payto_uri"
     65            " FROM close_requests cr"
     66            " WHERE cr.reserve_pub=$1"
     67            "   AND cr.row_id=$2;");
     68   return GNUNET_PQ_eval_prepared_singleton_select (
     69     pg->conn,
     70     "select_reserve_close_request_info",
     71     params,
     72     rs);
     73 }