donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

donaudb_lib.h (3913B)


      1 /*
      2 This file is part of TALER
      3   Copyright (C) 2014 - 2020 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,
      8 or (at your option) any later version.
      9 
     10 TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     12 A PARTICULAR PURPOSE.See the GNU General Public License for more details.
     13 
     14 You should have received a copy of the GNU General Public License along with
     15                                                TALER; see the file
     16 COPYING.If not, see <http:                        // www.gnu.org/licenses/>
     17 */
     18 /**
     19  *@file include/donaudb_lib.h
     20  * @brief IO operations for the donau's private keys
     21  * @author Florian Dold
     22  * @author Benedikt Mueller
     23  * @author Christian Grothoff
     24  */
     25 #ifndef DONAUDB_LIB_H
     26 #define DONAUDB_LIB_H
     27 
     28 #include <taler/taler_util.h>
     29 #include <taler/taler_json_lib.h>
     30 #include <taler/taler_error_codes.h>
     31 #include <taler/taler_dbevents.h>
     32 #include <taler/taler_pq_lib.h>
     33 #include "donau_util.h"
     34 #include "donau_signatures.h"
     35 
     36 
     37 /**
     38  * Main handle for the database.
     39  */
     40 struct DONAUDB_PostgresContext;
     41 
     42 
     43 /**
     44  * Meta data about an donau signing key.
     45  */
     46 struct DONAUDB_SignkeyMetaData
     47 {
     48   /**
     49    * Start time of the validity period for this key.
     50    */
     51   struct GNUNET_TIME_Timestamp valid_from;
     52 
     53   /**
     54    * The donau will sign messages with this key between @e start and this time.
     55    */
     56   struct GNUNET_TIME_Timestamp expire_sign;
     57 
     58   /**
     59    * When do signatures with this sign key become invalid?
     60    * After this point, these signatures cannot be used in (legal)
     61    * disputes anymore, as the Donau is then allowed to destroy its side
     62    * of the evidence.  @e expire_legal is expected to be significantly
     63    * larger than @e expire_sign (by a year or more).
     64    */
     65   struct GNUNET_TIME_Timestamp expire_legal;
     66 
     67 };
     68 
     69 /**
     70  * Meta data about a charity.
     71  */
     72 struct DONAUDB_CharityMetaData
     73 {
     74   /**
     75    * Charity public key
     76    */
     77   struct DONAU_CharityPublicKeyP charity_pub;
     78 
     79   /**
     80    * Charity name
     81    */
     82   char *charity_name;
     83 
     84   /**
     85    * Charity url
     86    */
     87   char *charity_url;
     88 
     89   /**
     90    * Charity yearly donation limit
     91    */
     92   struct TALER_Amount max_per_year;
     93 
     94   /**
     95    * Charity donations received in the current year
     96    */
     97   struct TALER_Amount receipts_to_date;
     98 
     99   /**
    100    * Current year
    101    */
    102   uint32_t current_year;
    103 
    104 };
    105 
    106 /**
    107  * Meta data about issued receipts of a request.
    108  */
    109 struct DONAUDB_IssuedReceiptsMetaData
    110 {
    111   /**
    112    * Charity id
    113    */
    114   uint64_t charity_id;
    115 
    116   /**
    117    * total issued amount of the receipts
    118    */
    119   struct TALER_Amount amount;
    120 
    121   /**
    122    * number of signatures
    123    */
    124   size_t num_sig;
    125 
    126   /**
    127    * Array of blinded signatures
    128    */
    129   struct DONAU_BlindedDonationUnitSignature *blinded_sigs;
    130 
    131 };
    132 
    133 /**
    134  * @brief All information about a donation unit key.
    135  */
    136 struct DONAUDB_DonationUnitKey
    137 {
    138   /**
    139    * The private key of the donation unit.  Will be NULL if the private
    140    * key is not available.
    141    */
    142   struct DONAU_DonationUnitPublicKey donation_unit_priv;
    143 
    144   /**
    145    * Decoded donation unit public key.
    146    */
    147   struct DONAU_DonationUnitPublicKey donation_unit_pub;
    148 
    149 };
    150 
    151 
    152 /**
    153  * Connect to the database if the connection does not exist yet.
    154  *
    155  * @param pg the plugin-specific state
    156  * @return #GNUNET_OK on success
    157  */
    158 enum GNUNET_GenericReturnValue
    159 DONAUDB_internal_setup (struct DONAUDB_PostgresContext *pg);
    160 
    161 
    162 /**
    163  * Connect to the donau database.
    164  *
    165  * @param cfg configuration to use
    166  * @return NULL on failure
    167  */
    168 struct DONAUDB_PostgresContext *
    169 DONAUDB_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
    170 
    171 
    172 /**
    173  * Disconnect from the donau database.
    174  *
    175  * @param pg context to disconnect and free
    176  */
    177 void
    178 DONAUDB_disconnect (struct DONAUDB_PostgresContext *pg);
    179 
    180 #endif