gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] branch master updated: fix balance calcula


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: fix balance calculation for reserve withdrawals
Date: Thu, 02 Nov 2017 16:51:55 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new db3c297  fix balance calculation for reserve withdrawals
db3c297 is described below

commit db3c29711f0845010852ddc23e2f33786a585023
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Nov 2 16:51:48 2017 +0100

    fix balance calculation for reserve withdrawals
---
 ChangeLog                                          |  4 +++
 .../taler-exchange-httpd_reserve_withdraw.c        | 34 ++++++++++------------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2f12309..80697ee 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 cc21972..11265b4 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))
   {

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]