From 1be14a34161cd04c61f6df506bead0d8ca64b76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Tue, 27 Jun 2023 09:48:51 +0200 Subject: [age-withdraw] added handlers for age-withdraw to router --- src/exchange/taler-exchange-httpd.c | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 348967f77..25af862b6 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -30,6 +30,8 @@ #include "taler_kyclogic_lib.h" #include "taler_templating_lib.h" #include "taler_mhd_lib.h" +#include "taler-exchange-httpd_age-withdraw.h" +#include "taler-exchange-httpd_age-withdraw_reveal.h" #include "taler-exchange-httpd_aml-decision.h" #include "taler-exchange-httpd_auditors.h" #include "taler-exchange-httpd_batch-deposit.h" @@ -571,6 +573,46 @@ handle_get_aml (struct TEH_RequestContext *rc, } +/** + * Handle a "/age-withdraw/$ACH/reveal" POST request. Parses the "ACH" + * hash of the commitment from a previous call to + * /reserves/$reserve_pub/age-withdraw + * + * @param rc request context + * @param root uploaded JSON data + * @param args array of additional options + * @return MHD result code + */ +static MHD_RESULT +handle_post_age_withdraw (struct TEH_RequestContext *rc, + const json_t *root, + const char *const args[2]) +{ + struct TALER_AgeWithdrawCommitmentHashP ach; + + if (0 != strcmp ("reveal", args[1])) + return r404 (rc->connection, + args[1]); + + if (GNUNET_OK != + GNUNET_STRINGS_string_to_data (args[0], + strlen (args[0]), + &ach, + sizeof (ach))) + { + GNUNET_break_op (0); + return TALER_MHD_reply_with_error (rc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_RESERVE_PUB_MALFORMED, + args[0]); + } + + return TEH_handler_age_withdraw_reveal (rc, + &ach, + root); +} + + /** * Signature of functions that handle operations on reserves. * @@ -617,6 +659,10 @@ handle_post_reserves (struct TEH_RequestContext *rc, .op = "batch-withdraw", .handler = &TEH_handler_batch_withdraw }, + { + .op = "age-withdraw", + .handler = &TEH_handler_age_withdraw + }, { .op = "withdraw", .handler = &TEH_handler_withdraw @@ -1454,6 +1500,12 @@ handle_mhd_request (void *cls, .handler.post = &handle_post_reserves, .nargs = 2 }, + { + .url = "age-withdraw", + .method = MHD_HTTP_METHOD_POST, + .handler.post = &handle_post_age_withdraw, + .nargs = 2 + }, { .url = "reserves-attest", .method = MHD_HTTP_METHOD_GET, -- cgit v1.2.3