From 35fe98a1657086af959e4512bb79b04e81ed3fc1 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 26 Jun 2019 19:14:02 +0200 Subject: template for /refresh/payback --- src/exchange/Makefile.am | 1 + src/exchange/taler-exchange-httpd.c | 30 +++++++----- src/exchange/taler-exchange-httpd_refresh_melt.c | 14 +++--- .../taler-exchange-httpd_refresh_payback.c | 57 ++++++++++++++++++++++ .../taler-exchange-httpd_refresh_payback.h | 49 +++++++++++++++++++ 5 files changed, 133 insertions(+), 18 deletions(-) create mode 100644 src/exchange/taler-exchange-httpd_refresh_payback.c create mode 100644 src/exchange/taler-exchange-httpd_refresh_payback.h diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am index b5419a7a6..2b5a10e9c 100644 --- a/src/exchange/Makefile.am +++ b/src/exchange/Makefile.am @@ -51,6 +51,7 @@ taler_exchange_httpd_SOURCES = \ taler-exchange-httpd_payback.c taler-exchange-httpd_payback.h \ taler-exchange-httpd_refresh_link.c taler-exchange-httpd_refresh_link.h \ taler-exchange-httpd_refresh_melt.c taler-exchange-httpd_refresh_melt.h \ + taler-exchange-httpd_refresh_payback.c taler-exchange-httpd_refresh_payback.h \ taler-exchange-httpd_refresh_reveal.c taler-exchange-httpd_refresh_reveal.h \ taler-exchange-httpd_refund.c taler-exchange-httpd_refund.h \ taler-exchange-httpd_reserve_status.c taler-exchange-httpd_reserve_status.h \ diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 45e0c764b..734f260ba 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -36,6 +36,7 @@ #include "taler-exchange-httpd_payback.h" #include "taler-exchange-httpd_refresh_link.h" #include "taler-exchange-httpd_refresh_melt.h" +#include "taler-exchange-httpd_refresh_payback.h" #include "taler-exchange-httpd_refresh_reveal.h" #include "taler-exchange-httpd_track_transfer.h" #include "taler-exchange-httpd_track_transaction.h" @@ -317,6 +318,13 @@ handle_mhd_request (void *cls, "Only GET is allowed", 0, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + { "/refresh/payback", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_REFRESH_handler_refresh_payback, MHD_HTTP_OK }, + { "/refresh/payback", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + { "/track/transfer", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, &TEH_TRACKING_handler_track_transfer, MHD_HTTP_OK }, @@ -347,29 +355,29 @@ handle_mhd_request (void *cls, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/test/base32", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_base32, MHD_HTTP_OK }, + NULL, 0, + &TEH_TEST_handler_test_base32, MHD_HTTP_OK }, { "/test/base32", NULL, "text/plain", "Only POST is allowed", 0, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/test/encrypt", MHD_HTTP_METHOD_POST, "application/json", NULL, 0, - &TEH_TEST_handler_test_encrypt, MHD_HTTP_OK }, + &TEH_TEST_handler_test_encrypt, MHD_HTTP_OK }, { "/test/encrypt", NULL, "text/plain", "Only POST is allowed", 0, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/test/hkdf", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_hkdf, MHD_HTTP_OK }, + NULL, 0, + &TEH_TEST_handler_test_hkdf, MHD_HTTP_OK }, { "/test/hkdf", NULL, "text/plain", "Only POST is allowed", 0, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/test/ecdhe", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_ecdhe, MHD_HTTP_OK }, + NULL, 0, + &TEH_TEST_handler_test_ecdhe, MHD_HTTP_OK }, { "/test/ecdhe", NULL, "text/plain", "Only POST is allowed", 0, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, @@ -382,15 +390,15 @@ handle_mhd_request (void *cls, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/test/rsa/get", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_TEST_handler_test_rsa_get, MHD_HTTP_OK }, + NULL, 0, + &TEH_TEST_handler_test_rsa_get, MHD_HTTP_OK }, { "/test/rsa/get", NULL, "text/plain", "Only GET is allowed", 0, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, { "/test/rsa/sign", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_rsa_sign, MHD_HTTP_OK }, + NULL, 0, + &TEH_TEST_handler_test_rsa_sign, MHD_HTTP_OK }, { "/test/rsa/sign", NULL, "text/plain", "Only POST is allowed", 0, &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, diff --git a/src/exchange/taler-exchange-httpd_refresh_melt.c b/src/exchange/taler-exchange-httpd_refresh_melt.c index 1b8e04a07..36ad1a738 100644 --- a/src/exchange/taler-exchange-httpd_refresh_melt.c +++ b/src/exchange/taler-exchange-httpd_refresh_melt.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2017 Inria & GNUnet e.V. + Copyright (C) 2014-2019 Inria & GNUnet e.V. TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -155,8 +155,8 @@ struct RefreshMeltContext static enum GNUNET_DB_QueryStatus refresh_check_melt (struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, - struct RefreshMeltContext *rmc, - int *mhd_ret) + struct RefreshMeltContext *rmc, + int *mhd_ret) { struct TALER_EXCHANGEDB_TransactionList *tl; struct TALER_Amount coin_value; @@ -351,10 +351,10 @@ handle_refresh_melt (struct MHD_Connection *connection, body.coin_pub = rmc->refresh_session.coin.coin_pub; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, - &body.purpose, - &rmc->refresh_session.coin_sig.eddsa_signature, - &rmc->refresh_session.coin.coin_pub.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, + &body.purpose, + &rmc->refresh_session.coin_sig.eddsa_signature, + &rmc->refresh_session.coin.coin_pub.eddsa_pub)) { GNUNET_break_op (0); return TEH_RESPONSE_reply_signature_invalid (connection, diff --git a/src/exchange/taler-exchange-httpd_refresh_payback.c b/src/exchange/taler-exchange-httpd_refresh_payback.c new file mode 100644 index 000000000..3687d19d8 --- /dev/null +++ b/src/exchange/taler-exchange-httpd_refresh_payback.c @@ -0,0 +1,57 @@ +/* + This file is part of TALER + Copyright (C) 2014-2019 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + TALER; see the file COPYING. If not, see +*/ +/** + * @file taler-exchange-httpd_refresh_link.c + * @brief Handle /refresh/link requests + * @author Florian Dold + * @author Benedikt Mueller + * @author Christian Grothoff + */ +#include "platform.h" +#include +#include +#include +#include "taler-exchange-httpd_parsing.h" +#include "taler-exchange-httpd_mhd.h" +#include "taler-exchange-httpd_refresh_payback.h" +#include "taler-exchange-httpd_responses.h" +#include "taler-exchange-httpd_keystate.h" + + +/** + * Handle a "/refresh/payback" request. Parses the request into the JSON + * components and then processes the request. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +int +TEH_REFRESH_handler_refresh_payback (struct TEH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) +{ + GNUNET_break (0); + return MHD_NO; +} + + +/* end of taler-exchange-httpd_refresh_payback.c */ diff --git a/src/exchange/taler-exchange-httpd_refresh_payback.h b/src/exchange/taler-exchange-httpd_refresh_payback.h new file mode 100644 index 000000000..921715c76 --- /dev/null +++ b/src/exchange/taler-exchange-httpd_refresh_payback.h @@ -0,0 +1,49 @@ +/* + This file is part of TALER + Copyright (C) 2014-2019 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + TALER; see the file COPYING. If not, see +*/ +/** + * @file taler-exchange-httpd_refresh_payback.h + * @brief Handle /refresh/payback requests + * @author Florian Dold + * @author Christian Grothoff + */ +#ifndef TALER_EXCHANGE_HTTPD_REFRESH_PAYBACK_H +#define TALER_EXCHANGE_HTTPD_REFRESH_PAYBACK_H + +#include +#include +#include "taler-exchange-httpd.h" + + +/** + * Handle a "/refresh/payback" request. Parses the request into the JSON + * components and then processes the request. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +int +TEH_REFRESH_handler_refresh_payback (struct TEH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); + + +#endif -- cgit v1.2.3