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