LCOV - code coverage report
Current view: top level - exchangedb - do_recoup_refresh.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 21 21
Test Date: 2026-10-10 21:00:14 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2022, 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/do_recoup_refresh.c
      18              :  * @brief Implementation of the do_recoup_refresh function for Postgres
      19              :  * @author Christian Grothoff
      20              :  * @author Özgür Kesim
      21              :  */
      22              : #include "taler/taler_pq_lib.h"
      23              : #include "exchange-database/do_recoup_refresh.h"
      24              : #include "helper.h"
      25              : 
      26              : enum GNUNET_DB_QueryStatus
      27           27 : TALER_EXCHANGEDB_do_recoup_refresh (
      28              :   struct TALER_EXCHANGEDB_PostgresContext *pg,
      29              :   const struct TALER_CoinSpendPublicKeyP *old_coin_pub,
      30              :   uint64_t refresh_id,
      31              :   uint32_t coin_index,
      32              :   const union GNUNET_CRYPTO_BlindingSecretP *coin_bks,
      33              :   const struct TALER_CoinSpendPublicKeyP *coin_pub,
      34              :   uint64_t known_coin_id,
      35              :   const struct TALER_CoinSpendSignatureP *coin_sig,
      36              :   struct GNUNET_TIME_Timestamp *recoup_timestamp,
      37              :   struct TALER_Amount *recoup_amount,
      38              :   bool *recoup_ok,
      39              :   bool *internal_failure)
      40              : {
      41           27 :   struct GNUNET_PQ_QueryParam params[] = {
      42           27 :     GNUNET_PQ_query_param_auto_from_type (old_coin_pub),
      43           27 :     GNUNET_PQ_query_param_uint64 (&refresh_id),
      44           27 :     GNUNET_PQ_query_param_uint32 (&coin_index),
      45           27 :     GNUNET_PQ_query_param_auto_from_type (coin_bks),
      46           27 :     GNUNET_PQ_query_param_auto_from_type (coin_pub),
      47           27 :     GNUNET_PQ_query_param_uint64 (&known_coin_id),
      48           27 :     GNUNET_PQ_query_param_auto_from_type (coin_sig),
      49           27 :     GNUNET_PQ_query_param_timestamp (recoup_timestamp),
      50              :     GNUNET_PQ_query_param_end
      51              :   };
      52              :   bool is_null;
      53              :   bool amount_is_null;
      54           27 :   struct GNUNET_PQ_ResultSpec rs[] = {
      55           27 :     GNUNET_PQ_result_spec_allow_null (
      56              :       GNUNET_PQ_result_spec_timestamp ("recoup_timestamp",
      57              :                                        recoup_timestamp),
      58              :       &is_null),
      59           27 :     GNUNET_PQ_result_spec_allow_null (
      60              :       TALER_PQ_result_spec_amount ("recoup_amount",
      61           27 :                                    pg->currency,
      62              :                                    recoup_amount),
      63              :       &amount_is_null),
      64           27 :     GNUNET_PQ_result_spec_bool ("recoup_ok",
      65              :                                 recoup_ok),
      66           27 :     GNUNET_PQ_result_spec_bool ("internal_failure",
      67              :                                 internal_failure),
      68              :     GNUNET_PQ_result_spec_end
      69              :   };
      70              : 
      71              : 
      72           27 :   PREPARE (pg,
      73              :            "do_recoup_refresh",
      74              :            "SELECT "
      75              :            " out_recoup_timestamp AS recoup_timestamp"
      76              :            ",out_recoup_amount AS recoup_amount"
      77              :            ",out_recoup_ok AS recoup_ok"
      78              :            ",out_internal_failure AS internal_failure"
      79              :            " FROM exchange_do_recoup_to_coin"
      80              :            " ($1,$2,$3,$4,$5,$6,$7,$8);");
      81              : 
      82              :   {
      83              :     enum GNUNET_DB_QueryStatus qs;
      84              : 
      85           27 :     qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
      86              :                                                    "do_recoup_refresh",
      87              :                                                    params,
      88              :                                                    rs);
      89           27 :     if ( (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) ||
      90              :          amount_is_null)
      91            3 :       GNUNET_assert (GNUNET_OK ==
      92              :                      TALER_amount_set_zero (pg->currency,
      93              :                                             recoup_amount));
      94           27 :     return qs;
      95              :   }
      96              : }
        

Generated by: LCOV version 2.0-1