LCOV - code coverage report
Current view: top level - backenddb - get_expected_transfer.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 18 18
Test Date: 2026-09-04 23:42:01 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 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 src/backenddb/get_expected_transfer.c
      18              :  * @brief Implementation of the get_expected_transfer function for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "platform.h"
      22              : #include <taler/taler_pq_lib.h>
      23              : #include "merchant-database/get_expected_transfer.h"
      24              : #include "helper.h"
      25              : 
      26              : 
      27              : enum GNUNET_DB_QueryStatus
      28            1 : TALER_MERCHANTDB_get_expected_transfer (
      29              :   struct TALER_MERCHANTDB_PostgresContext *pg,
      30              :   const char *instance_id,
      31              :   uint64_t expected_incoming_serial,
      32              :   struct GNUNET_TIME_Timestamp *expected_time,
      33              :   struct TALER_Amount *expected_credit_amount,
      34              :   struct TALER_WireTransferIdentifierRawP *wtid,
      35              :   struct TALER_FullPayto *payto_uri,
      36              :   char **exchange_url,
      37              :   struct GNUNET_TIME_Timestamp *execution_time,
      38              :   bool *confirmed,
      39              :   struct TALER_MasterPublicKeyP *master_pub)
      40              : {
      41            1 :   struct GNUNET_PQ_QueryParam params[] = {
      42            1 :     GNUNET_PQ_query_param_uint64 (&expected_incoming_serial),
      43              :     GNUNET_PQ_query_param_end
      44              :   };
      45            1 :   struct GNUNET_PQ_ResultSpec rs[] = {
      46            1 :     GNUNET_PQ_result_spec_timestamp ("expected_time",
      47              :                                      expected_time),
      48            1 :     GNUNET_PQ_result_spec_bool ("confirmed",
      49              :                                 confirmed),
      50            1 :     GNUNET_PQ_result_spec_allow_null (
      51              :       TALER_PQ_result_spec_amount_with_currency ("expected_credit_amount",
      52              :                                                  expected_credit_amount),
      53              :       NULL),
      54            1 :     GNUNET_PQ_result_spec_string ("exchange_url",
      55              :                                   exchange_url),
      56            1 :     GNUNET_PQ_result_spec_auto_from_type ("wtid",
      57              :                                           wtid),
      58            1 :     GNUNET_PQ_result_spec_string ("payto_uri",
      59              :                                   &payto_uri->full_payto),
      60            1 :     GNUNET_PQ_result_spec_allow_null (
      61              :       GNUNET_PQ_result_spec_timestamp ("execution_time",
      62              :                                        execution_time),
      63              :       NULL),
      64            1 :     GNUNET_PQ_result_spec_auto_from_type ("master_pub",
      65              :                                           master_pub),
      66              :     GNUNET_PQ_result_spec_end
      67              :   };
      68              : 
      69            1 :   GNUNET_assert (NULL != pg->current_merchant_id);
      70            1 :   GNUNET_assert (0 == strcmp (instance_id,
      71              :                               pg->current_merchant_id));
      72            1 :   *execution_time = GNUNET_TIME_UNIT_ZERO_TS;
      73            1 :   memset (expected_credit_amount,
      74              :           0,
      75              :           sizeof (*expected_credit_amount));
      76            1 :   TMH_PQ_prepare_anon (pg,
      77              :                        "SELECT"
      78              :                        "  met.expected_time"
      79              :                        " ,met.confirmed"
      80              :                        " ,met.expected_credit_amount"
      81              :                        " ,met.exchange_url"
      82              :                        " ,met.wtid"
      83              :                        " ,ma.payto_uri"
      84              :                        " ,mts.execution_time"
      85              :                        " ,esk.master_pub"
      86              :                        " FROM merchant_expected_transfers met"
      87              :                        " JOIN merchant.merchant_exchange_signing_keys esk"
      88              :                        "   USING (signkey_serial)"
      89              :                        " JOIN merchant_accounts ma"
      90              :                        "   USING (account_serial)"
      91              :                        " LEFT JOIN merchant_transfer_signatures mts"
      92              :                        "   USING (expected_credit_serial)"
      93              :                        " WHERE met.expected_credit_serial=$1");
      94            1 :   return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
      95              :                                                    "",
      96              :                                                    params,
      97              :                                                    rs);
      98              : }
        

Generated by: LCOV version 2.0-1