aboutsummaryrefslogtreecommitdiff
path: root/src/mint
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-11-24 14:48:35 +0100
committerChristian Grothoff <christian@grothoff.org>2015-11-24 14:48:35 +0100
commit4c80119b30c4a9946cb4bfb05363c543ba955bb6 (patch)
treeea71d9658f205917ba500786288dfdb65def4034 /src/mint
parent3961d3df7edfc710223b75cfa2756703a8c74db9 (diff)
parent1ca54c5df12dc7fd5e9891b64d3e8eb61848e08e (diff)
Merge branch 'master' of git+ssh://taler.net/var/git/mint
Diffstat (limited to 'src/mint')
-rw-r--r--src/mint/Makefile.am3
-rw-r--r--src/mint/taler-mint-httpd.c14
-rw-r--r--src/mint/taler-mint-httpd_responses.c41
-rw-r--r--src/mint/taler-mint-httpd_tracking.c75
-rw-r--r--src/mint/taler-mint-httpd_tracking.h65
5 files changed, 177 insertions, 21 deletions
diff --git a/src/mint/Makefile.am b/src/mint/Makefile.am
index 1c7e1ca87..a115d63a0 100644
--- a/src/mint/Makefile.am
+++ b/src/mint/Makefile.am
@@ -19,6 +19,7 @@ taler_mint_httpd_SOURCES = \
taler-mint-httpd_admin.c taler-mint-httpd_admin.h \
taler-mint-httpd_deposit.c taler-mint-httpd_deposit.h \
taler-mint-httpd_reserve.c taler-mint-httpd_reserve.h \
+ taler-mint-httpd_tracking.c taler-mint-httpd_tracking.h \
taler-mint-httpd_wire.c taler-mint-httpd_wire.h \
taler-mint-httpd_refresh.c taler-mint-httpd_refresh.h
taler_mint_httpd_LDADD = \
@@ -36,7 +37,7 @@ taler_mint_httpd_SOURCES += \
endif
check_SCRIPTS = \
- test_taler_mint_httpd.sh
+ test_taler_mint_httpd.sh
if HAVE_EXPENSIVE_TESTS
check_SCRIPTS += \
diff --git a/src/mint/taler-mint-httpd.c b/src/mint/taler-mint-httpd.c
index b55004d91..26a440c95 100644
--- a/src/mint/taler-mint-httpd.c
+++ b/src/mint/taler-mint-httpd.c
@@ -33,6 +33,7 @@
#include "taler-mint-httpd_reserve.h"
#include "taler-mint-httpd_wire.h"
#include "taler-mint-httpd_refresh.h"
+#include "taler-mint-httpd_tracking.h"
#include "taler-mint-httpd_keystate.h"
#if HAVE_DEVELOPER
#include "taler-mint-httpd_test.h"
@@ -256,6 +257,19 @@ handle_mhd_request (void *cls,
"Only POST is allowed", 0,
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
+ { "/wire/deposits", MHD_HTTP_METHOD_GET, "application/json",
+ NULL, 0,
+ &TMH_TRACKING_handler_wire_deposits, MHD_HTTP_OK },
+ { "/wire/deposits", NULL, "text/plain",
+ "Only GET is allowed", 0,
+ &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
+ { "/deposit/wtid", MHD_HTTP_METHOD_POST, "application/json",
+ NULL, 0,
+ &TMH_TRACKING_handler_deposit_wtid, MHD_HTTP_OK },
+ { "/deposit/wtid", NULL, "text/plain",
+ "Only POST is allowed", 0,
+ &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
+
#if HAVE_DEVELOPER
/* Client crypto-interoperability test functions */
{ "/test", MHD_HTTP_METHOD_POST, "application/json",
diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c
index a018f68d3..3b04fdb3c 100644
--- a/src/mint/taler-mint-httpd_responses.c
+++ b/src/mint/taler-mint-httpd_responses.c
@@ -404,10 +404,11 @@ TMH_RESPONSE_reply_deposit_success (struct MHD_Connection *connection,
static json_t *
compile_transaction_history (const struct TALER_MINTDB_TransactionList *tl)
{
- json_t *transaction;
+ json_t *details;
const char *type;
struct TALER_Amount value;
json_t *history;
+ const struct TALER_CoinSpendSignatureP *sig;
const struct TALER_MINTDB_TransactionList *pos;
history = json_array ();
@@ -420,7 +421,7 @@ compile_transaction_history (const struct TALER_MINTDB_TransactionList *tl)
struct TALER_DepositRequestPS dr;
const struct TALER_MINTDB_Deposit *deposit = pos->details.deposit;
- type = "deposit";
+ type = "DEPOSIT";
value = deposit->amount_with_fee;
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
@@ -435,12 +436,12 @@ compile_transaction_history (const struct TALER_MINTDB_TransactionList *tl)
&deposit->deposit_fee);
dr.merchant = deposit->merchant_pub;
dr.coin_pub = deposit->coin.coin_pub;
-
+ sig = &deposit->csig;
/* internal sanity check before we hand out a bogus sig... */
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_DEPOSIT,
&dr.purpose,
- &deposit->csig.eddsa_signature,
+ &sig->eddsa_signature,
&deposit->coin.coin_pub.eddsa_pub))
{
GNUNET_break (0);
@@ -448,8 +449,8 @@ compile_transaction_history (const struct TALER_MINTDB_TransactionList *tl)
return NULL;
}
- transaction = TALER_json_from_eddsa_sig (&dr.purpose,
- &deposit->csig.eddsa_signature);
+ details = TALER_json_from_data (&dr.purpose,
+ sizeof (struct TALER_DepositRequestPS));
break;
}
case TALER_MINTDB_TT_REFRESH_MELT:
@@ -457,7 +458,7 @@ compile_transaction_history (const struct TALER_MINTDB_TransactionList *tl)
struct TALER_RefreshMeltCoinAffirmationPS ms;
const struct TALER_MINTDB_RefreshMelt *melt = pos->details.melt;
- type = "melt";
+ type = "MELT";
value = melt->amount_with_fee;
ms.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT);
ms.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS));
@@ -467,12 +468,12 @@ compile_transaction_history (const struct TALER_MINTDB_TransactionList *tl)
TALER_amount_hton (&ms.melt_fee,
&melt->melt_fee);
ms.coin_pub = melt->coin.coin_pub;
-
+ sig = &melt->coin_sig;
/* internal sanity check before we hand out a bogus sig... */
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT,
&ms.purpose,
- &melt->coin_sig.eddsa_signature,
+ &sig->eddsa_signature,
&melt->coin.coin_pub.eddsa_pub))
{
GNUNET_break (0);
@@ -480,18 +481,20 @@ compile_transaction_history (const struct TALER_MINTDB_TransactionList *tl)
return NULL;
}
- transaction = TALER_json_from_eddsa_sig (&ms.purpose,
- &melt->coin_sig.eddsa_signature);
+ details = TALER_json_from_data (&ms.purpose,
+ sizeof (struct TALER_RefreshMeltCoinAffirmationPS));
}
break;
default:
GNUNET_assert (0);
}
json_array_append_new (history,
- json_pack ("{s:s, s:o, s:o}",
+ json_pack ("{s:s, s:o, s:o, s:o}",
"type", type,
"amount", TALER_json_from_amount (&value),
- "signature", transaction));
+ "signature", TALER_json_from_data (sig,
+ sizeof (struct TALER_CoinSpendSignatureP)),
+ "details", details));
}
return history;
}
@@ -539,7 +542,6 @@ compile_reserve_history (const struct TALER_MINTDB_ReserveHistory *rh,
struct TALER_Amount withdraw_total;
struct TALER_Amount value;
json_t *json_history;
- json_t *transaction;
int ret;
const struct TALER_MINTDB_ReserveHistory *pos;
struct TALER_WithdrawRequestPS wr;
@@ -609,14 +611,13 @@ compile_reserve_history (const struct TALER_MINTDB_ReserveHistory *rh,
GNUNET_CRYPTO_rsa_public_key_hash (pos->details.withdraw->denom_pub.rsa_public_key,
&wr.h_denomination_pub);
wr.h_coin_envelope = pos->details.withdraw->h_coin_envelope;
-
- transaction = TALER_json_from_eddsa_sig (&wr.purpose,
- &pos->details.withdraw->reserve_sig.eddsa_signature);
-
json_array_append_new (json_history,
- json_pack ("{s:s, s:o, s:o}",
+ json_pack ("{s:s, s:o, s:o, s:o}",
"type", "WITHDRAW",
- "signature", transaction,
+ "signature", TALER_json_from_data (&pos->details.withdraw->reserve_sig,
+ sizeof (struct TALER_ReserveSignatureP)),
+ "details", TALER_json_from_data (&wr,
+ sizeof (wr)),
"amount", TALER_json_from_amount (&value)));
break;
}
diff --git a/src/mint/taler-mint-httpd_tracking.c b/src/mint/taler-mint-httpd_tracking.c
new file mode 100644
index 000000000..beb4b4dd1
--- /dev/null
+++ b/src/mint/taler-mint-httpd_tracking.c
@@ -0,0 +1,75 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014, 2015 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
+ 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, If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler-mint-httpd_tracking.c
+ * @brief Handle wire transfer tracking-related requests
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <jansson.h>
+#include <microhttpd.h>
+#include <pthread.h>
+#include "taler-mint-httpd_parsing.h"
+#include "taler-mint-httpd_tracking.h"
+#include "taler-mint-httpd_responses.h"
+
+
+/**
+ * Handle a "/wire/deposits" 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
+TMH_TRACKING_handler_wire_deposits (struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size)
+{
+ GNUNET_break (0); // not implemented
+ return MHD_NO;
+}
+
+
+/**
+ * Handle a "/deposit/wtid" 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
+TMH_TRACKING_handler_deposit_wtid (struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size)
+{
+ GNUNET_break (0); // not implemented
+ return MHD_NO;
+}
+
+
+/* end of taler-mint-httpd_tracking.c */
diff --git a/src/mint/taler-mint-httpd_tracking.h b/src/mint/taler-mint-httpd_tracking.h
new file mode 100644
index 000000000..9ec4c6827
--- /dev/null
+++ b/src/mint/taler-mint-httpd_tracking.h
@@ -0,0 +1,65 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014, 2015 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
+ 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, If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler-mint-httpd_tracking.h
+ * @brief Handle wire transfer tracking-related requests
+ * @author Christian Grothoff
+ */
+#ifndef TALER_MINT_HTTPD_TRACKING_H
+#define TALER_MINT_HTTPD_TRACKING_H
+
+#include <gnunet/gnunet_util_lib.h>
+#include <microhttpd.h>
+#include "taler-mint-httpd.h"
+
+
+/**
+ * Handle a "/wire/deposits" 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
+TMH_TRACKING_handler_wire_deposits (struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size);
+
+
+/**
+ * Handle a "/deposit/wtid" 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
+TMH_TRACKING_handler_deposit_wtid (struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size);
+
+
+#endif