post-purses-PURSE_PUB-deposit.h (4874B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2014-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 Affero 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 Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file include/taler/exchange/post-purses-PURSE_PUB-deposit.h 18 * @brief C interface for POST /purses/$PURSE_PUB/deposit 19 * @author Christian Grothoff 20 */ 21 #ifndef _TALER_EXCHANGE__POST_PURSES_PURSE_PUB_DEPOSIT_H 22 #define _TALER_EXCHANGE__POST_PURSES_PURSE_PUB_DEPOSIT_H 23 24 #include <taler/exchange/common.h> 25 26 /** 27 * Handle for an operation to POST /purses/$PURSE_PUB/deposit. 28 */ 29 struct TALER_EXCHANGE_PostPursesDepositHandle; 30 31 32 /** 33 * Set up POST /purses/$PURSE_PUB/deposit operation. 34 * Note that you must explicitly start the operation after setup. 35 * 36 * @param ctx curl context 37 * @param url exchange base URL 38 * @param keys exchange keys 39 * @param purse_exchange_url base URL of the exchange hosting the purse 40 * @param purse_pub public key of the purse to deposit into 41 * @param min_age minimum age we need to prove for the purse 42 * @param num_deposits length of the @a deposits array 43 * @param deposits array of deposits to make into the purse 44 * @return handle to operation, NULL on error 45 */ 46 struct TALER_EXCHANGE_PostPursesDepositHandle * 47 TALER_EXCHANGE_post_purses_deposit_create ( 48 struct GNUNET_CURL_Context *ctx, 49 const char *url, 50 struct TALER_EXCHANGE_Keys *keys, 51 const char *purse_exchange_url, // FIXME: turn into option 52 const struct TALER_PurseContractPublicKeyP *purse_pub, 53 uint8_t min_age, // FIXME: turn into option 54 unsigned int num_deposits, 55 const struct TALER_EXCHANGE_PurseDeposit deposits[static num_deposits]); 56 57 58 /** 59 * Response generated for purse deposit request. 60 */ 61 struct TALER_EXCHANGE_PostPursesDepositResponse 62 { 63 /** 64 * Full HTTP response. 65 */ 66 struct TALER_EXCHANGE_HttpResponse hr; 67 68 /** 69 * Details depending on the HTTP status. 70 */ 71 union 72 { 73 /** 74 * Details returned on #MHD_HTTP_OK. 75 */ 76 struct 77 { 78 /** 79 * When does the purse expire. 80 */ 81 struct GNUNET_TIME_Timestamp purse_expiration; 82 83 /** 84 * How much was actually deposited into the purse. 85 */ 86 struct TALER_Amount total_deposited; 87 88 /** 89 * How much should be in the purse in total in the end. 90 */ 91 struct TALER_Amount purse_value_after_fees; 92 93 /** 94 * Hash of the contract (needed to verify signature). 95 */ 96 struct TALER_PrivateContractHashP h_contract_terms; 97 98 /** 99 * Signature by the exchange affirming the deposit. 100 */ 101 struct TALER_ExchangeSignatureP exchange_sig; 102 103 /** 104 * Online signing key used by the exchange. 105 */ 106 struct TALER_ExchangePublicKeyP exchange_pub; 107 108 } ok; 109 } details; 110 111 }; 112 113 114 #ifndef TALER_EXCHANGE_POST_PURSES_DEPOSIT_RESULT_CLOSURE 115 /** 116 * Type of the closure used by 117 * the #TALER_EXCHANGE_PostPursesDepositCallback. 118 */ 119 #define TALER_EXCHANGE_POST_PURSES_DEPOSIT_RESULT_CLOSURE void 120 #endif /* TALER_EXCHANGE_POST_PURSES_DEPOSIT_RESULT_CLOSURE */ 121 122 /** 123 * Type of the function that receives the result of a 124 * POST /purses/$PURSE_PUB/deposit request. 125 * 126 * @param cls closure 127 * @param result result returned by the HTTP server 128 */ 129 typedef void 130 (*TALER_EXCHANGE_PostPursesDepositCallback)( 131 TALER_EXCHANGE_POST_PURSES_DEPOSIT_RESULT_CLOSURE *cls, 132 const struct TALER_EXCHANGE_PostPursesDepositResponse *result); 133 134 135 /** 136 * Start POST /purses/$PURSE_PUB/deposit operation. 137 * 138 * @param[in,out] ppdh operation to start 139 * @param cb function to call with the exchange's result 140 * @param cb_cls closure for @a cb 141 * @return status code, #TALER_EC_NONE on success 142 */ 143 enum TALER_ErrorCode 144 TALER_EXCHANGE_post_purses_deposit_start ( 145 struct TALER_EXCHANGE_PostPursesDepositHandle *ppdh, 146 TALER_EXCHANGE_PostPursesDepositCallback cb, 147 TALER_EXCHANGE_POST_PURSES_DEPOSIT_RESULT_CLOSURE *cb_cls); 148 149 150 /** 151 * Cancel POST /purses/$PURSE_PUB/deposit operation. This function must not 152 * be called by clients after the TALER_EXCHANGE_PostPursesDepositCallback has 153 * been invoked (as in those cases it'll be called internally by the 154 * implementation already). 155 * 156 * @param[in] ppdh operation to cancel 157 */ 158 void 159 TALER_EXCHANGE_post_purses_deposit_cancel ( 160 struct TALER_EXCHANGE_PostPursesDepositHandle *ppdh); 161 162 163 #endif /* _TALER_EXCHANGE__POST_PURSES_PURSE_PUB_DEPOSIT_H */