gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: implement specification update #


From: gnunet
Subject: [taler-merchant] branch master updated: implement specification update #6891: return exchange_url and payto_uri as part of GET reserve/ID response
Date: Thu, 27 May 2021 12:19:11 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 5dea2c74 implement specification update #6891: return exchange_url and 
payto_uri as part of GET reserve/ID response
5dea2c74 is described below

commit 5dea2c74a16191d269c8fc7beead55c2683c887a
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu May 27 12:14:05 2021 +0200

    implement specification update #6891: return exchange_url and payto_uri as 
part of GET reserve/ID response
---
 .../taler-merchant-httpd_private-get-reserves-ID.c | 10 +++++++--
 .../taler-merchant-httpd_private-post-reserves.c   |  1 +
 src/backenddb/merchant-0002.sql                    |  7 ++++++
 src/backenddb/plugin_merchantdb_postgres.c         | 26 ++++++++++++++++++++--
 src/include/taler_merchant_service.h               |  4 ++++
 src/include/taler_merchantdb_plugin.h              |  6 +++++
 src/lib/merchant_api_get_reserve.c                 | 16 ++++++++++++-
 src/testing/testing_api_cmd_get_reserve.c          |  2 ++
 8 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c 
b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c
index 35d3707d..bb4da531 100644
--- a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c
@@ -63,6 +63,8 @@ struct GetReserveContext
  * @param committed_amount total of tips that the merchant committed to, but 
that were not
  *           picked up yet
  * @param active true if the reserve is still active (we have the private key)
+ * @param exchange_url URL of the exchange, NULL if not active
+ * @param payto_uri payto:// URI to fill the reserve, NULL if not active or 
already paid
  * @param tips_length length of the @a tips array
  * @param tips information about the tips created by this reserve
  */
