merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

insert_fountain_withdraw_sig.c (2812B)


      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/insert_fountain_withdraw_sig.c
     18  * @brief record one blind signature of a completed fountain withdrawal
     19  */
     20 #include "platform.h"
     21 #include <taler/taler_pq_lib.h>
     22 #include "merchant-database/insert_fountain_withdraw_sig.h"
     23 #include "helper.h"
     24 
     25 
     26 enum GNUNET_DB_QueryStatus
     27 TALER_MERCHANTDB_insert_fountain_withdraw_sig (
     28   struct TALER_MERCHANTDB_PostgresContext *pg,
     29   uint64_t fountain_serial,
     30   const struct GNUNET_HashCode *h_request,
     31   uint32_t grant_index,
     32   uint32_t token_index,
     33   const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub,
     34   const struct TALER_BlindedTokenIssueSignature *blind_sig)
     35 {
     36   struct GNUNET_PQ_QueryParam params[] = {
     37     GNUNET_PQ_query_param_uint64 (&fountain_serial),
     38     GNUNET_PQ_query_param_auto_from_type (h_request),
     39     GNUNET_PQ_query_param_uint32 (&grant_index),
     40     GNUNET_PQ_query_param_uint32 (&token_index),
     41     GNUNET_PQ_query_param_auto_from_type (h_issue_pub),
     42     GNUNET_PQ_query_param_blinded_sig (blind_sig->signature),
     43     GNUNET_PQ_query_param_end
     44   };
     45 
     46   GNUNET_assert (NULL != pg->current_merchant_id);
     47   GNUNET_assert (NULL != pg->transaction_name);
     48   TMH_PQ_prepare_anon (pg,
     49                        "INSERT INTO merchant_fountain_withdraw_sigs"
     50                        " (fountain_serial"
     51                        " ,h_request"
     52                        " ,grant_index"
     53                        " ,token_index"
     54                        " ,token_family_slug"
     55                        " ,h_issue"
     56                        " ,signature_validity_end"
     57                        " ,token_blinded_signature"
     58                        ")"
     59                        " SELECT $1, $2, $3, $4,"
     60                        "        tf.slug, k.h_pub, k.signature_validity_end, $6"
     61                        "   FROM merchant_token_family_keys k"
     62                        "   JOIN merchant_token_families tf"
     63                        "     USING (token_family_serial)"
     64                        "  WHERE k.h_pub = $5");
     65   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     66                                              "",
     67                                              params);
     68 }