LCOV - code coverage report
Current view: top level - exchangedb - lookup_kyc_requirement_by_row.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 92.3 % 26 24
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, 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              : /**
      17              :  * @file exchangedb/lookup_kyc_requirement_by_row.c
      18              :  * @brief Implementation of the lookup_kyc_requirement_by_row function for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "taler/taler_pq_lib.h"
      22              : #include "exchange-database/lookup_kyc_requirement_by_row.h"
      23              : #include "helper.h"
      24              : 
      25              : 
      26              : enum GNUNET_DB_QueryStatus
      27           14 : TALER_EXCHANGEDB_lookup_kyc_requirement_by_row (
      28              :   struct TALER_EXCHANGEDB_PostgresContext *pg,
      29              :   const struct TALER_NormalizedPaytoHashP *h_payto,
      30              :   const union TALER_AccountPublicKeyP *account_pub,
      31              :   enum GNUNET_GenericReturnValue *is_wallet,
      32              :   struct TALER_AccountAccessTokenP *access_token,
      33              :   uint64_t *rule_gen,
      34              :   json_t **jrules,
      35              :   bool *aml_review,
      36              :   bool *kyc_required)
      37              : {
      38           14 :   struct GNUNET_PQ_QueryParam params[] = {
      39           14 :     GNUNET_PQ_query_param_auto_from_type (h_payto),
      40           14 :     GNUNET_PQ_query_param_auto_from_type (account_pub),
      41              :     GNUNET_PQ_query_param_end
      42              :   };
      43              :   bool bis_wallet;
      44              :   bool bis_wallet_unknown;
      45              :   bool not_found;
      46           14 :   struct GNUNET_PQ_ResultSpec rs[] = {
      47           14 :     GNUNET_PQ_result_spec_allow_null (
      48              :       GNUNET_PQ_result_spec_auto_from_type ("access_token",
      49              :                                             access_token),
      50              :       NULL),
      51           14 :     GNUNET_PQ_result_spec_allow_null (
      52              :       /* can be NULL due to LEFT JOIN */
      53              :       TALER_PQ_result_spec_json ("jrules",
      54              :                                  jrules),
      55              :       NULL),
      56           14 :     GNUNET_PQ_result_spec_allow_null (
      57              :       /* can be NULL due to LEFT JOIN */
      58              :       GNUNET_PQ_result_spec_bool ("is_wallet",
      59              :                                   &bis_wallet),
      60              :       &bis_wallet_unknown),
      61           14 :     GNUNET_PQ_result_spec_allow_null (
      62              :       /* can be NULL due to LEFT JOIN */
      63              :       GNUNET_PQ_result_spec_bool ("aml_review",
      64              :                                   aml_review),
      65              :       NULL),
      66           14 :     GNUNET_PQ_result_spec_allow_null (
      67              :       GNUNET_PQ_result_spec_uint64 ("rule_gen",
      68              :                                     rule_gen),
      69              :       NULL),
      70           14 :     GNUNET_PQ_result_spec_bool ("kyc_required",
      71              :                                 kyc_required),
      72           14 :     GNUNET_PQ_result_spec_bool ("not_found",
      73              :                                 &not_found),
      74              :     GNUNET_PQ_result_spec_end
      75              :   };
      76              :   enum GNUNET_DB_QueryStatus qs;
      77              : 
      78           14 :   *jrules = NULL;
      79           14 :   *aml_review = false;
      80           14 :   *is_wallet = GNUNET_SYSERR;
      81           14 :   *rule_gen = 0;
      82           14 :   memset (access_token,
      83              :           0,
      84              :           sizeof (*access_token));
      85           14 :   PREPARE (pg,
      86              :            "lookup_kyc_requirement_by_row",
      87              :            "SELECT "
      88              :            " out_access_token AS access_token"
      89              :            ",out_jrules::TEXT AS jrules"
      90              :            ",out_is_wallet AS is_wallet"
      91              :            ",out_not_found AS not_found"
      92              :            ",out_aml_review AS aml_review"
      93              :            ",out_kyc_required AS kyc_required"
      94              :            ",out_rule_gen AS rule_gen"
      95              :            " FROM exchange_do_lookup_kyc_requirement_by_row"
      96              :            " ($1, $2);");
      97           14 :   qs = GNUNET_PQ_eval_prepared_singleton_select (
      98              :     pg->conn,
      99              :     "lookup_kyc_requirement_by_row",
     100              :     params,
     101              :     rs);
     102           14 :   if (qs <= 0)
     103            0 :     return qs;
     104           14 :   if (! bis_wallet_unknown)
     105           14 :     *is_wallet = (bis_wallet) ? GNUNET_YES : GNUNET_NO;
     106           14 :   if (not_found)
     107            0 :     return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
     108           14 :   return qs;
     109              : }
        

Generated by: LCOV version 2.0-1