gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated (cdaf1ce6 -> c25b805f)


From: gnunet
Subject: [taler-exchange] branch master updated (cdaf1ce6 -> c25b805f)
Date: Tue, 11 Feb 2020 16:01:48 +0100

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

grothoff pushed a change to branch master
in repository exchange.

    from cdaf1ce6 rename SQL files to make filenames consistent with versioning 
name
     new de0d987e start with new history API implementation
     new 3ad698d0 merging
     new c25b805f first draft implementation of new bank account balance in 
history logic (untested)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/prebuilt                                       |   2 +-
 src/bank-lib/fakebank.c                            | 169 ++++++++++++++++++++-
 src/exchange-tools/taler-exchange-keyup.c          |   2 +-
 src/exchange/taler-exchange-httpd_refresh_reveal.c |   6 +-
 src/lib/exchange_api_handle.c                      |   2 +-
 5 files changed, 169 insertions(+), 12 deletions(-)

diff --git a/doc/prebuilt b/doc/prebuilt
index 934a6a18..ca53235c 160000
--- a/doc/prebuilt
+++ b/doc/prebuilt
@@ -1 +1 @@
-Subproject commit 934a6a18301e81c4fd1b3a8cda2dc13dca4741cc
+Subproject commit ca53235ccfa0458ebf11c204888ca370e20ec3f5
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 56af11f8..61b9a91c 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -972,8 +972,14 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
                       const char *account)
 {
   struct HistoryArgs ha;
-  struct Transaction *pos;
+  const struct Transaction *pos;
+  const struct Transaction *spos;
   json_t *history;
+  struct TALER_Amount total_incoming;
+  struct TALER_Amount start_outgoing;
+  struct TALER_Amount end_outgoing;
+  const struct Transaction *start_pos;
+  const struct Transaction *end_pos;
 
   if (GNUNET_OK !=
       parse_history_common_args (connection,
@@ -1014,6 +1020,8 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
     /* list is empty */
     pos = NULL;
   }
+  spos = pos;
+
   history = json_array ();
   while ( (0 != ha.delta) &&
           (NULL != pos) )
@@ -1065,11 +1073,81 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
     if (0 < ha.delta)
       pos = pos->next;
   }
+  if (0 > ha.delta)
+  {
+    start_pos = pos;
+    end_pos = spos;
+  }
+  else
+  {
+    start_pos = spos;
+    if (NULL == pos)
+      end_pos = h->transactions_tail;
+    else
+      end_pos = pos;
+  }
+  /* now calculate balances at beginning end end of
+     transaction history */
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_amount_get_zero (h->currency,
+                                        &total_incoming));
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_amount_get_zero (h->currency,
+                                        &start_outgoing));
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_amount_get_zero (h->currency,
+                                        &end_outgoing));
+  for (pos = h->transactions_head;
+       NULL != pos;
+       pos = pos->next)
+  {
+    if ( (0 == strcasecmp (pos->debit_account,
+                           account)) &&
+         (T_DEBIT == pos->type) )
+    {
+      if (pos == start_pos)
+        start_pos = NULL;
+      if (NULL != start_pos)
+      {
+        /* we are *before* the start position (exclusive), add to balances */
+        GNUNET_break (GNUNET_OK ==
+                      TALER_amount_add (&start_outgoing,
+                                        &start_outgoing,
+                                        &pos->amount));
+      }
+      if (NULL != end_pos)
+      {
+        /* we are *before* the end position (inclusive),
+           add to balances */
+        GNUNET_break (GNUNET_OK ==
+                      TALER_amount_add (&end_outgoing,
+                                        &end_outgoing,
+                                        &pos->amount));
+      }
+      if (pos == end_pos)
+        end_pos = NULL;
+    }
+    if ( (0 == strcasecmp (pos->credit_account,
+                           account)) &&
+         (T_CREDIT == pos->type) )
+    {
+      GNUNET_break (GNUNET_OK ==
+                    TALER_amount_add (&total_incoming,
+                                      &total_incoming,
+                                      &pos->amount));
+    }
+  }
   return TALER_MHD_reply_json_pack (connection,
                                     MHD_HTTP_OK,
-                                    "{s:o}",
+                                    "{s:o, s:o, s:o, s:o}",
                                     "outgoing_transactions",
-                                    history);
+                                    history,
+                                    "current_incoming",
+                                    TALER_JSON_from_amount (&total_incoming),
+                                    "total_incoming_start",
+                                    TALER_JSON_from_amount (&start_outgoing),
+                                    "total_incoming_end",
+                                    TALER_JSON_from_amount (&end_outgoing));
 }
 
 
