gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated: implement getting r


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: implement getting reserve_priv from configuration in test and backend
Date: Mon, 30 Oct 2017 16:24:35 +0100

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 2ea6c04  implement getting reserve_priv from configuration in test and 
backend
2ea6c04 is described below

commit 2ea6c04d9720d78c6e3466d58a54116bc1c11b51
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Oct 30 16:24:33 2017 +0100

    implement getting reserve_priv from configuration in test and backend
---
 src/backend/taler-merchant-httpd.c | 44 +++++++++++++++++++++++++++++--
 src/backend/taler-merchant-httpd.h |  2 +-
 src/lib/test_merchant_api.c        | 54 ++++++++++++++++++++++++++++++++------
 3 files changed, 89 insertions(+), 11 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index bb4b458..f53a586 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -308,6 +308,7 @@ hashmap_free (void *cls,
   json_decref (mi->j_wire);
   GNUNET_free (mi->id);
   GNUNET_free (mi->keyfile);
+  GNUNET_free_non_null (mi->tip_exchange);
   GNUNET_free (mi);
   return GNUNET_YES;
 }
@@ -539,8 +540,47 @@ instances_iterator_cb (void *cls,
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_string (iic->config,
+                                             section,
+                                             "TIP_EXCHANGE",
+                                             &mi->tip_exchange))
+  {
+    char *tip_reserves;
+
+    if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_string (iic->config,
+                                               section,
+                                               "TIP_RESERVE_PRIV",
+                                               &tip_reserves))
+    {
+      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                                 section,
+                                 "TIP_RESERVE_PRIV");
+      GNUNET_free (mi);
+      GNUNET_SCHEDULER_shutdown ();
+      return;
+    }
+    if (GNUNET_OK !=
+        GNUNET_STRINGS_string_to_data (tip_reserves,
+                                       strlen (tip_reserves),
+                                       &mi->tip_reserve,
+                                       sizeof (struct 
TALER_ReservePrivateKeyP)))
+    {
+      GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+                                 section,
+                                 "TIP_RESERVE_PRIV",
+                                 "Must decode to private EdDSA key");
+      GNUNET_free (tip_reserves);
+      GNUNET_free (mi);
+      GNUNET_SCHEDULER_shutdown ();
+      return;
+    }
+    GNUNET_free (tip_reserves);
+  }
 
-  if (GNUNET_YES != GNUNET_DISK_file_test (mi->keyfile))
+  if (GNUNET_YES !=
+      GNUNET_DISK_file_test (mi->keyfile))
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Merchant private key `%s' does not exist yet, creating it!\n",
                 mi->keyfile);
@@ -847,7 +887,7 @@ run (void *cls,
                                "DEFAULT_MAX_WIRE_FEE");
     GNUNET_SCHEDULER_shutdown ();
     return;
-  } 
+  }
 
   if (GNUNET_OK !=
       TALER_config_get_denom (config,
diff --git a/src/backend/taler-merchant-httpd.h 
b/src/backend/taler-merchant-httpd.h
index 6fd3195..6418801 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -123,7 +123,7 @@ struct MerchantInstance
    * Exchange this instance uses for tipping, NULL if tipping
    * is not supported.
    */
-  const char *tip_exchange;
+  char *tip_exchange;
 
   /**
    * What is the private key of the reserve used for signing tips by this 
exchange?
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index c163e6a..162557c 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -20,7 +20,6 @@
  * @author Marcello Stanisci
  *
  * TODO:
- * - implement getting reserve_priv from configuration in /admin/add/incoming
  * - implement tip_pickup
  * - implement spending with coins from tips
  * - add test logic for tips to main test interpreter
@@ -320,6 +319,13 @@ struct Command
       const char *reserve_reference;
 
       /**
+       * Instance to use if we are filling a tipping-reserve. In this
+       * case, @e reserve_priv is filled from the configuration instead
+       * of at random.  Usually NULL (for random @e reserve_priv).
+       */
+      const char *instance;
+
+      /**
        * String describing the amount to add to the reserve.
        */
       const char *amount;
@@ -342,13 +348,6 @@ struct Command
       struct TALER_ReservePrivateKeyP reserve_priv;
 
       /**
-       * Instance to use if we are filling a tipping-reserve. In this
-       * case, @e reserve_priv is filled from the configuration instead
-       * of at random.  Usually NULL (for random @e reserve_priv).
-       */
-      const char *instance;
-
-      /**
        * Set to the API's handle during the operation.
        */
       struct TALER_EXCHANGE_AdminAddIncomingHandle *aih;
@@ -2156,6 +2155,45 @@ interpreter_run (void *cls)
       cmd->details.admin_add_incoming.reserve_priv
         = ref->details.admin_add_incoming.reserve_priv;
     }
+    else if (NULL !=
+             cmd->details.admin_add_incoming.instance)
+    {
+      char *section;
+      char *keys;
+
+      GNUNET_asprintf (&section,
+                       "merchant-instance-%s",
+                       cmd->details.admin_add_incoming.instance);
+      if (GNUNET_OK !=
+          GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                 section,
+                                                 "tipping-reserve-priv",
+                                                 &keys))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Configuration fails to specify reserve private key in 
section %s\n",
+                    section);
+        GNUNET_free (section);
+        fail (is);
+        return;
+      }
+      if (GNUNET_OK !=
+          GNUNET_STRINGS_string_to_data (keys,
+                                         strlen (keys),
+                                         
&cmd->details.admin_add_incoming.reserve_priv,
+                                         sizeof (struct 
TALER_ReservePrivateKeyP)))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Reserve private key in section %s fails to decode to 
EdDSA key\n",
+                    section);
+        GNUNET_free (keys);
+        GNUNET_free (section);
+        fail (is);
+        return;
+      }
+      GNUNET_free (keys);
+      GNUNET_free (section);
+    }
     else
     {
       struct GNUNET_CRYPTO_EddsaPrivateKey *priv;

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



reply via email to

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