LCOV - code coverage report
Current view: top level - exchangedb - lookup_kyc_process_by_account.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 14 14
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, 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/lookup_kyc_process_by_account.c
      18              :  * @brief Implementation of the lookup_kyc_process_by_account function for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "taler/taler_pq_lib.h"
      22              : #include "exchange-database/lookup_kyc_process_by_account.h"
      23              : #include "helper.h"
      24              : 
      25              : 
      26              : enum GNUNET_DB_QueryStatus
      27           11 : TALER_EXCHANGEDB_lookup_kyc_process_by_account (
      28              :   struct TALER_EXCHANGEDB_PostgresContext *pg,
      29              :   const char *provider_name,
      30              :   const struct TALER_NormalizedPaytoHashP *h_payto,
      31              :   uint64_t *process_row,
      32              :   struct GNUNET_TIME_Absolute *expiration,
      33              :   char **provider_account_id,
      34              :   char **provider_legitimization_id,
      35              :   bool *is_wallet)
      36              : {
      37           11 :   struct GNUNET_PQ_QueryParam params[] = {
      38           11 :     GNUNET_PQ_query_param_auto_from_type (h_payto),
      39           11 :     GNUNET_PQ_query_param_string (provider_name),
      40              :     GNUNET_PQ_query_param_end
      41              :   };
      42           11 :   struct GNUNET_PQ_ResultSpec rs[] = {
      43           11 :     GNUNET_PQ_result_spec_uint64 (
      44              :       "legitimization_process_serial_id",
      45              :       process_row),
      46           11 :     GNUNET_PQ_result_spec_absolute_time (
      47              :       "expiration_time",
      48              :       expiration),
      49           11 :     GNUNET_PQ_result_spec_allow_null (
      50              :       GNUNET_PQ_result_spec_string (
      51              :         "provider_user_id",
      52              :         provider_account_id),
      53              :       NULL),
      54           11 :     GNUNET_PQ_result_spec_allow_null (
      55              :       GNUNET_PQ_result_spec_string (
      56              :         "provider_legitimization_id",
      57              :         provider_legitimization_id),
      58              :       NULL),
      59           11 :     GNUNET_PQ_result_spec_bool (
      60              :       "is_wallet",
      61              :       is_wallet),
      62              :     GNUNET_PQ_result_spec_end
      63              :   };
      64              : 
      65           11 :   *provider_account_id = NULL;
      66           11 :   *provider_legitimization_id = NULL;
      67           11 :   PREPARE (pg,
      68              :            "lookup_kyc_process_by_account",
      69              :            "SELECT "
      70              :            " lp.legitimization_process_serial_id"
      71              :            ",lp.expiration_time"
      72              :            ",lp.provider_user_id"
      73              :            ",lp.provider_legitimization_id"
      74              :            ",kt.is_wallet"
      75              :            " FROM legitimization_processes lp"
      76              :            " JOIN kyc_targets kt"
      77              :            "   ON (lp.h_payto = kt.h_normalized_payto)"
      78              :            " WHERE h_payto=$1"
      79              :            "   AND provider_name=$2"
      80              :            "   AND NOT finished"
      81              :            /* Note: there *should* only be one unfinished
      82              :               match, so this is just to be safe(r): */
      83              :            " ORDER BY lp.expiration_time DESC"
      84              :            " LIMIT 1;");
      85           11 :   return GNUNET_PQ_eval_prepared_singleton_select (
      86              :     pg->conn,
      87              :     "lookup_kyc_process_by_account",
      88              :     params,
      89              :     rs);
      90              : }
        

Generated by: LCOV version 2.0-1