merchant

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

do_insert_fountain.h (2976B)


      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/include/merchant-database/do_insert_fountain.h
     18  * @brief implementation of the do_insert_fountain function for Postgres
     19  * @author Bohdan Potuzhnyi
     20  */
     21 #ifndef MERCHANT_DATABASE_DO_INSERT_FOUNTAIN_H
     22 #define MERCHANT_DATABASE_DO_INSERT_FOUNTAIN_H
     23 
     24 #include <taler/taler_util.h>
     25 #include "merchantdb_lib.h"
     26 
     27 
     28 struct TALER_MERCHANTDB_PostgresContext;
     29 
     30 /**
     31  * Withdrawal rights of a fountain for one token family (DD 98).
     32  */
     33 struct TALER_MERCHANTDB_FountainGrant
     34 {
     35   /**
     36    * Slug of the token family this grant refers to.
     37    */
     38   const char *token_family_slug;
     39 
     40   /**
     41    * Maximum number of tokens blind-signed per issue-key
     42    * validity period for this family.
     43    */
     44   uint64_t tokens_per_period_limit;
     45 
     46   /**
     47    * Number of tokens the wallet should aim to hold per period;
     48    * at most @e tokens_per_period_limit.
     49    */
     50   uint64_t tokens_per_period_stash;
     51 
     52   /**
     53    * Number of issue-key slots ahead of the current one the
     54    * wallet may withdraw tokens for.
     55    */
     56   uint32_t key_window_size;
     57 };
     58 
     59 
     60 /**
     61  * Create a fountain with its grants.
     62  *
     63  * @param pg database context
     64  * @param instance_id instance to create the fountain for
     65  * @param fountain_id public identifier of the new fountain
     66  * @param h_fountain_secret hash of the fountain's bearer credential
     67  * @param description description of the fountain
     68  * @param poll_freq how often wallets should re-poll the fountain info
     69  * @param grants_len length of the @a grants array
     70  * @param grants withdrawal rights of the fountain
     71  * @param[out] unknown_slug set to the first token family slug in
     72  *        @a grants that does not exist (caller must free); the
     73  *        fountain is not created in that case
     74  * @param[out] conflict set to true if a fountain with the same
     75  *        @a fountain_id or @a h_fountain_secret already exists
     76  * @return database result code
     77  */
     78 enum GNUNET_DB_QueryStatus
     79 TALER_MERCHANTDB_do_insert_fountain (
     80   struct TALER_MERCHANTDB_PostgresContext *pg,
     81   const char *instance_id,
     82   const char *fountain_id,
     83   const struct GNUNET_HashCode *h_fountain_secret,
     84   const char *description,
     85   struct GNUNET_TIME_Relative poll_freq,
     86   unsigned int grants_len,
     87   const struct TALER_MERCHANTDB_FountainGrant grants[static grants_len],
     88   char **unknown_slug,
     89   bool *conflict);
     90 
     91 #endif