gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: bank/fakebank API changes for #7


From: gnunet
Subject: [taler-exchange] branch master updated: bank/fakebank API changes for #7275
Date: Sun, 03 Sep 2023 17:59:59 +0200

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 fd6a1d1a bank/fakebank API changes for #7275
fd6a1d1a is described below

commit fd6a1d1a6cc3069baace21b3822bf857618e356d
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Sun Sep 3 17:59:53 2023 +0200

    bank/fakebank API changes for #7275
---
 src/bank-lib/bank_api_credit.c | 27 ++++++++++++---------
 src/bank-lib/bank_api_debit.c  | 27 ++++++++++++---------
 src/bank-lib/fakebank.c        | 54 ++++++++++++++++++++++++------------------
 3 files changed, 63 insertions(+), 45 deletions(-)

diff --git a/src/bank-lib/bank_api_credit.c b/src/bank-lib/bank_api_credit.c
index 14ddcd72..9ed8a231 100644
--- a/src/bank-lib/bank_api_credit.c
+++ b/src/bank-lib/bank_api_credit.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2017--2021 Taler Systems SA
+  Copyright (C) 2017--2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
@@ -82,15 +82,21 @@ parse_account_history (struct 
TALER_BANK_CreditHistoryHandle *hh,
     .ec = TALER_EC_NONE,
     .response = history
   };
-  json_t *history_array;
+  const json_t *history_array;
+  const char *credit_account_uri;
+  struct GNUNET_JSON_Specification spec[] = {
+    GNUNET_JSON_spec_array_const ("incoming_transactions",
+                                  &history_array),
+    GNUNET_JSON_spec_string ("credit_account",
+                             &credit_account_uri),
+    GNUNET_JSON_spec_end ()
+  };
 
-  if (NULL == (history_array = json_object_get (history,
-                                                "incoming_transactions")))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  if (! json_is_array (history_array))
+  if (GNUNET_OK !=
+      GNUNET_JSON_parse (history,
+                         spec,
+                         NULL,
+                         NULL))
   {
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
@@ -114,8 +120,6 @@ parse_account_history (struct 
TALER_BANK_CreditHistoryHandle *hh,
                                      &td->reserve_pub),
         GNUNET_JSON_spec_string ("debit_account",
                                  &td->debit_account_uri),
-        GNUNET_JSON_spec_string ("credit_account",
-                                 &td->credit_account_uri),
         GNUNET_JSON_spec_end ()
       };
       json_t *transaction = json_array_get (history_array,
@@ -130,6 +134,7 @@ parse_account_history (struct 
TALER_BANK_CreditHistoryHandle *hh,
         GNUNET_break_op (0);
         return GNUNET_SYSERR;
       }
+      td->credit_account_uri = credit_account_uri;
     }
     chr.details.ok.details_length = len;
     chr.details.ok.details = cd;
diff --git a/src/bank-lib/bank_api_debit.c b/src/bank-lib/bank_api_debit.c
index e40156ce..f3c69ce3 100644
--- a/src/bank-lib/bank_api_debit.c
+++ b/src/bank-lib/bank_api_debit.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2017--2022 Taler Systems SA
+  Copyright (C) 2017--2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
@@ -82,15 +82,21 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle 
*hh,
     .ec = TALER_EC_NONE,
     .response = history
   };
-  json_t *history_array;
+  const char *debit_account_uri;
+  const json_t *history_array;
+  struct GNUNET_JSON_Specification spec[] = {
+    GNUNET_JSON_spec_array_const ("outgoing_transactions",
+                                  &history_array),
+    GNUNET_JSON_spec_string ("debit_account",
+                             &debit_account_uri),
+    GNUNET_JSON_spec_end ()
+  };
 
-  if (NULL == (history_array = json_object_get (history,
-                                                "outgoing_transactions")))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  if (! json_is_array (history_array))
+  if (GNUNET_OK !=
+      GNUNET_JSON_parse (history,
+                         spec,
+                         NULL,
+                         NULL))
   {
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
@@ -114,8 +120,6 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle 
*hh,
                                      &td->wtid),
         GNUNET_JSON_spec_string ("credit_account",
                                  &td->credit_account_uri),
-        GNUNET_JSON_spec_string ("debit_account",
-                                 &td->debit_account_uri),
         GNUNET_JSON_spec_string ("exchange_base_url",
                                  &td->exchange_base_url),
         GNUNET_JSON_spec_end ()
@@ -132,6 +136,7 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle 
*hh,
         GNUNET_break_op (0);
         return GNUNET_SYSERR;
       }
+      td->debit_account_uri = debit_account_uri;
     }
     dhr.details.ok.details_length = len;
     dhr.details.ok.details = dd;
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index b680118f..d0fbf769 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -2479,8 +2479,6 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
                               &pos->amount),
       GNUNET_JSON_pack_string ("credit_account",
                                credit_payto),
