summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_responses.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-29 16:42:38 +0200
committerChristian Grothoff <christian@grothoff.org>2017-03-29 16:42:38 +0200
commit21d26132877990d7beac118b33e336aaed395234 (patch)
treed970f8115b00b5125ffc4aef89c0a2dd721c0ee8 /src/exchange/taler-exchange-httpd_responses.c
parent5aebc70da6524d3b27ad4f93a66ba70dbe64fab1 (diff)
downloadexchange-21d26132877990d7beac118b33e336aaed395234.tar.gz
exchange-21d26132877990d7beac118b33e336aaed395234.tar.bz2
exchange-21d26132877990d7beac118b33e336aaed395234.zip
first sketch at db module implementation for #3887
Diffstat (limited to 'src/exchange/taler-exchange-httpd_responses.c')
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c65
1 files changed, 57 insertions, 8 deletions
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 1caef3469..c78462532 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -436,6 +436,11 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl)
const struct TALER_EXCHANGEDB_TransactionList *pos;
history = json_array ();
+ if (NULL == history)
+ {
+ GNUNET_break (0); /* out of memory!? */
+ return NULL;
+ }
for (pos = tl; NULL != pos; pos = pos->next)
{
switch (pos->type)
@@ -562,29 +567,33 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl)
/**
- * Send proof that a /deposit request is invalid to client. This
- * function will create a message with all of the operations affecting
- * the coin that demonstrate that the coin has insufficient value.
+ * Send proof that a request is invalid to client because of
+ * insufficient funds. This function will create a message with all
+ * of the operations affecting the coin that demonstrate that the coin
+ * has insufficient value.
*
* @param connection connection to the client
+ * @param ec error code to return
* @param tl transaction list to use to build reply
* @return MHD result code
*/
int
-TEH_RESPONSE_reply_deposit_insufficient_funds (struct MHD_Connection *connection,
- const struct TALER_EXCHANGEDB_TransactionList *tl)
+TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection,
+ enum TALER_ErrorCode ec,
+ const struct TALER_EXCHANGEDB_TransactionList *tl)
{
json_t *history;
history = compile_transaction_history (tl);
if (NULL == history)
- return TEH_RESPONSE_reply_internal_db_error (connection,
- TALER_EC_DEPOSIT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS);
+ return TEH_RESPONSE_reply_internal_error (connection,
+ TALER_EC_COIN_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
+ "failed to convert transaction history to JSON");
return TEH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_FORBIDDEN,
"{s:s, s:I, s:o}",
"error", "insufficient funds",
- "code", (json_int_t) TALER_EC_DEPOSIT_INSUFFICIENT_FUNDS,
+ "code", (json_int_t) ec,
"history", history);
}
@@ -1286,4 +1295,44 @@ 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.
+ *
+ * @param connection connection to the client
+ * @param ec Taler error code
+ * @return MHD result code
+ */
+int
+TEH_RESPONSE_reply_payback_unknown (struct MHD_Connection *connection,
+ enum TALER_ErrorCode ec)
+{
+ GNUNET_break (0); /* #3887 */
+ return MHD_NO;
+}
+
+
+/**
+ * A wallet asked for /payback, return the successful response.
+ *
+ * @param connection connection to the client
+ * @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
+ * @return MHD result code
+ */
+int
+TEH_RESPONSE_reply_payback_success (struct MHD_Connection *connection,
+ const char *wire_subject,
+ const struct TALER_Amount *amount,
+ struct GNUNET_TIME_Absolute payback_deadline)
+{
+ GNUNET_break (0); /* #3887 */
+ return MHD_NO;
+}
+
+
+
/* end of taler-exchange-httpd_responses.c */