summaryrefslogtreecommitdiff
path: root/src/exchange-lib/exchange_api_payback.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-04-16 02:39:11 +0200
committerChristian Grothoff <christian@grothoff.org>2017-04-16 02:39:11 +0200
commit4d4ac495a4cca70d7ac14d01d0a0088f86e82ba1 (patch)
tree861b595db73169c2a079392312c6fe09393ccaf6 /src/exchange-lib/exchange_api_payback.c
parentbe6dde89dbc6e9a9c69a8cec600f46e02c6c387c (diff)
downloadexchange-4d4ac495a4cca70d7ac14d01d0a0088f86e82ba1.tar.gz
exchange-4d4ac495a4cca70d7ac14d01d0a0088f86e82ba1.tar.bz2
exchange-4d4ac495a4cca70d7ac14d01d0a0088f86e82ba1.zip
test case of /payback done twice, handle 403-case in /payback handler, thereby also testing coin-with-payback history case in test logic (fixes #3887)
Diffstat (limited to 'src/exchange-lib/exchange_api_payback.c')
-rw-r--r--src/exchange-lib/exchange_api_payback.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/exchange-lib/exchange_api_payback.c b/src/exchange-lib/exchange_api_payback.c
index eff459693..30cd55cba 100644
--- a/src/exchange-lib/exchange_api_payback.c
+++ b/src/exchange-lib/exchange_api_payback.c
@@ -54,6 +54,11 @@ struct TALER_EXCHANGE_PaybackHandle
char *json_enc;
/**
+ * Denomination key of the coin.
+ */
+ const struct TALER_EXCHANGE_DenomPublicKey *pk;
+
+ /**
* Handle for the request.
*/
struct GNUNET_CURL_Job *job;
@@ -181,6 +186,35 @@ handle_payback_finished (void *cls,
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
break;
+ case MHD_HTTP_FORBIDDEN:
+ {
+ /* Insufficient funds, proof attached */
+ json_t *history;
+ struct TALER_Amount total;
+ const struct TALER_EXCHANGE_DenomPublicKey *dki;
+
+ dki = ph->pk;
+ history = json_object_get (json,
+ "history");
+ if (GNUNET_OK !=
+ TALER_EXCHANGE_verify_coin_history (dki->fee_deposit.currency,
+ &ph->coin_pub,
+ history,
+ &total))
+ {
+ GNUNET_break_op (0);
+ response_code = 0;
+ }
+ ph->cb (ph->cb_cls,
+ response_code,
+ TALER_JSON_get_error_code (json),
+ &total,
+ GNUNET_TIME_UNIT_FOREVER_ABS,
+ NULL,
+ json);
+ TALER_EXCHANGE_payback_cancel (ph);
+ return;
+ }
case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, exchange says one of the signatures is
invalid; as we checked them, this should never happen, we
@@ -277,6 +311,7 @@ TALER_EXCHANGE_payback (struct TALER_EXCHANGE_Handle *exchange,
ph = GNUNET_new (struct TALER_EXCHANGE_PaybackHandle);
ph->coin_pub = pr.coin_pub;
ph->exchange = exchange;
+ ph->pk = pk;
ph->cb = payback_cb;
ph->cb_cls = payback_cb_cls;
ph->url = MAH_path_to_url (exchange, "/payback");