anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

anastasis-db_get_last_auth_iban_payment_row.c (2539B)


      1 /*
      2   This file is part of Anastasis
      3   Copyright (C) 2020-2022 Anastasis SARL
      4 
      5   Anastasis is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Affero General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   Anastasis 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 Affero General Public License for more details.
     12 
     13   You should have received a copy of the GNU Affero General Public License along with
     14   Anastasis; see the file COPYING.GPL.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 /**
     17  * @file stasis/anastasis-db_get_last_auth_iban_payment_row.c
     18  * @brief Anastasis database: get last auth iban payment row
     19  * @author Christian Grothoff
     20  */
     21 #include "platform.h"
     22 #include "anastasis-db_pg.h"
     23 #include "anastasis/anastasis-database/get_last_auth_iban_payment_row.h"
     24 #include "anastasis/anastasis-database/transaction.h"
     25 #include "anastasis/anastasis-database/preflight.h"
     26 #include <taler/taler_pq_lib.h>
     27 
     28 
     29 /**
     30  * Function to check the last known IBAN payment.
     31  *
     32  * @param credit_account which credit account to check
     33  * @param[out] last_row set to the last known row
     34  * @return transaction status,
     35  *    #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if @a cb
     36  *      returned 'true' once
     37  *    #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if no
     38  *      wire transfers existed for which @a cb returned true
     39  */
     40 enum GNUNET_DB_QueryStatus
     41 ANASTASIS_DB_get_last_auth_iban_payment_row (
     42   const char *credit_account,
     43   uint64_t *last_row)
     44 {
     45   struct GNUNET_PQ_QueryParam params[] = {
     46     GNUNET_PQ_query_param_string (credit_account),
     47     GNUNET_PQ_query_param_end
     48   };
     49   struct GNUNET_PQ_ResultSpec rs[] = {
     50     GNUNET_PQ_result_spec_uint64 ("wire_reference",
     51                                   last_row),
     52     GNUNET_PQ_result_spec_end
     53   };
     54 
     55   PREPARE ("get_last_auth_iban_payment",
     56            "SELECT "
     57            " wire_reference"
     58            " FROM anastasis_auth_iban_in"
     59            " WHERE credit_account_details=$1"
     60            " ORDER BY wire_reference DESC"
     61            " LIMIT 1;");
     62   return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
     63                                                    "get_last_auth_iban_payment",
     64                                                    params,
     65                                                    rs);
     66 }
     67 
     68 
     69 /* end of anastasis-db_get_last_auth_iban_payment_row.c */