post-batch-deposit.rst (15130B)
1 .. http:post:: /batch-deposit 2 3 Deposit multiple coins and ask the exchange to transfer the given :ref:`amount` 4 into the merchant's bank account. This API is used by the merchant to redeem 5 the digital coins. 6 7 **Request:** 8 9 The request body must be a `BatchDepositRequest` object. 10 11 **Response:** 12 13 :http:statuscode:`200 OK`: 14 The operation succeeded, the exchange confirms that no double-spending took 15 place. The response will include a `DepositSuccess` object. 16 :http:statuscode:`400 Bad Request`: 17 The request is malformed or a parameter is invalid. 18 This response comes with a standard `ErrorDetail` response. 19 Possible error codes include ``TALER_EC_GENERIC_PARAMETER_MALFORMED``, 20 ``TALER_EC_EXCHANGE_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE``, 21 ``TALER_EC_EXCHANGE_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE``, 22 ``TALER_EC_EXCHANGE_DEPOSIT_WIRE_DEADLINE_IS_NEVER``, 23 ``TALER_EC_EXCHANGE_GENERIC_AMOUNT_EXCEEDS_DENOMINATION_VALUE``, 24 ``TALER_EC_EXCHANGE_GENERIC_CIPHER_MISMATCH``, or 25 ``TALER_EC_EXCHANGE_DEPOSITS_POLICY_NOT_ACCEPTED``. 26 :http:statuscode:`403 Forbidden`: 27 One of the signatures is invalid. 28 This response comes with a standard `ErrorDetail` response. 29 Possible error codes include 30 ``TALER_EC_EXCHANGE_DEPOSIT_COIN_SIGNATURE_INVALID`` or 31 ``TALER_EC_EXCHANGE_DENOMINATION_SIGNATURE_INVALID``. 32 :http:statuscode:`404 Not found`: 33 Either one of the denomination keys is not recognized (expired or invalid), 34 or the wire type is not recognized. 35 If a denomination key is unknown, the response will be 36 a `DenominationUnknownMessage`. 37 :http:statuscode:`409 Conflict`: 38 The deposit operation has either failed because a coin has insufficient 39 residual value, or because the same public key of a coin has been 40 previously used with a different denomination. 41 Which case it is can be decided by looking at the error code: 42 43 1. ``TALER_EC_EXCHANGE_DEPOSIT_CONFLICTING_CONTRACT`` (same coin used in different ways), 44 2. ``TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS`` (balance insufficient), 45 3. ``TALER_EC_EXCHANGE_GENERIC_COIN_CONFLICTING_DENOMINATION_KEY`` (same coin public key, but different denomination). 46 4. ``TALER_EC_EXCHANGE_GENERIC_COIN_CONFLICTING_AGE_HASH`` (same coin public key, but different age commitment). 47 48 The request should not be repeated again with this coin. Instead, the client 49 can get from the exchange via the ``/coin/$COIN_PUB/history`` endpoint the record 50 of the transactions known for this coin's public key. 51 :http:statuscode:`410 Gone`: 52 The requested denomination key is no longer valid. 53 It is past the expiration or was revoked. The response is a 54 `DenominationGoneMessage`. Clients must evaluate 55 the error code provided to understand which of the 56 cases this is and handle it accordingly. 57 Possible error codes include 58 ``TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED`` or 59 ``TALER_EC_EXCHANGE_GENERIC_DENOMINATION_REVOKED``. 60 :http:statuscode:`412 Precondition Failed`: 61 The requested denomination key is not yet valid. 62 It is before the validity start time. The response is a 63 `DenominationGoneMessage` with 64 ``TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE``. 65 :http:statuscode:`413 Request entity too large`: 66 The uploaded body is to long, it exceeds the size limit. 67 Returned with an error code of 68 ``TALER_EC_GENERIC_UPLOAD_EXCEEDS_LIMIT``. 69 :http:statuscode:`451 Unavailable For Legal Reasons`: 70 This merchant has not yet passed the KYC checks. 71 The client must pass KYC checks before proceeding with the deposit. 72 The response will be an `LegitimizationNeededResponse` object. 73 @since protocol **v21**. 74 :http:statuscode:`500 Internal Server Error`: 75 The server experienced an internal error. 76 This response comes with a standard `ErrorDetail` response. 77 Possible error codes include 78 ``TALER_EC_GENERIC_DB_STORE_FAILED``, 79 ``TALER_EC_GENERIC_DB_START_FAILED``, or 80 ``TALER_EC_GENERIC_DB_FETCH_FAILED``. 81 82 **Details:** 83 84 .. ts:def:: BatchDepositRequest 85 86 interface BatchDepositRequest { 87 88 // The merchant's account details as a full payto URI. 89 merchant_payto_uri: string; 90 91 // The salt is used to hide the ``payto_uri`` from customers 92 // when computing the ``h_wire`` of the merchant. 93 wire_salt: WireSalt; 94 95 // SHA-512 hash of the contract of the merchant with the customer. Further 96 // details are never disclosed to the exchange. 97 h_contract_terms: HashCode; 98 99 // Merchant's signature over the h_contract_terms. 100 // @since protocol **v22** 101 merchant_sig: EddsaSignature; 102 103 // The list of coins that are going to be deposited with this Request. 104 coins: BatchDepositRequestCoin[]; 105 106 // Timestamp when the contract was finalized. 107 timestamp: Timestamp; 108 109 // Indicative time by which the exchange undertakes to transfer the funds to 110 // the merchant, in case of successful payment. A wire transfer deadline of 'never' 111 // is not allowed. 112 wire_transfer_deadline: Timestamp; 113 114 // EdDSA `public key of the merchant <merchant-pub>`, so that the client can identify the 115 // merchant for refund requests. 116 merchant_pub: EddsaPublicKey; 117 118 // Additional text to include in the wire transfer subject when 119 // settling the payment. Note that the merchant MUST use this 120 // consistently for the same ``merchant_pub`` and ``merchant_payto_uri`` 121 // as during aggregation *any* of these values may be selected 122 // for the actual aggregated wire transfer. If a merchant wants 123 // to use different ``extra_subject`` values for the same IBAN, 124 // it should thus create multiple instances (with different 125 // ``merchant_pub`` values). When changing the ``extra_subject``, 126 // the change may thus not be immediately reflected in the 127 // settlements. 128 // 129 // Must match [a-zA-Z0-9-.:]{1, 40} 130 // 131 // Optional. Since **v32**. 132 extra_wire_subject_metadata?: string; 133 134 // Date until which the merchant can issue a refund to the customer via the 135 // exchange, to be omitted if refunds are not allowed. 136 // 137 // THIS FIELD WILL BE DEPRICATED, once the refund mechanism becomes a 138 // policy via extension. 139 refund_deadline?: Timestamp; 140 141 // CAVEAT: THIS IS WORK IN PROGRESS 142 // (Optional) policy for the batch-deposit. 143 // This might be a refund, auction or escrow policy. 144 policy?: DepositPolicy; 145 } 146 147 .. ts:def:: BatchDepositRequestCoin 148 149 interface BatchDepositRequestCoin { 150 // EdDSA public key of the coin being deposited. 151 coin_pub: EddsaPublicKey; 152 153 // Hash of denomination RSA key with which the coin is signed. 154 denom_pub_hash: HashCode; 155 156 // Exchange's unblinded RSA signature of the coin. 157 ub_sig: DenominationSignature; 158 159 // Amount to be deposited, can be a fraction of the 160 // coin's total value. 161 contribution: Amount; 162 163 // Signature over `TALER_DepositRequestPS`, made by the customer with the 164 // `coin's private key <coin-priv>`. 165 coin_sig: EddsaSignature; 166 167 // Hash over the age commitment of the coin. 168 // Only present if the coin is actually age-restricted. 169 h_age_commitment?: HashCode; 170 } 171 172 .. ts:def:: DenominationSignature 173 174 type DenominationSignature = DenomCipher & ( 175 | RsaDenominationSignature 176 | CSDenominationSignature 177 ); 178 179 .. ts:def:: RsaDenominationSignature 180 181 interface RsaDenominationSignature extends DenomCipher { 182 cipher: "RSA"; 183 184 // RSA signature 185 rsa_signature: RsaSignature; 186 } 187 188 .. ts:def:: CSDenominationSignature 189 190 interface CSDenominationSignature extends DenomCipher { 191 cipher: "CS"; 192 193 // R value component of the signature. 194 cs_signature_r: Cs25519Point; 195 196 // s value component of the signature. 197 cs_signature_s: Cs25519Scalar; 198 199 } 200 201 .. ts:def:: DepositPolicy 202 203 type DepositPolicy = 204 | PolicyMerchantRefund 205 | PolicyBrandtVickreyAuction 206 | PolicyEscrowedPayment; 207 208 .. ts:def:: PolicyMerchantRefund 209 210 // CAVEAT: THIS IS STILL WORK IN PROGRESS. 211 // This policy is optional and might not be supported by the exchange. 212 // If it does, the exchange MUST show support for this policy in the 213 // ``extensions`` field in the response to ``/keys``. 214 interface PolicyMerchantRefund { 215 type: "merchant_refund"; 216 217 // EdDSA `public key of the merchant <merchant-pub>`, so that the client 218 // can identify the merchant for refund requests. 219 merchant_pub: EddsaPublicKey; 220 221 // Date until which the merchant can issue a refund to the customer via 222 // the ``/extensions/policy_refund``-endpoint of the exchange. 223 deadline: Timestamp; 224 } 225 226 .. ts:def:: PolicyBrandtVickreyAuction 227 228 // CAVEAT: THIS IS STILL WORK IN PROGRESS. 229 // This policy is optional and might not be supported by the exchange. 230 // If it does, the exchange MUST show support for this policy in the 231 // ``extensions`` field in the response to ``/keys``. 232 interface PolicyBrandtVickreyAuction { 233 type: "brandt_vickrey_auction"; 234 235 // Public key of this bidder. 236 // 237 // The bidder uses this key to sign the auction information and 238 // the messages it sends to the seller during the auction. 239 bidder_pub: EddsaPublicKey; 240 241 // Hash of the auction terms 242 // 243 // The hash should be taken over a normalized JSON object of type 244 // `BrandtVickreyAuction`. 245 h_auction: HashCode; 246 247 // The amount that this bidder commits to for this auction 248 // 249 // This amount can be larger than the contribution of a single coin. 250 // The bidder can increase funding of this auction policy by using 251 // sufficiently many coins during the deposit operation (single or batch) 252 // with the same policy. 253 commitment: Amount; 254 255 // Date until the auction must have been successfully executed and 256 // a valid transcript provided to the 257 // ``/extensions/policy_brandt_vickrey_auction``-endpoint of the 258 // exchange. 259 // 260 // [If the auction has not been executed by then] OR [has been executed 261 // before then, but this bidder did not win], the coin's value doesn't 262 // change and the owner can refresh the coin. 263 // 264 // If this bidder won the auction, the winning price/amount from the 265 // outcome will be substracted from the coin and transfered to the 266 // merchant's ``payout_uri`` from the deposit request (minus a potential 267 // auction fee). For any remaining value, the bidder can refresh the 268 // coin to retrieve change. 269 deadline: Timestamp; 270 } 271 272 .. ts:def:: BrandtVickreyAuction 273 274 // CAVEAT: THIS IS STILL WORK IN PROGRESS. 275 // This structure defines an auction of Brandt-Vickory kind. 276 // It is used for the `PolicyBrandtVickreyAuction`. 277 interface BrandtVickreyAuction { 278 // Start date of the auction 279 time_start: Timestamp; 280 281 // Maximum duration per round. There are four rounds in an auction of 282 // Brandt-Vickrey kind. 283 time_round: RelativeTime; 284 285 // This integer m refers to the (m+1)-type of the Brandt-Vickrey-auction. 286 // - Type 0 refers to an auction with one highest-price winner, 287 // - Type 1 refers to an auction with one winner, paying the second 288 // highest price, 289 // - Type 2 refers to an auction with two winners, paying 290 // the third-highest price, 291 // - etc. 292 auction_type: Integer; 293 294 // The vector of prices for the Brandt-Vickrey auction. The values MUST 295 // be in strictly increasing order. 296 prices: Amount[]; 297 298 // The type of outcome of the auction. 299 // In case the auction is declared public, each bidder can calculate the 300 // winning price. This field is not relevant for the replay of a 301 // transcript, as the transcript must be provided by the seller who sees 302 // the winner(s) and winning price of the auction. 303 outcome_public: boolean; 304 305 // The public key of the seller. 306 pubkey: EddsaPublicKey; 307 308 // The seller's account details as a full payto URI. 309 payto_uri: string; 310 } 311 312 313 .. ts:def:: PolicyEscrowedPayment 314 315 // CAVEAT: THIS IS STILL WORK IN PROGRESS 316 // This policy is optional and might not be supported by the exchange. 317 // If it does, the exchange MUST show support for this policy in the 318 // ``extensions`` field in the response to ``/keys``. 319 interface PolicyEscrowedPayment { 320 type: "escrowed_payment"; 321 322 // Public key of this trustor, the owner of the coins. 323 // 324 // To claim the deposit, the merchant must provide the valid signature 325 // of the ``h_contract_terms`` field from the deposit, signed by _this_ 326 // key, to the ``/extensions/policy_escrow``-endpoint of the exchange, 327 // after the date specified in ``not_before`` and before the date 328 // specified in ``not_after``. 329 trustor_pub: EddsaPublicKey; 330 331 // Latest date by which the deposit must be claimed. If the deposit 332 // has not been claimed by that date, the deposited coins can be 333 // refreshed by the (still) owner. 334 deadline: Timestamp; 335 } 336 337 The deposit operation succeeds if the coin is valid for making a deposit and 338 has enough residual value that has not already been deposited or melted. 339 340 .. ts:def:: DepositSuccessResponse 341 342 interface DepositSuccessResponse { 343 344 // Total amount deposited so far under this contract terms for 345 // this merchant. 346 // Since **v33**. 347 accumulated_total_without_fee: Amount; 348 349 // Timestamp when the deposit was received by the exchange. 350 exchange_timestamp: Timestamp; 351 352 // `Public EdDSA key of the exchange <sign-key-pub>` that was used to 353 // generate the signature. 354 // Should match one of the exchange's signing keys from ``/keys``. It is given 355 // explicitly as the client might otherwise be confused by clock skew as to 356 // which signing key was used. 357 exchange_pub: EddsaPublicKey; 358 359 // Deposit confirmation signature from the exchange. 360 // The EdDSA signature of `TALER_DepositConfirmationPS` using a current 361 // `signing key of the exchange <sign-key-priv>` affirming the successful 362 // deposit and that the exchange will transfer the funds after the refund 363 // deadline, or as soon as possible if the refund deadline is zero. 364 exchange_sig: EddsaSignature; 365 } 366 367 .. ts:def:: DepositDoubleSpendError 368 369 interface DepositDoubleSpendError { 370 371 // Must be TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS 372 // or TALER_EC_EXCHANGE_GENERIC_COIN_CONFLICTING_DENOMINATION_KEY 373 code: Integer; 374 375 // A string explaining that the user tried to 376 // double-spend. 377 hint: string; 378 379 // EdDSA public key of a coin being double-spent. 380 coin_pub: EddsaPublicKey; 381 382 // Hash of the public key of the denomination of the coin. 383 h_denom_pub: HashCode; 384 385 }