-      GNUNET_JSON_pack_string ("debit_account",
-                               hc->payto_uri),          // FIXME #7275: 
inefficient to return this here always!
       GNUNET_JSON_pack_string ("exchange_base_url",
                                pos->subject.debit.exchange_base_url),
       GNUNET_JSON_pack_data_auto ("wtid",
@@ -2531,11 +2529,15 @@ finish:
     json_t *h = hc->history;
 
     hc->history = NULL;
-    return TALER_MHD_REPLY_JSON_PACK (connection,
-                                      MHD_HTTP_OK,
-                                      GNUNET_JSON_pack_array_steal (
-                                        "outgoing_transactions",
-                                        h));
+    return TALER_MHD_REPLY_JSON_PACK (
+      connection,
+      MHD_HTTP_OK,
+      GNUNET_JSON_pack_string (
+        "debit_account",
+        hc->payto_uri),
+      GNUNET_JSON_pack_array_steal (
+        "outgoing_transactions",
+        h));
   }
 }
 
@@ -2720,8 +2722,6 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
                                   pos->date),
       TALER_JSON_pack_amount ("amount",
                               &pos->amount),
-      GNUNET_JSON_pack_string ("credit_account",
-                               hc->payto_uri),   // FIXME #7275: inefficient 
to repeat this always here!
       GNUNET_JSON_pack_string ("debit_account",
                                pos->debit_account->payto_uri),
       GNUNET_JSON_pack_data_auto ("reserve_pub",
@@ -2771,11 +2771,15 @@ finish:
     json_t *h = hc->history;
 
     hc->history = NULL;
-    return TALER_MHD_REPLY_JSON_PACK (connection,
-                                      MHD_HTTP_OK,
-                                      GNUNET_JSON_pack_array_steal (
-                                        "incoming_transactions",
-                                        h));
+    return TALER_MHD_REPLY_JSON_PACK (
+      connection,
+      MHD_HTTP_OK,
+      GNUNET_JSON_pack_string (
+        "credit_account",
+        hc->payto_uri),
+      GNUNET_JSON_pack_array_steal (
+        "incoming_transactions",
+        h));
   }
 }
 
@@ -3293,7 +3297,7 @@ get_account_access (struct TALER_FAKEBANK_Handle *h,
   return TALER_MHD_REPLY_JSON_PACK (
     connection,
     MHD_HTTP_OK,
-    GNUNET_JSON_pack_string ("paytoUri", /* FIXME: #7300 */
+    GNUNET_JSON_pack_string ("payto_uri",
                              acc->payto_uri),
     GNUNET_JSON_pack_object_steal (
       "balance",
@@ -3907,7 +3911,7 @@ handle_bank_access (struct TALER_FAKEBANK_Handle *h,
     return TALER_MHD_REPLY_JSON_PACK (
       connection,
       MHD_HTTP_OK,
-      GNUNET_JSON_pack_array_steal ("publicAccounts", /* FIXME: #7300 */
+      GNUNET_JSON_pack_array_steal ("public_accounts",
                                     json_array ()));
   }
   if ( (0 == strncmp (url,
@@ -4253,14 +4257,14 @@ handle_anastasis_credit_history (
                 TALER_amount2s (&pos->amount),
                 subject);
     trans = GNUNET_JSON_PACK (
+      GNUNET_JSON_pack_string ("type",
+                               "RESERVE"),
       GNUNET_JSON_pack_uint64 ("row_id",
                                pos->row_id),
       GNUNET_JSON_pack_timestamp ("date",
                                   pos->date),
       TALER_JSON_pack_amount ("amount",
                               &pos->amount),
-      GNUNET_JSON_pack_string ("credit_account",
-                               hc->payto_uri),   // FIXME #7275: inefficient 
to repeat this always here!
       GNUNET_JSON_pack_string ("debit_account",
                                pos->debit_account->payto_uri),
       GNUNET_JSON_pack_string ("subject",
@@ -4311,11 +4315,15 @@ finish:
     json_t *h = hc->history;
 
     hc->history = NULL;
-    return TALER_MHD_REPLY_JSON_PACK (connection,
-                                      MHD_HTTP_OK,
-                                      GNUNET_JSON_pack_array_steal (
-                                        "incoming_transactions",
-                                        h));
+    return TALER_MHD_REPLY_JSON_PACK (
+      connection,
+      MHD_HTTP_OK,
+      GNUNET_JSON_pack_string (
+        "credit_account",
+        hc->payto_uri),
+      GNUNET_JSON_pack_array_steal (
+        "incoming_transactions",
+        h));
   }
 }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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