do_purse_deposit.h (2955B)
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 * @param pg the database context 38 * @param purse_pub purse to credit 39 * @param coin_pub coin to deposit (debit) 40 * @param amount fraction of the coin's value to deposit 41 * @param coin_sig signature affirming the operation 42 * @param amount_minus_fee amount to add to the purse 43 * @param[out] balance_ok set to false if the coin's 44 * remaining balance is below @a amount; 45 * in this case, the return value will be 46 * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT despite the failure 47 * @param[out] too_late set to true if it is too late to deposit into the purse 48 * @param[out] conflict set to true if the deposit failed due to a conflict (coin already spent, 49 * or deposited into this purse with a different amount) 50 * @return transaction status code 51 */ 52 enum GNUNET_DB_QueryStatus 53 TALER_EXCHANGEDB_do_purse_deposit (struct TALER_EXCHANGEDB_PostgresContext *pg, 54 const struct TALER_PurseContractPublicKeyP * 55 purse_pub, 56 const struct TALER_CoinSpendPublicKeyP * 57 coin_pub, 58 const struct TALER_Amount *amount, 59 const struct TALER_CoinSpendSignatureP * 60 coin_sig, 61 const struct TALER_Amount *amount_minus_fee, 62 bool *balance_ok, 63 bool *too_late, 64 bool *conflict); 65 66 #endif