@@ -1087,8 +1165,14 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
                        const char *account)
 {
   struct HistoryArgs ha;
-  struct Transaction *pos;
+  const struct Transaction *pos;
+  const struct Transaction *spos;
   json_t *history;
+  struct TALER_Amount end_incoming;
+  struct TALER_Amount start_incoming;
+  struct TALER_Amount total_outgoing;
+  const struct Transaction *start_pos;
+  const struct Transaction *end_pos;
 
   if (GNUNET_OK !=
       parse_history_common_args (connection,
@@ -1143,6 +1227,8 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
     /* list is empty */
     pos = NULL;
   }
+  spos = pos;
+
   history = json_array ();
   while ( (0 != ha.delta) &&
           (NULL != pos) )
@@ -1207,11 +1293,82 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
     if (0 < ha.delta)
       pos = pos->next;
   }
+  if (0 > ha.delta)
+  {
+    start_pos = pos;
+    end_pos = spos;
+  }
+  else
+  {
+    start_pos = spos;
+    if (NULL == pos)
+      end_pos = h->transactions_tail;
+    else
+      end_pos = pos;
+  }
+  /* now calculate balances at beginning end end of
+     transaction history */
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_amount_get_zero (h->currency,
+                                        &total_outgoing));
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_amount_get_zero (h->currency,
+                                        &start_incoming));
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_amount_get_zero (h->currency,
+                                        &end_incoming));
+  for (pos = h->transactions_head;
+       NULL != pos;
+       pos = pos->next)
+  {
+    if ( (0 == strcasecmp (pos->credit_account,
+                           account)) &&
+         (T_CREDIT == pos->type) )
+    {
+      if (pos == start_pos)
+        start_pos = NULL;
+      if (NULL != start_pos)
+      {
+        /* we are *before* the start position (exclusive), add to balances */
+        GNUNET_break (GNUNET_OK ==
+                      TALER_amount_add (&start_incoming,
+                                        &start_incoming,
+                                        &pos->amount));
+      }
+      if (NULL != end_pos)
+      {
+        /* we are *before* the end position (inclusive),
+           add to balances */
+        GNUNET_break (GNUNET_OK ==
+                      TALER_amount_add (&end_incoming,
+                                        &end_incoming,
+                                        &pos->amount));
+      }
+      if (pos == end_pos)
+        end_pos = NULL;
+    }
+    if ( (0 == strcasecmp (pos->debit_account,
+                           account)) &&
+         (T_DEBIT == pos->type) )
+    {
+      GNUNET_break (GNUNET_OK ==
+                    TALER_amount_add (&total_outgoing,
+                                      &total_outgoing,
+                                      &pos->amount));
+    }
+  }
+
   return TALER_MHD_reply_json_pack (connection,
                                     MHD_HTTP_OK,
-                                    "{s:o}",
+                                    "{s:o, s:o, s:o, s:o}",
                                     "incoming_transactions",
-                                    history);
+                                    history,
+                                    "current_outgoing",
+                                    TALER_JSON_from_amount (&total_outgoing),
+                                    "total_incoming_start",
+                                    TALER_JSON_from_amount (&start_incoming),
+                                    "total_incoming_end",
+                                    TALER_JSON_from_amount (&end_incoming));
 }
 
 
diff --git a/src/exchange-tools/taler-exchange-keyup.c 
b/src/exchange-tools/taler-exchange-keyup.c
index f70ff23a..a11ec3f8 100644
--- a/src/exchange-tools/taler-exchange-keyup.c
+++ b/src/exchange-tools/taler-exchange-keyup.c
@@ -770,7 +770,7 @@ create_denomkey_issue (const struct CoinTypeParams *params,
   GNUNET_assert (NULL != dki->denom_priv.rsa_private_key);
   dki->denom_pub.rsa_public_key
     = GNUNET_CRYPTO_rsa_private_key_get_public (
-        dki->denom_priv.rsa_private_key);
+    dki->denom_priv.rsa_private_key);
   GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
                                      &dki->issue.properties.denom_hash);
   dki->issue.properties.master = master_public_key;
diff --git a/src/exchange/taler-exchange-httpd_refresh_reveal.c 
b/src/exchange/taler-exchange-httpd_refresh_reveal.c
index 1e03c8e7..6ac91caf 100644
--- a/src/exchange/taler-exchange-httpd_refresh_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refresh_reveal.c
@@ -697,9 +697,9 @@ resolve_refresh_reveal_denominations (struct 
TEH_KS_StateHandle *key_state,
   {
     rctx->ev_sigs[i].rsa_signature
       = GNUNET_CRYPTO_rsa_sign_blinded (
-          rctx->dkis[i]->denom_priv.rsa_private_key,
-          rctx->rcds[i].coin_ev,
-          rctx->rcds[i].coin_ev_size);
+      rctx->dkis[i]->denom_priv.rsa_private_key,
+      rctx->rcds[i].coin_ev,
+      rctx->rcds[i].coin_ev_size);
     if (NULL == rctx->ev_sigs[i].rsa_signature)
     {
       GNUNET_break (0);
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index 783cddea..e0ef7f40 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -1259,7 +1259,7 @@ keys_completed_cb (void *cls,
     for (unsigned int i = 0; i<kd_old.num_denom_keys; i++)
       kd.denom_keys[i].key.rsa_public_key
         = GNUNET_CRYPTO_rsa_public_key_dup (
-            kd_old.denom_keys[i].key.rsa_public_key);
+        kd_old.denom_keys[i].key.rsa_public_key);
 
     kd.num_auditors = kd_old.num_auditors;
     kd.auditors = GNUNET_new_array (kd.num_auditors,

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



reply via email to

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