do_purse_deposit.h (3027B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022 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/exchange-database/do_purse_deposit.h 18 * @brief implementation of the do_purse_deposit function for Postgres 19 * @author Christian Grothoff 20 */ 21 #ifndef EXCHANGE_DATABASE_DO_PURSE_DEPOSIT_H 22 #define EXCHANGE_DATABASE_DO_PURSE_DEPOSIT_H 23 24 #include "taler/taler_util.h" 25 #include "taler/taler_json_lib.h" 26 #include "exchangedb_lib.h" 27 28 29 /** 30 * Function called to execute a transaction crediting 31 * a purse with @a amount from @a coin_pub. Reduces the 32 * value of @a coin_pub and increase the balance of 33 * the @a purse_pub purse. If the balance reaches the 34 * target amount and the purse has been merged, triggers 35 * the updates of the reserve/account balance. 36 * 37 * Primary test table: `purse_deposits` (see test_purse_deposits.c). 38 * 39 * @param pg the database context 40 * @param purse_pub purse to credit 41 * @param coin_pub coin to deposit (debit) 42 * @param amount fraction of the coin's value to deposit 43 * @param coin_sig signature affirming the operation 44 * @param amount_minus_fee amount to add to the purse 45 * @param[out] balance_ok set to false if the coin's 46 * remaining balance is below @a amount; 47 * in this case, the return value will be 48 * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT despite the failure 49 * @param[out] too_late set to true if it is too late to deposit into the purse 50 * @param[out] conflict set to true if the deposit failed due to a conflict (coin already spent, 51 * or deposited into this purse with a different amount) 52 * @return transaction status code 53 */ 54 enum GNUNET_DB_QueryStatus 55 TALER_EXCHANGEDB_do_purse_deposit (struct TALER_EXCHANGEDB_PostgresContext *pg, 56 const struct TALER_PurseContractPublicKeyP * 57 purse_pub, 58 const struct TALER_CoinSpendPublicKeyP * 59 coin_pub, 60 const struct TALER_Amount *amount, 61 const struct TALER_CoinSpendSignatureP * 62 coin_sig, 63 const struct TALER_Amount *amount_minus_fee, 64 bool *balance_ok, 65 bool *too_late, 66 bool *conflict); 67 68 #endif