summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_reserve_status.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-06-19 00:00:21 +0200
committerChristian Grothoff <christian@grothoff.org>2017-06-19 00:17:16 +0200
commitdea0f7c411d6ae5c5410d30f6072478e905cabb4 (patch)
tree63fd5490d62d991f47148c5147c51d249d9d61b8 /src/exchange/taler-exchange-httpd_reserve_status.c
parent4cb035cd298139f606562ed88f60ba89dff0febc (diff)
downloadexchange-dea0f7c411d6ae5c5410d30f6072478e905cabb4.tar.gz
exchange-dea0f7c411d6ae5c5410d30f6072478e905cabb4.tar.bz2
exchange-dea0f7c411d6ae5c5410d30f6072478e905cabb4.zip
fixing #5010 for /reserve/withdraw
Diffstat (limited to 'src/exchange/taler-exchange-httpd_reserve_status.c')
-rw-r--r--src/exchange/taler-exchange-httpd_reserve_status.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/exchange/taler-exchange-httpd_reserve_status.c b/src/exchange/taler-exchange-httpd_reserve_status.c
index e13b8f393..f87afa5ae 100644
--- a/src/exchange/taler-exchange-httpd_reserve_status.c
+++ b/src/exchange/taler-exchange-httpd_reserve_status.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014, 2015, 2016 GNUnet e.V.
+ Copyright (C) 2014-2017 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
@@ -30,6 +30,36 @@
/**
+ * Send reserve status information to client.
+ *
+ * @param connection connection to the client
+ * @param rh reserve history to return
+ * @return MHD result code
+ */
+static int
+reply_reserve_status_success (struct MHD_Connection *connection,
+ const struct TALER_EXCHANGEDB_ReserveHistory *rh)
+{
+ json_t *json_balance;
+ json_t *json_history;
+ struct TALER_Amount balance;
+
+ json_history = TEH_RESPONSE_compile_reserve_history (rh,
+ &balance);
+ if (NULL == json_history)
+ return TEH_RESPONSE_reply_internal_error (connection,
+ TALER_EC_RESERVE_STATUS_DB_ERROR,
+ "balance calculation failure");
+ json_balance = TALER_JSON_from_amount (&balance);
+ return TEH_RESPONSE_reply_json_pack (connection,
+ MHD_HTTP_OK,
+ "{s:o, s:o}",
+ "balance", json_balance,
+ "history", json_history);
+}
+
+
+/**
* Closure for #reserve_status_transaction.
*/
struct ReserveStatusContext
@@ -126,8 +156,8 @@ TEH_RESERVE_handler_reserve_status (struct TEH_RequestHandler *rh,
"{s:s, s:s}",
"error", "Reserve not found",
"parameter", "withdraw_pub");
- mhd_ret = TEH_RESPONSE_reply_reserve_status_success (connection,
- rsc.rh);
+ mhd_ret = reply_reserve_status_success (connection,
+ rsc.rh);
TEH_plugin->free_reserve_history (TEH_plugin->cls,
rsc.rh);
return mhd_ret;