template for /refresh/payback

This commit is contained in:
Christian Grothoff 2019-06-26 19:14:02 +02:00
parent 0be3dd4711
commit 35fe98a165
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
5 changed files with 133 additions and 18 deletions

View File

@ -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 \

View File

@ -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 },

View File

@ -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,

View File

@ -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 <http://www.gnu.org/licenses/>
*/
/**
* @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 <gnunet/gnunet_util_lib.h>
#include <jansson.h>
#include <microhttpd.h>
#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 */

View File

@ -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 <http://www.gnu.org/licenses/>
*/
/**
* @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 <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
#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