exchange

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

pg_lookup_reserve_in_inconsistency.c (2726B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2024 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 #include "taler/platform.h"
     17 #include "taler/taler_error_codes.h"
     18 #include "taler/taler_dbevents.h"
     19 #include "taler/taler_pq_lib.h"
     20 #include "pg_helper.h"
     21 #include "pg_lookup_reserve_in_inconsistency.h"
     22 
     23 
     24 enum GNUNET_DB_QueryStatus
     25 TAH_PG_lookup_reserve_in_inconsistency (
     26   void *cls,
     27   uint64_t bank_row_id,
     28   struct TALER_AUDITORDB_ReserveInInconsistency *dc)
     29 {
     30   struct PostgresClosure *pg = cls;
     31   struct GNUNET_PQ_QueryParam params[] = {
     32     GNUNET_PQ_query_param_uint64 (&bank_row_id),
     33     GNUNET_PQ_query_param_end
     34   };
     35   struct GNUNET_PQ_ResultSpec rs[] = {
     36     GNUNET_PQ_result_spec_uint64 ("row_id",
     37                                   &dc->serial_id),
     38     TALER_PQ_RESULT_SPEC_AMOUNT ("amount_exchange_expected",
     39                                  &dc->amount_exchange_expected),
     40     TALER_PQ_RESULT_SPEC_AMOUNT ("amount_wired",
     41                                  &dc->amount_wired),
     42     GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
     43                                           &dc->reserve_pub),
     44     GNUNET_PQ_result_spec_absolute_time ("timestamp",
     45                                          &dc->timestamp),
     46     GNUNET_PQ_result_spec_string ("account",
     47                                   &dc->account.full_payto),
     48     GNUNET_PQ_result_spec_string ("diagnostic",
     49                                   &dc->diagnostic),
     50     GNUNET_PQ_result_spec_bool ("suppressed",
     51                                 &dc->suppressed),
     52     GNUNET_PQ_result_spec_end
     53   };
     54 
     55   PREPARE (pg,
     56            "auditor_lookup_reserve_in_inconsistency",
     57            "SELECT"
     58            " row_id"
     59            ",amount_exchange_expected"
     60            ",amount_wired"
     61            ",reserve_pub"
     62            ",timestamp"
     63            ",account"
     64            ",diagnostic"
     65            ",suppressed"
     66            " FROM auditor_reserve_in_inconsistency"
     67            " WHERE (bank_row_id = $1)"
     68            );
     69   dc->bank_row_id = bank_row_id;
     70   return GNUNET_PQ_eval_prepared_singleton_select (
     71     pg->conn,
     72     "auditor_lookup_reserve_in_inconsistency",
     73     params,
     74     rs);
     75 }