aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-29 16:57:20 +0200
committerChristian Grothoff <christian@grothoff.org>2017-03-29 16:57:20 +0200
commitc329b92ccf1c461e4032e75164b6ffa6bb509a69 (patch)
tree0edbf79cdb304e1b930ff8b603980f8eaf51c052
parent21d26132877990d7beac118b33e336aaed395234 (diff)
implementing remaining /payback responses
-rw-r--r--src/exchange-lib/exchange_api_payback.c4
-rw-r--r--src/exchange/taler-exchange-httpd_db.c1
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c39
-rw-r--r--src/exchange/taler-exchange-httpd_responses.h7
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 7546605d1..600e0d682 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 fe92d76bb..eb7058bb2 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 c78462532..efe3ee091 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 27b20d353..e12229565 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);