aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-10-20 21:00:40 +0200
committerChristian Grothoff <christian@grothoff.org>2016-10-20 21:00:40 +0200
commit7341b21fa3d6328f2c85747824899be54668e891 (patch)
treeec9617287fe3514c377dbe06437cd33da6ba1c22
parente7875fb26145fcf90aaec4aa8bcb75ace0b40779 (diff)
return taler-specific error codes from C API as well
(#4497/4705)
-rw-r--r--src/exchange-lib/exchange_api_admin.c4
-rw-r--r--src/exchange-lib/exchange_api_common.c27
-rw-r--r--src/exchange-lib/exchange_api_common.h12
-rw-r--r--src/exchange-lib/exchange_api_deposit.c1
-rw-r--r--src/exchange-lib/exchange_api_refresh.c8
-rw-r--r--src/exchange-lib/exchange_api_refresh_link.c8
-rw-r--r--src/exchange-lib/exchange_api_refund.c1
-rw-r--r--src/exchange-lib/exchange_api_reserve.c8
-rw-r--r--src/exchange-lib/exchange_api_track_transaction.c1
-rw-r--r--src/exchange-lib/exchange_api_track_transfer.c2
-rw-r--r--src/exchange-lib/exchange_api_wire.c1
-rw-r--r--src/exchange-lib/test_exchange_api.c22
-rw-r--r--src/include/taler_error_codes.h87
-rw-r--r--src/include/taler_exchange_service.h24
14 files changed, 199 insertions, 7 deletions
diff --git a/src/exchange-lib/exchange_api_admin.c b/src/exchange-lib/exchange_api_admin.c
index 524916e68..e17cd780a 100644
--- a/src/exchange-lib/exchange_api_admin.c
+++ b/src/exchange-lib/exchange_api_admin.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014, 2015 GNUnet e.V.
+ Copyright (C) 2014, 2015, 2016 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -29,6 +29,7 @@
#include "taler_json_lib.h"
#include "taler_exchange_service.h"
#include "exchange_api_handle.h"
+#include "exchange_api_common.h"
#include "taler_signatures.h"
@@ -129,6 +130,7 @@ handle_admin_add_incoming_finished (void *cls,
}
aai->cb (aai->cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
json);
TALER_EXCHANGE_admin_add_incoming_cancel (aai);
}
diff --git a/src/exchange-lib/exchange_api_common.c b/src/exchange-lib/exchange_api_common.c
index e6ab2cbc2..445e2f131 100644
--- a/src/exchange-lib/exchange_api_common.c
+++ b/src/exchange-lib/exchange_api_common.c
@@ -28,6 +28,33 @@
/**
+ * Extract the Taler error code from the given @a json object.
+ * Note that #TALER_EC_NONE is returned if no "code" is present.
+ *
+ * @param json response to extract the error code from
+ * @return the "code" value from @a json
+ */
+enum TALER_ErrorCode
+TALER_EXCHANGE_json_get_error_code (const json_t *json)
+{
+ const json_t *jc;
+
+ if (NULL == json)
+ {
+ GNUNET_break_op (0);
+ return TALER_EC_INVALID_RESPONSE;
+ }
+ jc = json_object_get (json, "code");
+ if (NULL == jc)
+ return TALER_EC_NONE;
+ if (json_is_integer (jc))
+ return (enum TALER_ErrorCode) json_integer_value (jc);
+ GNUNET_break_op (0);
+ return TALER_EC_INVALID;
+}
+
+
+/**
* Verify a coins transaction history as returned by the exchange.
*
* @param currency expected currency for the coin
diff --git a/src/exchange-lib/exchange_api_common.h b/src/exchange-lib/exchange_api_common.h
index 5655f5d3b..bea36258e 100644
--- a/src/exchange-lib/exchange_api_common.h
+++ b/src/exchange-lib/exchange_api_common.h
@@ -23,6 +23,18 @@
#include <gnunet/gnunet_util_lib.h>
#include "taler_exchange_service.h"
+
+/**
+ * Extract the Taler error code from the given @a json object.
+ * Note that #TALER_EC_NONE is returned if no "code" is present.
+ *
+ * @param json response to extract the error code from
+ * @return the "code" value from @a json
+ */
+enum TALER_ErrorCode
+TALER_EXCHANGE_json_get_error_code (const json_t *json);
+
+
/**
* Verify a coins transaction history as returned by the exchange.
*
diff --git a/src/exchange-lib/exchange_api_deposit.c b/src/exchange-lib/exchange_api_deposit.c
index aa7e07ed8..63ae87d05 100644
--- a/src/exchange-lib/exchange_api_deposit.c
+++ b/src/exchange-lib/exchange_api_deposit.c
@@ -262,6 +262,7 @@ handle_deposit_finished (void *cls,
}
dh->cb (dh->cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
ep,
json);
TALER_EXCHANGE_deposit_cancel (dh);
diff --git a/src/exchange-lib/exchange_api_refresh.c b/src/exchange-lib/exchange_api_refresh.c
index 6d12a718c..e185ef98b 100644
--- a/src/exchange-lib/exchange_api_refresh.c
+++ b/src/exchange-lib/exchange_api_refresh.c
@@ -1115,6 +1115,7 @@ handle_refresh_melt_finished (void *cls,
{
rmh->melt_cb (rmh->melt_cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
noreveal_index,
(0 == response_code) ? NULL : &exchange_pub,
json);
@@ -1160,6 +1161,7 @@ handle_refresh_melt_finished (void *cls,
if (NULL != rmh->melt_cb)
rmh->melt_cb (rmh->melt_cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
UINT16_MAX,
NULL,
json);
@@ -1598,6 +1600,7 @@ handle_refresh_reveal_finished (void *cls,
{
rrh->reveal_cb (rrh->reveal_cb_cls,
MHD_HTTP_OK,
+ TALER_EC_NONE,
rrh->md->num_fresh_coins,
coin_privs,
sigs,
@@ -1634,7 +1637,10 @@ handle_refresh_reveal_finished (void *cls,
if (NULL != rrh->reveal_cb)
rrh->reveal_cb (rrh->reveal_cb_cls,
response_code,
- 0, NULL, NULL,
+ TALER_EXCHANGE_json_get_error_code (json),
+ 0,
+ NULL,
+ NULL,
json);
TALER_EXCHANGE_refresh_reveal_cancel (rrh);
}
diff --git a/src/exchange-lib/exchange_api_refresh_link.c b/src/exchange-lib/exchange_api_refresh_link.c
index a1dba9938..c5dbc389a 100644
--- a/src/exchange-lib/exchange_api_refresh_link.c
+++ b/src/exchange-lib/exchange_api_refresh_link.c
@@ -27,6 +27,7 @@
#include "taler_exchange_service.h"
#include "taler_json_lib.h"
#include "exchange_api_handle.h"
+#include "exchange_api_common.h"
#include "taler_signatures.h"
@@ -265,6 +266,7 @@ parse_refresh_link_ok (struct TALER_EXCHANGE_RefreshLinkHandle *rlh,
{
rlh->link_cb (rlh->link_cb_cls,
MHD_HTTP_OK,
+ TALER_EC_NONE,
num_coins,
coin_privs,
sigs,
@@ -345,7 +347,11 @@ handle_refresh_link_finished (void *cls,
if (NULL != rlh->link_cb)
rlh->link_cb (rlh->link_cb_cls,
response_code,
- 0, NULL, NULL, NULL,
+ TALER_EXCHANGE_json_get_error_code (json),
+ 0,
+ NULL,
+ NULL,
+ NULL,
json);
TALER_EXCHANGE_refresh_link_cancel (rlh);
}
diff --git a/src/exchange-lib/exchange_api_refund.c b/src/exchange-lib/exchange_api_refund.c
index f712f126a..73dd6ce51 100644
--- a/src/exchange-lib/exchange_api_refund.c
+++ b/src/exchange-lib/exchange_api_refund.c
@@ -196,6 +196,7 @@ handle_refund_finished (void *cls,
}
rh->cb (rh->cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
ep,
json);
TALER_EXCHANGE_refund_cancel (rh);
diff --git a/src/exchange-lib/exchange_api_reserve.c b/src/exchange-lib/exchange_api_reserve.c
index 9de2b268f..bcf372580 100644
--- a/src/exchange-lib/exchange_api_reserve.c
+++ b/src/exchange-lib/exchange_api_reserve.c
@@ -29,6 +29,7 @@
#include "taler_exchange_service.h"
#include "taler_json_lib.h"
#include "exchange_api_handle.h"
+#include "exchange_api_common.h"
#include "taler_signatures.h"
@@ -314,7 +315,8 @@ handle_reserve_status_finished (void *cls,
if (GNUNET_OK !=
GNUNET_JSON_parse (json,
spec,
- NULL, NULL))
+ NULL,
+ NULL))
{
GNUNET_break_op (0);
response_code = 0;
@@ -355,6 +357,7 @@ handle_reserve_status_finished (void *cls,
}
wsh->cb (wsh->cb_cls,
response_code,
+ TALER_EC_NONE,
json,
&balance,
len,
@@ -387,6 +390,7 @@ handle_reserve_status_finished (void *cls,
if (NULL != wsh->cb)
wsh->cb (wsh->cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
json,
NULL,
0, NULL);
@@ -589,6 +593,7 @@ reserve_withdraw_ok (struct TALER_EXCHANGE_ReserveWithdrawHandle *wsh,
dsig.rsa_signature = sig;
wsh->cb (wsh->cb_cls,
MHD_HTTP_OK,
+ TALER_EC_NONE,
&dsig,
json);
/* make sure callback isn't called again after return */
@@ -762,6 +767,7 @@ handle_reserve_withdraw_finished (void *cls,
if (NULL != wsh->cb)
wsh->cb (wsh->cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
NULL,
json);
TALER_EXCHANGE_reserve_withdraw_cancel (wsh);
diff --git a/src/exchange-lib/exchange_api_track_transaction.c b/src/exchange-lib/exchange_api_track_transaction.c
index c05115d57..cf0685733 100644
--- a/src/exchange-lib/exchange_api_track_transaction.c
+++ b/src/exchange-lib/exchange_api_track_transaction.c
@@ -239,6 +239,7 @@ handle_deposit_wtid_finished (void *cls,
}
dwh->cb (dwh->cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
ep,
json,
wtid,
diff --git a/src/exchange-lib/exchange_api_track_transfer.c b/src/exchange-lib/exchange_api_track_transfer.c
index ffcb19b59..0b45ecfc5 100644
--- a/src/exchange-lib/exchange_api_track_transfer.c
+++ b/src/exchange-lib/exchange_api_track_transfer.c
@@ -183,6 +183,7 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh
}
wdh->cb (wdh->cb_cls,
MHD_HTTP_OK,
+ TALER_EC_NONE,
&exchange_pub,
json,
&h_wire,
@@ -253,6 +254,7 @@ handle_track_transfer_finished (void *cls,
}
wdh->cb (wdh->cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
NULL,
json,
NULL,
diff --git a/src/exchange-lib/exchange_api_wire.c b/src/exchange-lib/exchange_api_wire.c
index cb8df4944..60e9113ab 100644
--- a/src/exchange-lib/exchange_api_wire.c
+++ b/src/exchange-lib/exchange_api_wire.c
@@ -210,6 +210,7 @@ handle_wire_finished (void *cls,
}
wh->cb (wh->cb_cls,
response_code,
+ TALER_EXCHANGE_json_get_error_code (json),
(NULL != keep) ? keep : json);
if (NULL != keep)
json_decref (keep);
diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c
index 80007c66f..39b8becef 100644
--- a/src/exchange-lib/test_exchange_api.c
+++ b/src/exchange-lib/test_exchange_api.c
@@ -761,11 +761,13 @@ next_command (struct InterpreterState *is)
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param full_response full response from the exchange (for logging, in case of errors)
*/
static void
add_incoming_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *full_response)
{
struct InterpreterState *is = cls;
@@ -857,6 +859,7 @@ compare_reserve_withdraw_history (const struct TALER_EXCHANGE_ReserveHistory *h,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param[in] json original response in JSON format (useful only for diagnostics)
* @param balance current balance in the reserve, NULL on error
* @param history_length number of entries in the transaction history, 0 on error
@@ -865,6 +868,7 @@ compare_reserve_withdraw_history (const struct TALER_EXCHANGE_ReserveHistory *h,
static void
reserve_status_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *json,
const struct TALER_Amount *balance,
unsigned int history_length,
@@ -973,12 +977,14 @@ reserve_status_cb (void *cls,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param sig signature over the coin, NULL on error
* @param full_response full response from the exchange (for logging, in case of errors)
*/
static void
reserve_withdraw_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_DenominationSignature *sig,
const json_t *full_response)
{
@@ -1027,6 +1033,7 @@ reserve_withdraw_cb (void *cls,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful deposit;
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param exchange_pub public key the exchange used for signing
* @param obj the received JSON reply, should be kept as proof (and, in case of errors,
* be forwarded to the customer)
@@ -1034,6 +1041,7 @@ reserve_withdraw_cb (void *cls,
static void
deposit_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const json_t *obj)
{
@@ -1061,6 +1069,7 @@ deposit_cb (void *cls,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, never #MHD_HTTP_OK (200) as for successful intermediate response this callback is skipped.
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param noreveal_index choice by the exchange in the cut-and-choose protocol,
* UINT16_MAX on error
* @param exchange_pub public key the exchange used for signing
@@ -1069,6 +1078,7 @@ deposit_cb (void *cls,
static void
melt_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
uint16_t noreveal_index,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const json_t *full_response)
@@ -1098,6 +1108,7 @@ melt_cb (void *cls,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed
* @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error
* @param sigs array of signature over @a num_coins coins, NULL on error
@@ -1106,6 +1117,7 @@ melt_cb (void *cls,
static void
reveal_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs,
const struct TALER_DenominationSignature *sigs,
@@ -1160,6 +1172,7 @@ reveal_cb (void *cls,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed
* @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error
* @param sigs array of signature over @a num_coins coins, NULL on error
@@ -1169,6 +1182,7 @@ reveal_cb (void *cls,
static void
link_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs,
const struct TALER_DenominationSignature *sigs,
@@ -1336,12 +1350,14 @@ find_pk (const struct TALER_EXCHANGE_Keys *keys,
* @param cls closure with the interpreter state
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful request;
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param obj the received JSON reply, if successful this should be the wire
* format details as provided by /wire.
*/
static void
wire_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *obj)
{
struct InterpreterState *is = cls;
@@ -1391,6 +1407,7 @@ wire_cb (void *cls,
*
* @param cls closure
* @param http_status HTTP status code we got, 0 on exchange protocol violation
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param exchange_pub public key the exchange used for signing
* @param json original json reply (may include signatures, those have then been
* validated already)
@@ -1404,6 +1421,7 @@ wire_cb (void *cls,
static void
wire_deposits_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const json_t *json,
const struct GNUNET_HashCode *h_wire,
@@ -1521,6 +1539,7 @@ wire_deposits_cb (void *cls,
*
* @param cls closure
* @param http_status HTTP status code we got, 0 on exchange protocol violation
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param exchange_pub public key the exchange used for signing
* @param json original json reply (may include signatures, those have then been
* validated already)
@@ -1534,6 +1553,7 @@ wire_deposits_cb (void *cls,
static void
deposit_wtid_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const json_t *json,
const struct TALER_WireTransferIdentifierRawP *wtid,
@@ -1588,6 +1608,7 @@ deposit_wtid_cb (void *cls,
* @param cls closure
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful deposit;
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param exchange_pub public key the exchange used for signing @a obj
* @param obj the received JSON reply, should be kept as proof (and, in particular,
* be forwarded to the customer)
@@ -1595,6 +1616,7 @@ deposit_wtid_cb (void *cls,
static void
refund_cb (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const json_t *obj)
{
diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h
index dbe189936..632c160a1 100644
--- a/src/include/taler_error_codes.h
+++ b/src/include/taler_error_codes.h
@@ -33,10 +33,22 @@ enum TALER_ErrorCode
{
/**
- * Special code to indicate no error.
+ * Special code to indicate no error (or no "code" present).
*/
TALER_EC_NONE = 0,
+ /**
+ * Special code to indicate that a non-integer error code was
+ * returned in the JSON response.
+ */
+ TALER_EC_INVALID = 1,
+
+ /**
+ * The response we got from the server was not even in JSON format.
+ */
+ TALER_EC_INVALID_RESPONSE = 2,
+
+
/* ********** generic error codes ************* */
/**
@@ -975,6 +987,33 @@ enum TALER_ErrorCode
TALER_EC_TRACK_TRANSACTION_DB_NO_DEPOSITS_ERROR = 2305,
/**
+ * We failed to obtain a wire transfer identifier for one
+ * of the coins in the transaction. The response is
+ * provided with HTTP status code MHD_HTTP_FAILED_DEPENDENCY if
+ * the exchange had a hard error, or MHD_HTTP_ACCEPTED if the
+ * exchange signaled that the transfer was in progress.
+ */
+ TALER_EC_TRACK_TRANSACTION_COIN_TRACE_ERROR = 2306,
+
+ /**
+ * We failed to obtain the full wire transfer identifier for the
+ * transfer one of the coins was aggregated into.
+ * The response is
+ * provided with HTTP status code MHD_HTTP_FAILED_DEPENDENCY.
+ */
+ TALER_EC_TRACK_TRANSACTION_WIRE_TRANSFER_TRACE_ERROR = 2307,
+
+ /**
+ * We got conflicting reports from the exhange with
+ * respect to which transfers are included in which
+ * aggregate.
+ * The response is
+ * provided with HTTP status code MHD_HTTP_FAILED_DEPENDENCY.
+ */
+ TALER_EC_TRACK_TRANSACTION_CONFLICTING_REPORTS = 2308,
+
+
+ /**
* We failed to contact the exchange for the /track/transfer
* request. This response is provided with HTTP status code
* MHD_HTTP_SERVICE_UNAVAILABLE.
@@ -986,8 +1025,52 @@ enum TALER_ErrorCode
* in the request. This response is
* provided with HTTP status code MHD_HTTP_NOT_FOUND.
*/
- TALER_EC_TRACK_TRANSFER_INSTANCE_UNKNOWN = 2000,
+ TALER_EC_TRACK_TRANSFER_INSTANCE_UNKNOWN = 2401,
+
+ /**
+ * We failed to persist coin wire transfer information in
+ * our merchant database.
+ * The response is
+ * provided with HTTP status code MHD_HTTP_INTERNAL_SERVER_ERROR.
+ */
+ TALER_EC_TRACK_TRANSFER_DB_STORE_COIN_ERROR = 2402,
+ /**
+ * We internally failed to execute the /track/transfer request.
+ * The response is
+ * provided with HTTP status code MHD_HTTP_INTERNAL_SERVER_ERROR.
+ */
+ TALER_EC_TRACK_TRANSFER_REQUEST_ERROR = 2403,
+
+ /**
+ * We failed to persist wire transfer information in
+ * our merchant database.
+ * The response is
+ * provided with HTTP status code MHD_HTTP_INTERNAL_SERVER_ERROR.
+ */
+ TALER_EC_TRACK_TRANSFER_DB_STORE_TRANSER_ERROR = 2404,
+
+ /**
+ * The exchange returned an error from /track/transfer.
+ * The response is
+ * provided with HTTP status code MHD_HTTP_FAILED_DEPENDENCY.
+ */
+ TALER_EC_TRACK_TRANSFER_EXCHANGE_ERROR = 2405,
+
+ /**
+ * We failed to fetch deposit information from
+ * our merchant database.
+ * The response is
+ * provided with HTTP status code MHD_HTTP_INTERNAL_SERVER_ERROR.
+ */
+ TALER_EC_TRACK_TRANSFER_DB_FETCH_DEPOSIT_ERROR = 2406,
+
+ /**
+ * We encountered an internal logic error.
+ * The response is
+ * provided with HTTP status code MHD_HTTP_INTERNAL_SERVER_ERROR.
+ */
+ TALER_EC_TRACK_TRANSFER_DB_INTERNAL_LOGIC_ERROR = 2407,
/* ********** /test API error codes ************* */
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index 9e3c48c4c..d1f6dbbe3 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -24,6 +24,7 @@
#include <jansson.h>
#include "taler_util.h"
+#include "taler_error_codes.h"
#include <gnunet/gnunet_curl_lib.h>
@@ -355,6 +356,7 @@ struct TALER_EXCHANGE_WireHandle;
* @param cls closure
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful request;
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param obj the received JSON reply, if successful this should be the wire
* format details as provided by /wire, or NULL if the
* reply was not in JSON format.
@@ -362,6 +364,7 @@ struct TALER_EXCHANGE_WireHandle;
typedef void
(*TALER_EXCHANGE_WireResultCallback) (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *obj);
@@ -423,6 +426,7 @@ struct TALER_EXCHANGE_DepositHandle;
typedef void
(*TALER_EXCHANGE_DepositResultCallback) (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_ExchangePublicKeyP *sign_key,
const json_t *obj);
@@ -504,6 +508,7 @@ struct TALER_EXCHANGE_RefundHandle;
* @param cls closure
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful deposit;
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param sign_key exchange key used to sign @a obj, or NULL
* @param obj the received JSON reply, should be kept as proof (and, in particular,
* be forwarded to the customer)
@@ -511,6 +516,7 @@ struct TALER_EXCHANGE_RefundHandle;
typedef void
(*TALER_EXCHANGE_RefundResultCallback) (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_ExchangePublicKeyP *sign_key,
const json_t *obj);
@@ -650,6 +656,7 @@ struct TALER_EXCHANGE_ReserveHistory
* @param cls closure
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param[in] json original response in JSON format (useful only for diagnostics)
* @param balance current balance in the reserve, NULL on error
* @param history_length number of entries in the transaction history, 0 on error
@@ -658,6 +665,7 @@ struct TALER_EXCHANGE_ReserveHistory
typedef void
(*TALER_EXCHANGE_ReserveStatusResultCallback) (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *json,
const struct TALER_Amount *balance,
unsigned int history_length,
@@ -713,12 +721,14 @@ struct TALER_EXCHANGE_ReserveWithdrawHandle;
* @param cls closure
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param sig signature over the coin, NULL on error
* @param full_response full response from the exchange (for logging, in case of errors)
*/
typedef void
(*TALER_EXCHANGE_ReserveWithdrawResultCallback) (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_DenominationSignature *sig,
const json_t *full_response);
@@ -835,6 +845,7 @@ struct TALER_EXCHANGE_RefreshMeltHandle;
* @param cls closure
* @param http_status HTTP response code, never #MHD_HTTP_OK (200) as for successful intermediate response this callback is skipped.
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param noreveal_index choice by the exchange in the cut-and-choose protocol,
* UINT16_MAX on error
* @param sign_key exchange key used to sign @a full_response, or NULL
@@ -843,7 +854,8 @@ struct TALER_EXCHANGE_RefreshMeltHandle;
typedef void
(*TALER_EXCHANGE_RefreshMeltCallback) (void *cls,
unsigned int http_status,
- uint16_t noreveal_index,
+ enum TALER_ErrorCode ec,
+ uint16_t noreveal_index,
const struct TALER_ExchangePublicKeyP *sign_key,
const json_t *full_response);
@@ -900,6 +912,7 @@ TALER_EXCHANGE_refresh_melt_cancel (struct TALER_EXCHANGE_RefreshMeltHandle *rmh
* @param cls closure
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed
* @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error
* @param sigs array of signature over @a num_coins coins, NULL on error
@@ -908,6 +921,7 @@ TALER_EXCHANGE_refresh_melt_cancel (struct TALER_EXCHANGE_RefreshMeltHandle *rmh
typedef void
(*TALER_EXCHANGE_RefreshRevealCallback) (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs,
const struct TALER_DenominationSignature *sigs,
@@ -979,6 +993,7 @@ struct TALER_EXCHANGE_RefreshLinkHandle;
* @param cls closure
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed
* @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error
* @param sigs array of signature over @a num_coins coins, NULL on error
@@ -988,6 +1003,7 @@ struct TALER_EXCHANGE_RefreshLinkHandle;
typedef void
(*TALER_EXCHANGE_RefreshLinkCallback) (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs,
const struct TALER_DenominationSignature *sigs,
@@ -1043,11 +1059,13 @@ struct TALER_EXCHANGE_AdminAddIncomingHandle;
* @param cls closure
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the exchange's reply is bogus (fails to follow the protocol)
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param full_response full response from the exchange (for logging, in case of errors)
*/
typedef void
(*TALER_EXCHANGE_AdminAddIncomingResultCallback) (void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const json_t *full_response);
@@ -1108,6 +1126,7 @@ struct TALER_EXCHANGE_TrackTransferHandle;
*
* @param cls closure
* @param http_status HTTP status code we got, 0 on exchange protocol violation
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param sign_key exchange key used to sign @a json, or NULL
* @param json original json reply (may include signatures, those have then been
* validated already)
@@ -1121,6 +1140,7 @@ struct TALER_EXCHANGE_TrackTransferHandle;
typedef void
(*TALER_EXCHANGE_TrackTransferCallback)(void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_ExchangePublicKeyP *sign_key,
const json_t *json,
const struct GNUNET_HashCode *h_wire,
@@ -1171,6 +1191,7 @@ struct TALER_EXCHANGE_TrackTransactionHandle;
*
* @param cls closure
* @param http_status HTTP status code we got, 0 on exchange protocol violation
+ * @param ec taler-specific error code, #TALER_EC_NONE on success
* @param sign_key exchange key used to sign @a json, or NULL
* @param json original json reply (may include signatures, those have then been
* validated already)
@@ -1182,6 +1203,7 @@ struct TALER_EXCHANGE_TrackTransactionHandle;
typedef void
(*TALER_EXCHANGE_TrackTransactionCallback)(void *cls,
unsigned int http_status,
+ enum TALER_ErrorCode ec,
const struct TALER_ExchangePublicKeyP *sign_key,
const json_t *json,
const struct TALER_WireTransferIdentifierRawP *wtid,