aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-11-02 16:51:48 +0100
committerChristian Grothoff <christian@grothoff.org>2017-11-02 16:51:48 +0100
commitdb3c29711f0845010852ddc23e2f33786a585023 (patch)
treec5943ca7d41e980f5358a2c0cd81eaebec7400e6
parentb6907bb6bf640b678ba05f65b4cca7d78181945f (diff)
fix balance calculation for reserve withdrawals
-rw-r--r--ChangeLog4
-rw-r--r--src/exchange/taler-exchange-httpd_reserve_withdraw.c34
2 files changed, 19 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f123098b..80697eed5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Nov 2 16:50:46 CET 2017
+ Fixing serious bug in reserve balance calculations, as
+ fees were not always properly included in the summation. -CG
+
Tue Oct 31 13:43:55 CET 2017
Extended crypto API to provide planchet generation functions
explicitly (to be used on withdraw, refresh and tipping).
diff --git a/src/exchange/taler-exchange-httpd_reserve_withdraw.c b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
index cc21972bc..11265b43c 100644
--- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
@@ -163,7 +163,6 @@ withdraw_transaction (void *cls,
struct TALER_Amount deposit_total;
struct TALER_Amount withdraw_total;
struct TALER_Amount balance;
- struct TALER_Amount value;
struct TALER_Amount fee_withdraw;
int res;
enum GNUNET_DB_QueryStatus qs;
@@ -236,27 +235,13 @@ withdraw_transaction (void *cls,
break;
case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
{
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *tdki;
-
- tdki = TEH_KS_denomination_key_lookup (wc->key_state,
- &pos->details.withdraw->denom_pub,
- TEH_KS_DKU_WITHDRAW);
- if (NULL == tdki)
- {
- GNUNET_break (0);
- *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
- TALER_EC_WITHDRAW_HISTORIC_DENOMINATION_KEY_NOT_FOUND);
- return GNUNET_DB_STATUS_HARD_ERROR;
- }
- TALER_amount_ntoh (&value,
- &tdki->issue.properties.value);
if (0 == (res & 2))
- withdraw_total = value;
+ withdraw_total = pos->details.withdraw->amount_with_fee;
else
if (GNUNET_OK !=
TALER_amount_add (&withdraw_total,
&withdraw_total,
- &value))
+ &pos->details.withdraw->amount_with_fee))
{
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_AMOUNT_WITHDRAWALS_OVERFLOW);
@@ -283,17 +268,27 @@ withdraw_transaction (void *cls,
case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
if (0 == (res & 2))
- withdraw_total = pos->details.bank->amount;
+ withdraw_total = pos->details.closing->amount;
else
if (GNUNET_OK !=
TALER_amount_add (&withdraw_total,
&withdraw_total,
- &pos->details.bank->amount))
+ &pos->details.closing->amount))
{
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_WITHDRAW_AMOUNT_WITHDRAWALS_OVERFLOW);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+ if (GNUNET_OK !=
+ TALER_amount_add (&withdraw_total,
+ &withdraw_total,
+ &pos->details.closing->closing_fee))
+ {
+ *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
+ TALER_EC_WITHDRAW_AMOUNT_WITHDRAWALS_OVERFLOW);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+
res |= 2;
break;
}
@@ -324,6 +319,7 @@ withdraw_transaction (void *cls,
TALER_EC_WITHDRAW_RESERVE_HISTORY_IMPOSSIBLE);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+
if (0 < TALER_amount_cmp (&wc->amount_required,
&balance))
{