diff options
Diffstat (limited to 'src/lib/exchange_api_deposits_get.c')
-rw-r--r-- | src/lib/exchange_api_deposits_get.c | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c index aecd88240..6a2ad5c3d 100644 --- a/src/lib/exchange_api_deposits_get.c +++ b/src/lib/exchange_api_deposits_get.c | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | 34 | ||
35 | /** | 35 | /** |
36 | * @brief A Deposit Wtid Handle | 36 | * @brief A Deposit Get Handle |
37 | */ | 37 | */ |
38 | struct TALER_EXCHANGE_DepositGetHandle | 38 | struct TALER_EXCHANGE_DepositGetHandle |
39 | { | 39 | { |
@@ -84,31 +84,19 @@ struct TALER_EXCHANGE_DepositGetHandle | |||
84 | * | 84 | * |
85 | * @param dwh deposit wtid handle | 85 | * @param dwh deposit wtid handle |
86 | * @param json json reply with the signature | 86 | * @param json json reply with the signature |
87 | * @param[out] exchange_pub set to the exchange's public key | 87 | * @param exchange_pub the exchange's public key |
88 | * @param exchange_sig the exchange's signature | ||
88 | * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not | 89 | * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not |
89 | */ | 90 | */ |
90 | static int | 91 | static int |
91 | verify_deposit_wtid_signature_ok ( | 92 | verify_deposit_wtid_signature_ok ( |
92 | const struct TALER_EXCHANGE_DepositGetHandle *dwh, | 93 | const struct TALER_EXCHANGE_DepositGetHandle *dwh, |
93 | const json_t *json, | 94 | const json_t *json, |
94 | struct TALER_ExchangePublicKeyP *exchange_pub) | 95 | const struct TALER_ExchangePublicKeyP *exchange_pub, |
96 | const struct TALER_ExchangeSignatureP *exchange_sig) | ||
95 | { | 97 | { |
96 | struct TALER_ExchangeSignatureP exchange_sig; | ||
97 | const struct TALER_EXCHANGE_Keys *key_state; | 98 | const struct TALER_EXCHANGE_Keys *key_state; |
98 | struct GNUNET_JSON_Specification spec[] = { | ||
99 | GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig), | ||
100 | GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub), | ||
101 | GNUNET_JSON_spec_end () | ||
102 | }; | ||
103 | 99 | ||
104 | if (GNUNET_OK != | ||
105 | GNUNET_JSON_parse (json, | ||
106 | spec, | ||
107 | NULL, NULL)) | ||
108 | { | ||
109 | GNUNET_break_op (0); | ||
110 | return GNUNET_SYSERR; | ||
111 | } | ||
112 | key_state = TALER_EXCHANGE_get_keys (dwh->exchange); | 100 | key_state = TALER_EXCHANGE_get_keys (dwh->exchange); |
113 | if (GNUNET_OK != | 101 | if (GNUNET_OK != |
114 | TALER_EXCHANGE_test_signing_key (key_state, | 102 | TALER_EXCHANGE_test_signing_key (key_state, |
@@ -120,7 +108,7 @@ verify_deposit_wtid_signature_ok ( | |||
120 | if (GNUNET_OK != | 108 | if (GNUNET_OK != |
121 | GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE, | 109 | GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE, |
122 | &dwh->depconf, | 110 | &dwh->depconf, |
123 | &exchange_sig.eddsa_signature, | 111 | &exchange_sig->eddsa_signature, |
124 | &exchange_pub->eddsa_pub)) | 112 | &exchange_pub->eddsa_pub)) |
125 | { | 113 | { |
126 | GNUNET_break_op (0); | 114 | GNUNET_break_op (0); |
@@ -144,12 +132,6 @@ handle_deposit_wtid_finished (void *cls, | |||
144 | const void *response) | 132 | const void *response) |
145 | { | 133 | { |
146 | struct TALER_EXCHANGE_DepositGetHandle *dwh = cls; | 134 | struct TALER_EXCHANGE_DepositGetHandle *dwh = cls; |
147 | const struct TALER_WireTransferIdentifierRawP *wtid = NULL; | ||
148 | struct GNUNET_TIME_Absolute execution_time = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
149 | const struct TALER_Amount *coin_contribution = NULL; | ||
150 | struct TALER_Amount coin_contribution_s; | ||
151 | struct TALER_ExchangePublicKeyP exchange_pub; | ||
152 | struct TALER_ExchangePublicKeyP *ep = NULL; | ||
153 | const json_t *j = response; | 135 | const json_t *j = response; |
154 | struct TALER_EXCHANGE_HttpResponse hr = { | 136 | struct TALER_EXCHANGE_HttpResponse hr = { |
155 | .reply = j, | 137 | .reply = j, |
@@ -164,10 +146,16 @@ handle_deposit_wtid_finished (void *cls, | |||
164 | break; | 146 | break; |
165 | case MHD_HTTP_OK: | 147 | case MHD_HTTP_OK: |
166 | { | 148 | { |
149 | struct GNUNET_TIME_Absolute execution_time; | ||
150 | struct TALER_Amount coin_contribution; | ||
151 | struct TALER_ExchangePublicKeyP exchange_pub; | ||
152 | struct TALER_ExchangeSignatureP exchange_sig; | ||
167 | struct GNUNET_JSON_Specification spec[] = { | 153 | struct GNUNET_JSON_Specification spec[] = { |
168 | GNUNET_JSON_spec_fixed_auto ("wtid", &dwh->depconf.wtid), | 154 | GNUNET_JSON_spec_fixed_auto ("wtid", &dwh->depconf.wtid), |
169 | GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time), | 155 | GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time), |
170 | TALER_JSON_spec_amount ("coin_contribution", &coin_contribution_s), | 156 | TALER_JSON_spec_amount ("coin_contribution", &coin_contribution), |
157 | GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig), | ||
158 | GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub), | ||
171 | GNUNET_JSON_spec_end () | 159 | GNUNET_JSON_spec_end () |
172 | }; | 160 | }; |
173 | 161 | ||
@@ -181,15 +169,14 @@ handle_deposit_wtid_finished (void *cls, | |||
181 | hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE; | 169 | hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE; |
182 | break; | 170 | break; |
183 | } | 171 | } |
184 | wtid = &dwh->depconf.wtid; | ||
185 | dwh->depconf.execution_time = GNUNET_TIME_absolute_hton (execution_time); | 172 | dwh->depconf.execution_time = GNUNET_TIME_absolute_hton (execution_time); |
186 | TALER_amount_hton (&dwh->depconf.coin_contribution, | 173 | TALER_amount_hton (&dwh->depconf.coin_contribution, |
187 | &coin_contribution_s); | 174 | &coin_contribution); |
188 | coin_contribution = &coin_contribution_s; | ||
189 | if (GNUNET_OK != | 175 | if (GNUNET_OK != |
190 | verify_deposit_wtid_signature_ok (dwh, | 176 | verify_deposit_wtid_signature_ok (dwh, |
191 | j, | 177 | j, |
192 | &exchange_pub)) | 178 | &exchange_pub, |
179 | &exchange_sig)) | ||
193 | { | 180 | { |
194 | GNUNET_break_op (0); | 181 | GNUNET_break_op (0); |
195 | hr.http_status = 0; | 182 | hr.http_status = 0; |
@@ -197,13 +184,26 @@ handle_deposit_wtid_finished (void *cls, | |||
197 | } | 184 | } |
198 | else | 185 | else |
199 | { | 186 | { |
200 | ep = &exchange_pub; | 187 | struct TALER_EXCHANGE_DepositData dd = { |
188 | .exchange_pub = &exchange_pub, | ||
189 | .exchange_sig = &exchange_sig, | ||
190 | .wtid = &dwh->depconf.wtid, | ||
191 | .execution_time = execution_time, | ||
192 | .coin_contribution = &coin_contribution | ||
193 | }; | ||
194 | |||
195 | dwh->cb (dwh->cb_cls, | ||
196 | &hr, | ||
197 | &dd); | ||
198 | TALER_EXCHANGE_deposits_get_cancel (dwh); | ||
199 | return; | ||
201 | } | 200 | } |
202 | } | 201 | } |
203 | break; | 202 | break; |
204 | case MHD_HTTP_ACCEPTED: | 203 | case MHD_HTTP_ACCEPTED: |
205 | { | 204 | { |
206 | /* Transaction known, but not executed yet */ | 205 | /* Transaction known, but not executed yet */ |
206 | struct GNUNET_TIME_Absolute execution_time; | ||
207 | struct GNUNET_JSON_Specification spec[] = { | 207 | struct GNUNET_JSON_Specification spec[] = { |
208 | GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time), | 208 | GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time), |
209 | GNUNET_JSON_spec_end () | 209 | GNUNET_JSON_spec_end () |
@@ -219,6 +219,18 @@ handle_deposit_wtid_finished (void *cls, | |||
219 | hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE; | 219 | hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE; |
220 | break; | 220 | break; |
221 | } | 221 | } |
222 | else | ||
223 | { | ||
224 | struct TALER_EXCHANGE_DepositData dd = { | ||
225 | .execution_time = execution_time | ||
226 | }; | ||
227 | |||
228 | dwh->cb (dwh->cb_cls, | ||
229 | &hr, | ||
230 | &dd); | ||
231 | TALER_EXCHANGE_deposits_get_cancel (dwh); | ||
232 | return; | ||
233 | } | ||
222 | } | 234 | } |
223 | break; | 235 | break; |
224 | case MHD_HTTP_BAD_REQUEST: | 236 | case MHD_HTTP_BAD_REQUEST: |
@@ -259,10 +271,7 @@ handle_deposit_wtid_finished (void *cls, | |||
259 | } | 271 | } |
260 | dwh->cb (dwh->cb_cls, | 272 | dwh->cb (dwh->cb_cls, |
261 | &hr, | 273 | &hr, |
262 | ep, | 274 | NULL); |
263 | wtid, | ||
264 | execution_time, | ||
265 | coin_contribution); | ||
266 | TALER_EXCHANGE_deposits_get_cancel (dwh); | 275 | TALER_EXCHANGE_deposits_get_cancel (dwh); |
267 | } | 276 | } |
268 | 277 | ||