gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] branch master updated: implementing remain


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: implementing remaining /payback responses
Date: Wed, 29 Mar 2017 16:54:23 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new c329b92  implementing remaining /payback responses
c329b92 is described below

commit c329b92ccf1c461e4032e75164b6ffa6bb509a69
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Mar 29 16:57:20 2017 +0200

    implementing remaining /payback responses
---
 src/exchange-lib/exchange_api_payback.c       |  4 +--
 src/exchange/taler-exchange-httpd_db.c        |  1 +
 src/exchange/taler-exchange-httpd_responses.c | 39 ++++++++++++++++++++++-----
 src/exchange/taler-exchange-httpd_responses.h |  7 ++---
 4 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/src/exchange-lib/exchange_api_payback.c 
b/src/exchange-lib/exchange_api_payback.c
index 7546605..600e0d6 100644
--- a/src/exchange-lib/exchange_api_payback.c
+++ b/src/exchange-lib/exchange_api_payback.c
@@ -98,8 +98,8 @@ verify_payback_signature_ok (const struct 
TALER_EXCHANGE_PaybackHandle *ph,
   const char *wire_subject;
   const struct TALER_EXCHANGE_Keys *key_state;
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_fixed_auto ("eddsa_sig", &exchange_sig),
-    GNUNET_JSON_spec_fixed_auto ("eddsa_pub", &exchange_pub),
+    GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig),
+    GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub),
     TALER_JSON_spec_amount ("amount", &amount),
     GNUNET_JSON_spec_absolute_time ("payback_deadline", &deadline),
     GNUNET_JSON_spec_string ("wire_subject", &wire_subject),
diff --git a/src/exchange/taler-exchange-httpd_db.c 
b/src/exchange/taler-exchange-httpd_db.c
index fe92d76..eb7058b 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -2372,6 +2372,7 @@ TEH_DB_execute_payback (struct MHD_Connection *connection,
   COMMIT_TRANSACTION(session, connection);
 
   return TEH_RESPONSE_reply_payback_success (connection,
+                                             &coin->coin_pub,
                                              wire_subject,
                                              &amount,
                                              payback_deadline);
diff --git a/src/exchange/taler-exchange-httpd_responses.c 
b/src/exchange/taler-exchange-httpd_responses.c
index c784625..efe3ee0 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -1297,9 +1297,8 @@ TEH_RESPONSE_reply_track_transfer_details (struct 
MHD_Connection *connection,
 
 
 /**
- * A wallet asked for /payback, but we do not know anything
- * about the original withdraw operation given. Generates a
- * 404 reply.
+ * A wallet asked for /payback, but we do not know anything about the
+ * original withdraw operation specified. Generates a 404 reply.
  *
  * @param connection connection to the client
  * @param ec Taler error code
@@ -1309,8 +1308,11 @@ int
 TEH_RESPONSE_reply_payback_unknown (struct MHD_Connection *connection,
                                     enum TALER_ErrorCode ec)
 {
-  GNUNET_break (0); /* #3887 */
-  return MHD_NO;
+  return TEH_RESPONSE_reply_json_pack (connection,
+                                       MHD_HTTP_NOT_FOUND,
+                                       "{s:s, s:I}",
+                                       "error", "blinded coin unknown",
+                                      "code", (json_int_t) ec);
 }
 
 
@@ -1325,12 +1327,35 @@ TEH_RESPONSE_reply_payback_unknown (struct 
MHD_Connection *connection,
  */
 int
 TEH_RESPONSE_reply_payback_success (struct MHD_Connection *connection,
+                                    const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
                                     const char *wire_subject,
                                     const struct TALER_Amount *amount,
                                     struct GNUNET_TIME_Absolute 
payback_deadline)
 {
-  GNUNET_break (0); /* #3887 */
-  return MHD_NO;
+  struct TALER_PaybackConfirmationPS pc;
+  struct TALER_ExchangePublicKeyP pub;
+  struct TALER_ExchangeSignatureP sig;
+
+  pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK);
+  pc.purpose.size = htonl (sizeof (struct TALER_PaybackConfirmationPS));
+  pc.payback_deadline = GNUNET_TIME_absolute_hton (payback_deadline);
+  TALER_amount_hton (&pc.payback_amount,
+                     amount);
+  pc.coin_pub = *coin_pub;
+  GNUNET_CRYPTO_hash (wire_subject,
+                      strlen (wire_subject),
+                      &pc.h_wire_subject);
+  TEH_KS_sign (&pc.purpose,
+               &pub,
+               &sig);
+  return TEH_RESPONSE_reply_json_pack (connection,
+                                       MHD_HTTP_OK,
+                                       "{s:s, s:o, s:o, s:o, s:o}",
+                                       "wire_subject", wire_subject,
+                                       "payback_deadline", 
GNUNET_JSON_from_time_abs (payback_deadline),
+                                       "amount", TALER_JSON_from_amount 
(amount),
+                                       "exchange_sig", 
GNUNET_JSON_from_data_auto (&sig),
+                                       "exchange_pub", 
GNUNET_JSON_from_data_auto (&pub));
 }
 
 
diff --git a/src/exchange/taler-exchange-httpd_responses.h 
b/src/exchange/taler-exchange-httpd_responses.h
index 27b20d3..e122295 100644
--- a/src/exchange/taler-exchange-httpd_responses.h
+++ b/src/exchange/taler-exchange-httpd_responses.h
@@ -560,9 +560,8 @@ TEH_RESPONSE_reply_refresh_link_success (struct 
MHD_Connection *connection,
 
 
 /**
- * A wallet asked for /payback, but we do not know anything
- * about the original withdraw operation given. Generates a
- * 404 reply.
+ * A wallet asked for /payback, but we do not know anything about the
+ * original withdraw operation specified. Generates a 404 reply.
  *
  * @param connection connection to the client
  * @param ec Taler error code
@@ -577,6 +576,7 @@ TEH_RESPONSE_reply_payback_unknown (struct MHD_Connection 
*connection,
  * A wallet asked for /payback, return the successful response.
  *
  * @param connection connection to the client
+ * @param coin_pub coin for which we are processing the payback request
  * @param wire_subject the wire subject we will use for the pay back operation
  * @param amount the amount we will wire back
  * @param payback_deadline deadline by which the exchange promises to pay
@@ -584,6 +584,7 @@ TEH_RESPONSE_reply_payback_unknown (struct MHD_Connection 
*connection,
  */
 int
 TEH_RESPONSE_reply_payback_success (struct MHD_Connection *connection,
+                                    const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
                                     const char *wire_subject,
                                     const struct TALER_Amount *amount,
                                     struct GNUNET_TIME_Absolute 
payback_deadline);

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]