post-purses-PURSE_PUB-create.rst (6667B)
1 .. http:post:: /purses/$PURSE_PUB/create 2 3 Create a purse by depositing money into it. First step of a PUSH payment. 4 5 **Request:** 6 7 The request body must be a `PurseCreate` object. 8 9 **Response:** 10 11 :http:statuscode:`200 OK`: 12 The operation succeeded, the exchange confirms that all 13 coins were deposited into the purse. 14 The response will include a `PurseCreateSuccessResponse` object. 15 :http:statuscode:`403 Forbidden`: 16 A coin, denomination or contract signature is invalid. 17 This response comes with a standard `ErrorDetail` response. 18 :http:statuscode:`404 Not Found`: 19 The denomination of one of the coins is unknown to the exchange. 20 :http:statuscode:`409 Conflict`: 21 The deposit operation has either failed because a coin has insufficient 22 residual value, or because the same public key of the coin has been 23 previously used with a different denomination, or because a purse with 24 the same public key but different meta data was created previously. 25 Which case it is 26 can be decided by looking at the error code 27 (``TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS`` or 28 ``TALER_EC_EXCHANGE_GENERIC_COIN_CONFLICTING_DENOMINATION_KEY`` or 29 ``TALER_EC_EXCHANGE_PURSE_CREATE_CONFLICTING_META_DATA`` or 30 ``TALER_EC_EXCHANGE_PURSE_DEPOSIT_CONFLICTING_META_DATA`` or 31 ``TALER_EC_EXCHANGE_PURSE_ECONTRACT_CONFLICTING_META_DATA``). 32 The specific fields of the response depend on the error code 33 and include the signatures (and what was signed over) proving the 34 conflict. 35 :http:statuscode:`425 Too Early`: 36 This response type is used if the given purse expiration time 37 is too far in the future (at least from the perspective 38 of the exchange). Thus, retrying at a later time may 39 succeed. The client should look at the ``Date:`` header 40 of the response to see if a minor time difference is to 41 blame and possibly adjust the request accordingly. 42 (Note: this status code is not yet used.) 43 44 45 **Details:** 46 47 .. ts:def:: PurseCreate 48 49 interface PurseCreate { 50 51 // Total value of the purse, excluding fees. 52 amount: Amount; 53 54 // Minimum age required for all coins deposited into the purse. 55 min_age: Integer; 56 57 // Optional encrypted contract, in case the buyer is 58 // proposing the contract and thus establishing the 59 // purse with the payment. 60 econtract?: EncryptedContract; 61 62 // EdDSA public key used to approve merges of this purse. 63 merge_pub: EddsaPublicKey; 64 65 // EdDSA signature of the purse over a 66 // `TALER_PurseRequestSignaturePS` 67 // of purpose ``TALER_SIGNATURE_WALLET_PURSE_CREATE`` 68 // confirming the key 69 // invariants associated with the purse. 70 // (amount, h_contract_terms, expiration). 71 purse_sig: EddsaSignature; 72 73 // SHA-512 hash of the contact of the purse. 74 h_contract_terms: HashCode; 75 76 // Array of coins being deposited into the purse. 77 // Maximum length is 128. 78 deposits: PurseDeposit[]; 79 80 // Indicative time by which the purse should expire 81 // if it has not been merged into an account. At this 82 // point, all of the deposits made will be auto-refunded. 83 purse_expiration: Timestamp; 84 85 } 86 87 .. ts:def:: EncryptedContract 88 89 interface EncryptedContract { 90 91 // Encrypted contract. 92 econtract: string; 93 94 // Signature over the (encrypted) contract. 95 econtract_sig: EddsaSignature; 96 97 // Ephemeral public key for the DH operation to decrypt the encrypted contract. 98 contract_pub: EddsaPublicKey; 99 100 } 101 102 .. ts:def:: PurseCreateSuccessResponse 103 104 interface PurseCreateSuccessResponse { 105 106 // Total amount deposited into the purse so far (without fees). 107 total_deposited: Amount; 108 109 // Time at the exchange. 110 exchange_timestamp: Timestamp; 111 112 // EdDSA signature of the exchange affirming the payment, 113 // of purpose ``TALER_SIGNATURE_PURSE_DEPOSIT_CONFIRMED`` 114 // over a `TALER_PurseDepositConfirmedSignaturePS`. 115 // Signs over the above and the purse public key and 116 // the hash of the contract terms. 117 exchange_sig: EddsaSignature; 118 119 // public key used to create the signature. 120 exchange_pub: EddsaPublicKey; 121 122 } 123 124 .. ts:def:: PurseConflict 125 126 // Union discriminated by the "code" field. 127 type PurseConflict = 128 | DepositDoubleSpendError 129 | PurseCreateConflict 130 | PurseDepositConflict 131 | PurseContractConflict; 132 133 .. ts:def:: PurseCreateConflict 134 135 interface PurseCreateConflict { 136 // Must be equal to TALER_EC_EXCHANGE_PURSE_CREATE_CONFLICTING_META_DATA 137 code: Integer; 138 139 // Total amount to be merged into the reserve. 140 // (excludes fees). 141 amount: Amount; 142 143 // Minimum age required for all coins deposited into the purse. 144 min_age: Integer; 145 146 // Indicative time by which the purse should expire 147 // if it has not been merged into an account. At this 148 // point, all of the deposits made should be 149 // auto-refunded. 150 purse_expiration: Timestamp; 151 152 // EdDSA signature of the purse over 153 // `TALER_PurseMergeSignaturePS` of 154 // purpose ``TALER_SIGNATURE_WALLET_PURSE_MERGE`` 155 // confirming that the 156 // above details hold for this purse. 157 purse_sig: EddsaSignature; 158 159 // SHA-512 hash of the contact of the purse. 160 h_contract_terms: HashCode; 161 162 // EdDSA public key used to approve merges of this purse. 163 merge_pub: EddsaPublicKey; 164 } 165 166 .. ts:def:: PurseDepositConflict 167 168 interface PurseDepositConflict { 169 // Must be equal to TALER_EC_EXCHANGE_PURSE_DEPOSIT_CONFLICTING_META_DATA 170 code: Integer; 171 172 // Public key of the coin being deposited into the purse. 173 coin_pub: EddsaPublicKey; 174 175 // Signature over `TALER_PurseDepositSignaturePS` 176 // of purpose ``TALER_SIGNATURE_WALLET_PURSE_DEPOSIT`` 177 // made by the customer with the 178 // `coin's private key <coin-priv>`. 179 coin_sig: EddsaSignature; 180 181 // Target exchange URL for the purse. Not present for the 182 // same exchange. 183 partner_url?: string; 184 185 // Amount to be contributed to the purse by this coin. 186 amount: Amount; 187 188 } 189 190 .. ts:def:: PurseContractConflict 191 192 interface PurseContractConflict { 193 // Must be equal to TALER_EC_EXCHANGE_PURSE_ECONTRACT_CONFLICTING_META_DATA 194 code: Integer; 195 196 // Hash of the encrypted contract. 197 h_econtract: HashCode; 198 199 // Signature over the contract. 200 econtract_sig: EddsaSignature; 201 202 // Ephemeral public key for the DH operation to decrypt the contract. 203 contract_pub: EddsaPublicKey; 204 205 }