@@ -75,6 +77,8 @@ handle_reserve_details (void *cls,
                         const struct TALER_Amount *picked_up_amount,
                         const struct TALER_Amount *committed_amount,
                         bool active,
+                        const char *exchange_url,
+                        const char *payto_uri,
                         unsigned int tips_length,
                         const struct TALER_MERCHANTDB_TipDetails *tips)
 {
@@ -114,7 +118,7 @@ handle_reserve_details (void *cls,
   ctx->res = TALER_MHD_reply_json_pack (
     ctx->connection,
     MHD_HTTP_OK,
-    "{s:o, s:o, s:o, s:o, s:o, s:o, s:o?, s:b}",
+    "{s:o, s:o, s:o, s:o, s:o, s:o, s:o?, s:b, s:s?, s:s?}",
     "creation_time", GNUNET_JSON_from_time_abs (creation_time_round),
     "expiration_time", GNUNET_JSON_from_time_abs (expiration_time_round),
     "merchant_initial_amount", TALER_JSON_from_amount 
(merchant_initial_amount),
@@ -122,7 +126,9 @@ handle_reserve_details (void *cls,
     "pickup_amount", TALER_JSON_from_amount (picked_up_amount),
     "committed_amount", TALER_JSON_from_amount (committed_amount),
     "tips", tips_json,
-    "active", active);
+    "active", active,
+    "exchange_url", exchange_url,
+    "payto_uri", payto_uri);
 }
 
 
diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c 
b/src/backend/taler-merchant-httpd_private-post-reserves.c
index b2cc14c6..f4f10973 100644
--- a/src/backend/taler-merchant-httpd_private-post-reserves.c
+++ b/src/backend/taler-merchant-httpd_private-post-reserves.c
@@ -373,6 +373,7 @@ TMH_private_post_reserves (const struct TMH_RequestHandler 
*rh,
                                  &reserve_priv,
                                  &reserve_pub,
                                  rc->exchange_url,
+                                 rc->payto_uri,
                                  &rc->initial_balance,
                                  rc->reserve_expiration);
     GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
diff --git a/src/backenddb/merchant-0002.sql b/src/backenddb/merchant-0002.sql
index 528b5f6d..13c1f797 100644
--- a/src/backenddb/merchant-0002.sql
+++ b/src/backenddb/merchant-0002.sql
@@ -31,5 +31,12 @@ COMMENT ON COLUMN merchant_instances.auth_salt
   IS 'salt to use when hashing Authorization header before comparing with 
auth_hash';
 
 
+-- need to preserve payto_uri for extended reserve API (easier than to 
reconstruct)
+ALTER TABLE merchant_tip_reserve_keys
+  ADD COLUMN payto_uri VARCHAR;
+COMMENT ON COLUMN merchant_tip_reserve_keys.payto_uri
+  IS 'payto:// URI used to fund the reserve, may be NULL once reserve is 
funded';
+
+
 -- Complete transaction
 COMMIT;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 2db6bca0..a81854d2 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -4543,6 +4543,7 @@ postgres_store_wire_fee_by_exchange (
  * @param reserve_priv which reserve is topped up or created
  * @param reserve_pub which reserve is topped up or created
  * @param exchange_url what URL is the exchange reachable at where the reserve 
is located
+ * @param payto_uri URI to use to fund the reserve
  * @param initial_balance how much money will be added to the reserve
  * @param expiration when does the reserve expire?
  * @return transaction status, usually
@@ -4554,6 +4555,7 @@ postgres_insert_reserve (void *cls,
                          const struct TALER_ReservePrivateKeyP *reserve_priv,
                          const struct TALER_ReservePublicKeyP *reserve_pub,
                          const char *exchange_url,
+                         const char *payto_uri,
                          const struct TALER_Amount *initial_balance,
                          struct GNUNET_TIME_Absolute expiration)
 {
@@ -4606,6 +4608,7 @@ RETRY:
       GNUNET_PQ_query_param_auto_from_type (reserve_pub),
       GNUNET_PQ_query_param_auto_from_type (reserve_priv),
       GNUNET_PQ_query_param_string (exchange_url),
+      GNUNET_PQ_query_param_string (payto_uri),
       GNUNET_PQ_query_param_end
     };
 
@@ -5072,6 +5075,8 @@ postgres_lookup_reserve (void *cls,
   struct TALER_Amount pickup_amount;
   struct TALER_Amount committed_amount;
   uint8_t active;
+  char *exchange_url = NULL;
+  char *payto_uri = NULL;
   struct GNUNET_PQ_ResultSpec rs[] = {
     GNUNET_PQ_result_spec_absolute_time ("creation_time",
                                          &creation_time),
@@ -5087,6 +5092,14 @@ postgres_lookup_reserve (void *cls,
                                  &committed_amount),
     GNUNET_PQ_result_spec_auto_from_type ("active",
                                           &active),
+    GNUNET_PQ_result_spec_allow_null (
+      GNUNET_PQ_result_spec_string ("exchange_url",
+                                    &exchange_url),
+      NULL),
+    GNUNET_PQ_result_spec_allow_null (
+      GNUNET_PQ_result_spec_string ("payto_uri",
+                                    &payto_uri),
+      NULL),
     GNUNET_PQ_result_spec_end
   };
   enum GNUNET_DB_QueryStatus qs;
@@ -5108,8 +5121,11 @@ postgres_lookup_reserve (void *cls,
         &pickup_amount,
         &committed_amount,
         (0 != active),
+        exchange_url,
+        payto_uri,
         0,
         NULL);
+    GNUNET_PQ_cleanup_result (rs);
     return qs;
   }
 
@@ -5130,6 +5146,8 @@ postgres_lookup_reserve (void *cls,
         &pickup_amount,
         &committed_amount,
         0 != active,
+        exchange_url,
+        payto_uri,
         ltc.tips_length,
         ltc.tips);
   }
@@ -5138,6 +5156,7 @@ postgres_lookup_reserve (void *cls,
   GNUNET_array_grow (ltc.tips,
                      ltc.tips_length,
                      0);
+  GNUNET_PQ_cleanup_result (rs);
   return ltc.qs;
 }
 
@@ -8213,15 +8232,16 @@ postgres_connect (void *cls)
                             "(reserve_serial"
                             ",reserve_priv"
                             ",exchange_url"
+                            ",payto_uri"
                             ")"
-                            "SELECT reserve_serial, $3, $4"
+                            "SELECT reserve_serial, $3, $4, $5"
                             " FROM merchant_tip_reserves"
                             " WHERE reserve_pub=$2"
                             "   AND merchant_serial="
                             "     (SELECT merchant_serial"
                             "        FROM merchant_instances"
                             "       WHERE merchant_id=$1)",
-                            4),
+                            5),
     /* For postgres_lookup_reserves() */
     GNUNET_PQ_make_prepare ("lookup_reserves",
                             "SELECT"
@@ -8273,6 +8293,8 @@ postgres_connect (void *cls)
                             ",tips_picked_up_val"
                             ",tips_picked_up_frac"
                             ",reserve_priv IS NOT NULL AS active"
+                            ",exchange_url"
+                            ",payto_uri"
                             " FROM merchant_tip_reserves"
                             " FULL OUTER JOIN merchant_tip_reserve_keys USING 
(reserve_serial)"
                             " WHERE reserve_pub = $2"
diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index 9e7cf8f8..cc44e660 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -3161,6 +3161,8 @@ struct TALER_MERCHANT_TipDetails
  * @param hr HTTP response details
  * @param rs reserve summary for the reserve, NULL on error
  * @param active is this reserve active (false if it was deleted but not 
purged)
+ * @param exchange_url URL of the exchange hosting the reserve, NULL if not @a 
active
+ * @param payto_uri URI to fill the reserve, NULL if not @a active or already 
filled
  * @param tips_length length of the @a reserves array
  * @param tips array with details about the tips granted, NULL on error
  */
@@ -3170,6 +3172,8 @@ typedef void
   const struct TALER_MERCHANT_HttpResponse *hr,
   const struct TALER_MERCHANT_ReserveSummary *rs,
   bool active,
+  const char *exchange_url,
+  const char *payto_uri,
   unsigned int tips_length,
   const struct TALER_MERCHANT_TipDetails tips[]);
 
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index a7d3e86e..594e3876 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -578,6 +578,8 @@ typedef void
  * @param committed_amount total of tips that the merchant committed to, but 
