post-batch-deposit.rst (14810B)
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 75 **Details:** 76 77 .. ts:def:: BatchDepositRequest 78 79 interface BatchDepositRequest { 80 81 // The merchant's account details as a full payto URI. 82 merchant_payto_uri: string; 83 84 // The salt is used to hide the ``payto_uri`` from customers 85 // when computing the ``h_wire`` of the merchant. 86 wire_salt: WireSalt; 87 88 // SHA-512 hash of the contract of the merchant with the customer. Further 89 // details are never disclosed to the exchange. 90 h_contract_terms: HashCode; 91 92 // Merchant's signature over the h_contract_terms. 93 // @since protocol **v22** 94 merchant_sig: EddsaSignature; 95 96 // The list of coins that are going to be deposited with this Request. 97 coins: BatchDepositRequestCoin[]; 98 99 // Timestamp when the contract was finalized. 100 timestamp: Timestamp; 101 102 // Indicative time by which the exchange undertakes to transfer the funds to 103 // the merchant, in case of successful payment. A wire transfer deadline of 'never' 104 // is not allowed. 105 wire_transfer_deadline: Timestamp; 106 107 // EdDSA `public key of the merchant <merchant-pub>`, so that the client can identify the 108 // merchant for refund requests. 109 merchant_pub: EddsaPublicKey; 110 111 // Additional text to include in the wire transfer subject when 112 // settling the payment. Note that the merchant MUST use this 113 // consistently for the same ``merchant_pub`` and ``merchant_payto_uri`` 114 // as during aggregation *any* of these values may be selected 115 // for the actual aggregated wire transfer. If a merchant wants 116 // to use different ``extra_subject`` values for the same IBAN, 117 // it should thus create multiple instances (with different 118 // ``merchant_pub`` values). When changing the ``extra_subject``, 119 // the change may thus not be immediately reflected in the 120 // settlements. 121 // 122 // Must match [a-zA-Z0-9-.:]{1, 40} 123 // 124 // Optional. Since **v32**. 125 extra_wire_subject_metadata?: string; 126 127 // Date until which the merchant can issue a refund to the customer via the 128 // exchange, to be omitted if refunds are not allowed. 129 // 130 // THIS FIELD WILL BE DEPRICATED, once the refund mechanism becomes a 131 // policy via extension. 132 refund_deadline?: Timestamp; 133 134 // CAVEAT: THIS IS WORK IN PROGRESS 135 // (Optional) policy for the batch-deposit. 136 // This might be a refund, auction or escrow policy. 137 policy?: DepositPolicy; 138 } 139 140 .. ts:def:: BatchDepositRequestCoin 141 142 interface BatchDepositRequestCoin { 143 // EdDSA public key of the coin being deposited. 144 coin_pub: EddsaPublicKey; 145 146 // Hash of denomination RSA key with which the coin is signed. 147 denom_pub_hash: HashCode; 148 149 // Exchange's unblinded RSA signature of the coin. 150 ub_sig: DenominationSignature; 151 152 // Amount to be deposited, can be a fraction of the 153 // coin's total value. 154 contribution: Amount; 155 156 // Signature over `TALER_DepositRequestPS`, made by the customer with the 157 // `coin's private key <coin-priv>`. 158 coin_sig: EddsaSignature; 159 160 // Hash over the age commitment of the coin. 161 // Only present if the coin is actually age-restricted. 162 h_age_commitment?: HashCode; 163 } 164 165 .. ts:def:: DenominationSignature 166 167 type DenominationSignature = DenomCipher & ( 168 | RsaDenominationSignature 169 | CSDenominationSignature 170 ); 171 172 .. ts:def:: RsaDenominationSignature 173 174 interface RsaDenominationSignature extends DenomCipher { 175 cipher: "RSA"; 176 177 // RSA signature 178 rsa_signature: RsaSignature; 179 } 180 181 .. ts:def:: CSDenominationSignature 182 183 interface CSDenominationSignature extends DenomCipher { 184 cipher: "CS"; 185 186 // R value component of the signature. 187 cs_signature_r: Cs25519Point; 188 189 // s value component of the signature. 190 cs_signature_s: Cs25519Scalar; 191 192 } 193 194 .. ts:def:: DepositPolicy 195 196 type DepositPolicy = 197 | PolicyMerchantRefund 198 | PolicyBrandtVickreyAuction 199 | PolicyEscrowedPayment; 200 201 .. ts:def:: PolicyMerchantRefund 202 203 // CAVEAT: THIS IS STILL WORK IN PROGRESS. 204 // This policy is optional and might not be supported by the exchange. 205 // If it does, the exchange MUST show support for this policy in the 206 // ``extensions`` field in the response to ``/keys``. 207 interface PolicyMerchantRefund { 208 type: "merchant_refund"; 209 210 // EdDSA `public key of the merchant <merchant-pub>`, so that the client 211 // can identify the merchant for refund requests. 212 merchant_pub: EddsaPublicKey; 213 214 // Date until which the merchant can issue a refund to the customer via 215 // the ``/extensions/policy_refund``-endpoint of the exchange. 216 deadline: Timestamp; 217 } 218 219 .. ts:def:: PolicyBrandtVickreyAuction 220 221 // CAVEAT: THIS IS STILL WORK IN PROGRESS. 222 // This policy is optional and might not be supported by the exchange. 223 // If it does, the exchange MUST show support for this policy in the 224 // ``extensions`` field in the response to ``/keys``. 225 interface PolicyBrandtVickreyAuction { 226 type: "brandt_vickrey_auction"; 227 228 // Public key of this bidder. 229 // 230 // The bidder uses this key to sign the auction information and 231 // the messages it sends to the seller during the auction. 232 bidder_pub: EddsaPublicKey; 233 234 // Hash of the auction terms 235 // 236 // The hash should be taken over a normalized JSON object of type 237 // `BrandtVickreyAuction`. 238 h_auction: HashCode; 239 240 // The amount that this bidder commits to for this auction 241 // 242 // This amount can be larger than the contribution of a single coin. 243 // The bidder can increase funding of this auction policy by using 244 // sufficiently many coins during the deposit operation (single or batch) 245 // with the same policy. 246 commitment: Amount; 247 248 // Date until the auction must have been successfully executed and 249 // a valid transcript provided to the 250 // ``/extensions/policy_brandt_vickrey_auction``-endpoint of the 251 // exchange. 252 // 253 // [If the auction has not been executed by then] OR [has been executed 254 // before then, but this bidder did not win], the coin's value doesn't 255 // change and the owner can refresh the coin. 256 // 257 // If this bidder won the auction, the winning price/amount from the 258 // outcome will be substracted from the coin and transfered to the 259 // merchant's ``payout_uri`` from the deposit request (minus a potential 260 // auction fee). For any remaining value, the bidder can refresh the 261 // coin to retrieve change. 262 deadline: Timestamp; 263 } 264 265 .. ts:def:: BrandtVickreyAuction 266 267 // CAVEAT: THIS IS STILL WORK IN PROGRESS. 268 // This structure defines an auction of Brandt-Vickory kind. 269 // It is used for the `PolicyBrandtVickreyAuction`. 270 interface BrandtVickreyAuction { 271 // Start date of the auction 272 time_start: Timestamp; 273 274 // Maximum duration per round. There are four rounds in an auction of 275 // Brandt-Vickrey kind. 276 time_round: RelativeTime; 277 278 // This integer m refers to the (m+1)-type of the Brandt-Vickrey-auction. 279 // - Type 0 refers to an auction with one highest-price winner, 280 // - Type 1 refers to an auction with one winner, paying the second 281 // highest price, 282 // - Type 2 refers to an auction with two winners, paying 283 // the third-highest price, 284 // - etc. 285 auction_type: Integer; 286 287 // The vector of prices for the Brandt-Vickrey auction. The values MUST 288 // be in strictly increasing order. 289 prices: Amount[]; 290 291 // The type of outcome of the auction. 292 // In case the auction is declared public, each bidder can calculate the 293 // winning price. This field is not relevant for the replay of a 294 // transcript, as the transcript must be provided by the seller who sees 295 // the winner(s) and winning price of the auction. 296 outcome_public: boolean; 297 298 // The public key of the seller. 299 pubkey: EddsaPublicKey; 300 301 // The seller's account details as a full payto URI. 302 payto_uri: string; 303 } 304 305 306 .. ts:def:: PolicyEscrowedPayment 307 308 // CAVEAT: THIS IS STILL WORK IN PROGRESS 309 // This policy is optional and might not be supported by the exchange. 310 // If it does, the exchange MUST show support for this policy in the 311 // ``extensions`` field in the response to ``/keys``. 312 interface PolicyEscrowedPayment { 313 type: "escrowed_payment"; 314 315 // Public key of this trustor, the owner of the coins. 316 // 317 // To claim the deposit, the merchant must provide the valid signature 318 // of the ``h_contract_terms`` field from the deposit, signed by _this_ 319 // key, to the ``/extensions/policy_escrow``-endpoint of the exchange, 320 // after the date specified in ``not_before`` and before the date 321 // specified in ``not_after``. 322 trustor_pub: EddsaPublicKey; 323 324 // Latest date by which the deposit must be claimed. If the deposit 325 // has not been claimed by that date, the deposited coins can be 326 // refreshed by the (still) owner. 327 deadline: Timestamp; 328 } 329 330 The deposit operation succeeds if the coin is valid for making a deposit and 331 has enough residual value that has not already been deposited or melted. 332 333 .. ts:def:: DepositSuccessResponse 334 335 interface DepositSuccessResponse { 336 337 // Total amount deposited so far under this contract terms for 338 // this merchant. 339 // Since **v33**. 340 accumulated_total_without_fee: Amount; 341 342 // Timestamp when the deposit was received by the exchange. 343 exchange_timestamp: Timestamp; 344 345 // `Public EdDSA key of the exchange <sign-key-pub>` that was used to 346 // generate the signature. 347 // Should match one of the exchange's signing keys from ``/keys``. It is given 348 // explicitly as the client might otherwise be confused by clock skew as to 349 // which signing key was used. 350 exchange_pub: EddsaPublicKey; 351 352 // Deposit confirmation signature from the exchange. 353 // The EdDSA signature of `TALER_DepositConfirmationPS` using a current 354 // `signing key of the exchange <sign-key-priv>` affirming the successful 355 // deposit and that the exchange will transfer the funds after the refund 356 // deadline, or as soon as possible if the refund deadline is zero. 357 exchange_sig: EddsaSignature; 358 } 359 360 .. ts:def:: DepositDoubleSpendError 361 362 interface DepositDoubleSpendError { 363 364 // Must be TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS 365 // or TALER_EC_EXCHANGE_GENERIC_COIN_CONFLICTING_DENOMINATION_KEY 366 code: Integer; 367 368 // A string explaining that the user tried to 369 // double-spend. 370 hint: string; 371 372 // EdDSA public key of a coin being double-spent. 373 coin_pub: EddsaPublicKey; 374 375 // Hash of the public key of the denomination of the coin. 376 h_denom_pub: HashCode; 377 378 }