summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-05-18 14:49:01 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-05-18 14:49:01 +0200
commitc9758f75f3f3129553fc541ef9334527de93cb6c (patch)
tree21e7d161c9cc77d0d8cbd58dac88b3dadab7c7b7 /src/exchange
parent76381cf0838db0f2e29208f770c83b3c662ed493 (diff)
downloadexchange-c9758f75f3f3129553fc541ef9334527de93cb6c.tar.gz
exchange-c9758f75f3f3129553fc541ef9334527de93cb6c.tar.bz2
exchange-c9758f75f3f3129553fc541ef9334527de93cb6c.zip
Annotation; error management.
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_reserve_withdraw.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/exchange/taler-exchange-httpd_reserve_withdraw.c b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
index 3f2bc3173..ec1a7684a 100644
--- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
@@ -48,11 +48,15 @@ reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection,
json_history = TEH_RESPONSE_compile_reserve_history (rh,
&balance);
- if (NULL == json_history)
+ if ((NULL == json_history)
+ /* Address the case where the ptr is not null, but
+ * it fails "internally" to dump as string (= corrupted). */
+ || (0 == json_dumpb (json_history, NULL, 0, 0)))
return TEH_RESPONSE_reply_internal_error (connection,
TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
"balance calculation failure");
json_balance = TALER_JSON_from_amount (&balance);
+
return TEH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_FORBIDDEN,
"{s:s, s:I, s:o, s:o}",
@@ -279,6 +283,25 @@ withdraw_transaction (void *cls,
TALER_EC_WITHDRAW_AMOUNT_WITHDRAWALS_OVERFLOW);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+
+ #if 0
+ /**
+ * WARNING:
+ *
+ * This check below is useless, as when a reserve gets
+ * closed, the database records that operation's amount
+ * as the _entire_ amount that was left into the reserve.
+ * This means that the closing fee is _included_ in what
+ * the database has, so it makes no sense to further
+ * subtract it from the 'withdraw_total'. On the other
+ * hand, the reserve-closing logic is careful to NOT wire
+ * transfer all the reserve amount back to the bank, but
+ * it does subtract the closing fee first from it.
+ *
+ * NOTE: this if-0'd out chunk of code is left around for
+ * internal review.
+ */
+
if (GNUNET_OK !=
TALER_amount_add (&withdraw_total,
&withdraw_total,
@@ -288,6 +311,7 @@ withdraw_transaction (void *cls,
TALER_EC_WITHDRAW_AMOUNT_WITHDRAWALS_OVERFLOW);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+ #endif
res |= 2;
break;
@@ -323,6 +347,7 @@ withdraw_transaction (void *cls,
if (0 < TALER_amount_cmp (&wc->amount_required,
&balance))
{
+ GNUNET_break_op (0);
*mhd_ret = reply_reserve_withdraw_insufficient_funds (connection,
rh);
TEH_plugin->free_reserve_history (TEH_plugin->cls,