exchange

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

get_denomination_by_serial.c (3342B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 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/get_denomination_by_serial.c
     18  * @brief Implementation of the get_denomination_by_serial function for Postgres
     19  * @author Özgür Kesim
     20  */
     21 #include "taler/taler_error_codes.h"
     22 #include "taler/taler_pq_lib.h"
     23 #include "exchange-database/get_denomination_by_serial.h"
     24 #include "helper.h"
     25 
     26 
     27 enum GNUNET_DB_QueryStatus
     28 TALER_EXCHANGEDB_get_denomination_by_serial (
     29   struct TALER_EXCHANGEDB_PostgresContext *pg,
     30   uint64_t denom_serial,
     31   struct TALER_EXCHANGEDB_DenominationKeyInformation *issue)
     32 {
     33   struct GNUNET_PQ_QueryParam params[] = {
     34     GNUNET_PQ_query_param_uint64 (&denom_serial),
     35     GNUNET_PQ_query_param_end
     36   };
     37   struct GNUNET_PQ_ResultSpec rs[] = {
     38     GNUNET_PQ_result_spec_auto_from_type ("master_sig",
     39                                           &issue->signature),
     40     GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
     41                                           &issue->denom_hash),
     42     GNUNET_PQ_result_spec_timestamp ("valid_from",
     43                                      &issue->start),
     44     GNUNET_PQ_result_spec_timestamp ("expire_withdraw",
     45                                      &issue->expire_withdraw),
     46     GNUNET_PQ_result_spec_timestamp ("expire_deposit",
     47                                      &issue->expire_deposit),
     48     GNUNET_PQ_result_spec_timestamp ("expire_legal",
     49                                      &issue->expire_legal),
     50     TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
     51                                  &issue->value),
     52     TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
     53                                  &issue->fees.withdraw),
     54     TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
     55                                  &issue->fees.deposit),
     56     TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
     57                                  &issue->fees.refresh),
     58     TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
     59                                  &issue->fees.refund),
     60     GNUNET_PQ_result_spec_uint32 ("age_mask",
     61                                   &issue->age_mask.bits),
     62     GNUNET_PQ_result_spec_end
     63   };
     64 
     65   PREPARE (pg,
     66            "denomination_get_by_serial",
     67            "SELECT"
     68            " master_sig"
     69            ",denom_pub_hash"
     70            ",valid_from"
     71            ",expire_withdraw"
     72            ",expire_deposit"
     73            ",expire_legal"
     74            ",coin"  /* value of this denom */
     75            ",fee_withdraw"
     76            ",fee_deposit"
     77            ",fee_refresh"
     78            ",fee_refund"
     79            ",age_mask"
     80            " FROM denominations"
     81            " WHERE denominations_serial=$1;");
     82   return GNUNET_PQ_eval_prepared_singleton_select (
     83     pg->conn,
     84     "denomination_get_by_serial",
     85     params,
     86     rs);
     87 }