LCOV - code coverage report
Current view: top level - auditordb - get_reserve_info.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 17 17
Test Date: 2026-04-14 15:39:31 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2022 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 get_reserve_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 "auditor-database/get_reserve_info.h"
      23              : #include "pg_helper.h"
      24              : 
      25              : 
      26              : enum GNUNET_DB_QueryStatus
      27            1 : TALER_AUDITORDB_get_reserve_info (
      28              :   struct TALER_AUDITORDB_PostgresContext *pg,
      29              :   const struct TALER_ReservePublicKeyP *reserve_pub,
      30              :   uint64_t *rowid,
      31              :   struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
      32              :   struct GNUNET_TIME_Timestamp *expiration_date,
      33              :   struct TALER_FullPayto *sender_account)
      34              : {
      35            1 :   struct GNUNET_PQ_QueryParam params[] = {
      36            1 :     GNUNET_PQ_query_param_auto_from_type (reserve_pub),
      37              :     GNUNET_PQ_query_param_end
      38              :   };
      39            1 :   struct GNUNET_PQ_ResultSpec rs[] = {
      40            1 :     TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_balance",
      41              :                                  &rfb->reserve_balance),
      42            1 :     TALER_PQ_RESULT_SPEC_AMOUNT ("reserve_loss",
      43              :                                  &rfb->reserve_loss),
      44            1 :     TALER_PQ_RESULT_SPEC_AMOUNT ("withdraw_fee_balance",
      45              :                                  &rfb->withdraw_fee_balance),
      46            1 :     TALER_PQ_RESULT_SPEC_AMOUNT ("close_fee_balance",
      47              :                                  &rfb->close_fee_balance),
      48            1 :     TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee_balance",
      49              :                                  &rfb->purse_fee_balance),
      50            1 :     TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee_balance",
      51              :                                  &rfb->open_fee_balance),
      52            1 :     TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee_balance",
      53              :                                  &rfb->history_fee_balance),
      54            1 :     GNUNET_PQ_result_spec_timestamp ("expiration_date",
      55              :                                      expiration_date),
      56            1 :     GNUNET_PQ_result_spec_uint64 ("auditor_reserves_rowid",
      57              :                                   rowid),
      58            1 :     GNUNET_PQ_result_spec_allow_null (
      59              :       GNUNET_PQ_result_spec_string ("origin_account",
      60              :                                     &sender_account->full_payto),
      61              :       NULL),
      62              :     GNUNET_PQ_result_spec_end
      63              :   };
      64              : 
      65            1 :   sender_account->full_payto = NULL;
      66            1 :   PREPARE (pg,
      67              :            "auditor_get_reserve_info",
      68              :            "SELECT"
      69              :            " reserve_balance"
      70              :            ",reserve_loss"
      71              :            ",withdraw_fee_balance"
      72              :            ",close_fee_balance"
      73              :            ",purse_fee_balance"
      74              :            ",open_fee_balance"
      75              :            ",history_fee_balance"
      76              :            ",expiration_date"
      77              :            ",auditor_reserves_rowid"
      78              :            ",origin_account"
      79              :            " FROM auditor_reserves"
      80              :            " WHERE reserve_pub=$1;");
      81            1 :   return GNUNET_PQ_eval_prepared_singleton_select (
      82              :     pg->conn,
      83              :     "auditor_get_reserve_info",
      84              :     params,
      85              :     rs);
      86              : }
        

Generated by: LCOV version 2.0-1