that were not
  *           picked up yet
  * @param active true if the reserve is still active (we have the private key)
+ * @param exchange_url base URL of the exchange hosting the reserve, NULL if 
not @a active
+ * @param payto_uri URI to use to fund the reserve, NULL if not @a active
  * @param tips_length length of the @a tips array
  * @param tips information about the tips created by this reserve
  */
@@ -591,6 +593,8 @@ typedef void
   const struct TALER_Amount *picked_up_amount,
   const struct TALER_Amount *committed_amount,
   bool active,
+  const char *exchange_url,
+  const char *payto_uri,
   unsigned int tips_length,
   const struct TALER_MERCHANTDB_TipDetails *tips);
 
@@ -1826,6 +1830,7 @@ struct TALER_MERCHANTDB_Plugin
    * @param reserve_priv which reserve is topped up or created
    * @param reserve_pub which reserve is topped up or created
    * @param exchange_url what URL is the exchange reachable at where the 
reserve is located
+   * @param payto_uri URI to fund the reserve
    * @param initial_balance how much money will be added to the reserve
    * @param expiration when does the reserve expire?
    * @return transaction status, usually
@@ -1837,6 +1842,7 @@ struct TALER_MERCHANTDB_Plugin
                     const struct TALER_ReservePrivateKeyP *reserve_priv,
                     const struct TALER_ReservePublicKeyP *reserve_pub,
                     const char *exchange_url,
+                    const char *payto_uri,
                     const struct TALER_Amount *initial_balance,
                     struct GNUNET_TIME_Absolute expiration);
 
diff --git a/src/lib/merchant_api_get_reserve.c 
b/src/lib/merchant_api_get_reserve.c
index 710bcbc4..79a3fb32 100644
--- a/src/lib/merchant_api_get_reserve.c
+++ b/src/lib/merchant_api_get_reserve.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2017, 2020 Taler Systems SA
+  Copyright (C) 2014-2021 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Lesser General Public License as published by the Free 
Software
@@ -95,6 +95,8 @@ handle_reserve_get_finished (void *cls,
     {
       struct TALER_MERCHANT_ReserveSummary rs;
       const json_t *tips;
+      const char *exchange_url = NULL;
+      const char *payto_uri = NULL;
       struct GNUNET_JSON_Specification spec[] = {
         TALER_JSON_spec_absolute_time ("creation_time",
                                        &rs.creation_time),
@@ -102,6 +104,12 @@ handle_reserve_get_finished (void *cls,
                                        &rs.expiration_time),
         GNUNET_JSON_spec_bool ("active",
                                &active),
+        GNUNET_JSON_spec_mark_optional (
+          GNUNET_JSON_spec_string ("exchange_url",
+                                   &exchange_url)),
+        GNUNET_JSON_spec_mark_optional (
+          GNUNET_JSON_spec_string ("payto_uri",
+                                   &payto_uri)),
         TALER_JSON_spec_amount ("merchant_initial_amount",
                                 &rs.merchant_initial_amount),
         TALER_JSON_spec_amount ("exchange_initial_amount",
@@ -133,6 +141,8 @@ handle_reserve_get_finished (void *cls,
                  &hr,
                  &rs,
                  false,
+                 NULL,
+                 NULL,
                  0,
                  NULL);
         TALER_MERCHANT_reserve_get_cancel (rgh);
@@ -191,6 +201,8 @@ handle_reserve_get_finished (void *cls,
                  &hr,
                  &rs,
                  active,
+                 exchange_url,
+                 payto_uri,
                  tds_length,
                  tds);
         GNUNET_free (tds);
@@ -226,6 +238,8 @@ handle_reserve_get_finished (void *cls,
            &hr,
            NULL,
            false,
+           NULL,
+           NULL,
            0,
            NULL);
   TALER_MERCHANT_reserve_get_cancel (rgh);
diff --git a/src/testing/testing_api_cmd_get_reserve.c 
b/src/testing/testing_api_cmd_get_reserve.c
index ba03eb89..539013ab 100644
--- a/src/testing/testing_api_cmd_get_reserve.c
+++ b/src/testing/testing_api_cmd_get_reserve.c
@@ -78,6 +78,8 @@ get_reserve_cb (void *cls,
                 const struct TALER_MERCHANT_HttpResponse *hr,
                 const struct TALER_MERCHANT_ReserveSummary *rs,
                 bool active,
+                const char *exchange_url,
+                const char *payto_uri,
                 unsigned int tips_length,
                 const struct TALER_MERCHANT_TipDetails tips[])
 {

-- 
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]