aboutsummaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_withdraw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange/taler-exchange-httpd_withdraw.c')
-rw-r--r--src/exchange/taler-exchange-httpd_withdraw.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c
index 7be560847..7d10bb8e7 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -316,24 +316,8 @@ withdraw_transaction (void *cls,
316} 316}
317 317
318 318
319/**
320 * Handle a "/reserves/$RESERVE_PUB/withdraw" request. Parses the
321 * "reserve_pub" EdDSA key of the reserve and the requested "denom_pub" which
322 * specifies the key/value of the coin to be withdrawn, and checks that the
323 * signature "reserve_sig" makes this a valid withdrawal request from the
324 * specified reserve. If so, the envelope with the blinded coin "coin_ev" is
325 * passed down to execute the withdrawal operation.
326 *
327 * @param rh context of the handler
328 * @param connection the MHD connection to handle
329 * @param root uploaded JSON data
330 * @param args array of additional options (first must be the
331 * reserve public key, the second one should be "withdraw")
332 * @return MHD result code
333 */
334MHD_RESULT 319MHD_RESULT
335TEH_handler_withdraw (const struct TEH_RequestHandler *rh, 320TEH_handler_withdraw (struct TEH_RequestContext *rc,
336 struct MHD_Connection *connection,
337 const json_t *root, 321 const json_t *root,
338 const char *const args[2]) 322 const char *const args[2])
339{ 323{
@@ -351,7 +335,6 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
351 enum TALER_ErrorCode ec; 335 enum TALER_ErrorCode ec;
352 struct TEH_DenominationKey *dk; 336 struct TEH_DenominationKey *dk;
353 337
354 (void) rh;
355 if (GNUNET_OK != 338 if (GNUNET_OK !=
356 GNUNET_STRINGS_string_to_data (args[0], 339 GNUNET_STRINGS_string_to_data (args[0],
357 strlen (args[0]), 340 strlen (args[0]),
@@ -359,7 +342,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
359 sizeof (wc.wsrd.reserve_pub))) 342 sizeof (wc.wsrd.reserve_pub)))
360 { 343 {
361 GNUNET_break_op (0); 344 GNUNET_break_op (0);
362 return TALER_MHD_reply_with_error (connection, 345 return TALER_MHD_reply_with_error (rc->connection,
363 MHD_HTTP_BAD_REQUEST, 346 MHD_HTTP_BAD_REQUEST,
364 TALER_EC_MERCHANT_GENERIC_RESERVE_PUB_MALFORMED, 347 TALER_EC_MERCHANT_GENERIC_RESERVE_PUB_MALFORMED,
365 args[0]); 348 args[0]);
@@ -368,7 +351,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
368 { 351 {
369 enum GNUNET_GenericReturnValue res; 352 enum GNUNET_GenericReturnValue res;
370 353
371 res = TALER_MHD_parse_json_data (connection, 354 res = TALER_MHD_parse_json_data (rc->connection,
372 root, 355 root,
373 spec); 356 spec);
374 if (GNUNET_OK != res) 357 if (GNUNET_OK != res)
@@ -379,7 +362,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
379 struct GNUNET_TIME_Absolute now; 362 struct GNUNET_TIME_Absolute now;
380 363
381 dk = TEH_keys_denomination_by_hash (&wc.denom_pub_hash, 364 dk = TEH_keys_denomination_by_hash (&wc.denom_pub_hash,
382 connection, 365 rc->connection,
383 &mret); 366 &mret);
384 if (NULL == dk) 367 if (NULL == dk)
385 { 368 {
@@ -397,7 +380,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
397 /* This denomination is past the expiration time for withdraws */ 380 /* This denomination is past the expiration time for withdraws */
398 GNUNET_JSON_parse_free (spec); 381 GNUNET_JSON_parse_free (spec);
399 return TEH_RESPONSE_reply_expired_denom_pub_hash ( 382 return TEH_RESPONSE_reply_expired_denom_pub_hash (
400 connection, 383 rc->connection,
401 &wc.denom_pub_hash, 384 &wc.denom_pub_hash,
402 now, 385 now,
403 TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED, 386 TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED,
@@ -412,7 +395,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
412 /* This denomination is not yet valid */ 395 /* This denomination is not yet valid */
413 GNUNET_JSON_parse_free (spec); 396 GNUNET_JSON_parse_free (spec);
414 return TEH_RESPONSE_reply_expired_denom_pub_hash ( 397 return TEH_RESPONSE_reply_expired_denom_pub_hash (
415 connection, 398 rc->connection,
416 &wc.denom_pub_hash, 399 &wc.denom_pub_hash,
417 now, 400 now,
418 TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE, 401 TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE,
@@ -427,7 +410,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
427 /* This denomination has been revoked */ 410 /* This denomination has been revoked */
428 GNUNET_JSON_parse_free (spec); 411 GNUNET_JSON_parse_free (spec);
429 return TEH_RESPONSE_reply_expired_denom_pub_hash ( 412 return TEH_RESPONSE_reply_expired_denom_pub_hash (
430 connection, 413 rc->connection,
431 &wc.denom_pub_hash, 414 &wc.denom_pub_hash,
432 now, 415 now,
433 TALER_EC_EXCHANGE_GENERIC_DENOMINATION_REVOKED, 416 TALER_EC_EXCHANGE_GENERIC_DENOMINATION_REVOKED,
@@ -442,7 +425,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
442 &dk->meta.fee_withdraw)) 425 &dk->meta.fee_withdraw))
443 { 426 {
444 GNUNET_JSON_parse_free (spec); 427 GNUNET_JSON_parse_free (spec);
445 return TALER_MHD_reply_with_error (connection, 428 return TALER_MHD_reply_with_error (rc->connection,
446 MHD_HTTP_INTERNAL_SERVER_ERROR, 429 MHD_HTTP_INTERNAL_SERVER_ERROR,
447 TALER_EC_EXCHANGE_WITHDRAW_AMOUNT_FEE_OVERFLOW, 430 TALER_EC_EXCHANGE_WITHDRAW_AMOUNT_FEE_OVERFLOW,
448 NULL); 431 NULL);
@@ -470,7 +453,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
470 TALER_LOG_WARNING ( 453 TALER_LOG_WARNING (
471 "Client supplied invalid signature for withdraw request\n"); 454 "Client supplied invalid signature for withdraw request\n");
472 GNUNET_JSON_parse_free (spec); 455 GNUNET_JSON_parse_free (spec);
473 return TALER_MHD_reply_with_error (connection, 456 return TALER_MHD_reply_with_error (rc->connection,
474 MHD_HTTP_FORBIDDEN, 457 MHD_HTTP_FORBIDDEN,
475 TALER_EC_EXCHANGE_WITHDRAW_RESERVE_SIGNATURE_INVALID, 458 TALER_EC_EXCHANGE_WITHDRAW_RESERVE_SIGNATURE_INVALID,
476 NULL); 459 NULL);
@@ -487,7 +470,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
487 { 470 {
488 GNUNET_break (0); 471 GNUNET_break (0);
489 GNUNET_JSON_parse_free (spec); 472 GNUNET_JSON_parse_free (spec);
490 return TALER_MHD_reply_with_ec (connection, 473 return TALER_MHD_reply_with_ec (rc->connection,
491 ec, 474 ec,
492 NULL); 475 NULL);
493 } 476 }
@@ -498,7 +481,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
498 MHD_RESULT mhd_ret; 481 MHD_RESULT mhd_ret;
499 482
500 if (GNUNET_OK != 483 if (GNUNET_OK !=
501 TEH_DB_run_transaction (connection, 484 TEH_DB_run_transaction (rc->connection,
502 "run withdraw", 485 "run withdraw",
503 &mhd_ret, 486 &mhd_ret,
504 &withdraw_transaction, 487 &withdraw_transaction,
@@ -520,7 +503,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
520 MHD_RESULT ret; 503 MHD_RESULT ret;
521 504
522 ret = TALER_MHD_REPLY_JSON_PACK ( 505 ret = TALER_MHD_REPLY_JSON_PACK (
523 connection, 506 rc->connection,
524 MHD_HTTP_OK, 507 MHD_HTTP_OK,
525 GNUNET_JSON_pack_rsa_signature ("ev_sig", 508 GNUNET_JSON_pack_rsa_signature ("ev_sig",
526 wc.collectable.sig.rsa_signature)); 509 wc.collectable.sig.rsa_signature));