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: adding command to w


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: adding command to wire transfer to exchange by reading a merchant instance's (reserve tip) private key in order to construct the subject.
Date: Wed, 21 Feb 2018 12:25:05 +0100

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

marcello pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 377f35f  adding command to wire transfer to exchange by reading a 
merchant instance's (reserve tip) private key in order to construct the subject.
377f35f is described below

commit 377f35fd7da097372ca494b8b30569b73336cdf2
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Feb 21 12:23:45 2018 +0100

    adding command to wire transfer to exchange by
    reading a merchant instance's (reserve tip) private
    key in order to construct the subject.
---
 .../testing_api_cmd_fakebank_transfer.c            | 108 +++++++++++++++++++++
 src/include/taler_testing_lib.h                    |  16 +++
 2 files changed, 124 insertions(+)

diff --git a/src/exchange-lib/testing_api_cmd_fakebank_transfer.c 
b/src/exchange-lib/testing_api_cmd_fakebank_transfer.c
index 1093918..2fa67f1 100644
--- a/src/exchange-lib/testing_api_cmd_fakebank_transfer.c
+++ b/src/exchange-lib/testing_api_cmd_fakebank_transfer.c
@@ -107,6 +107,19 @@ struct FakebankTransferState
    * Exchange URL.
    */
   const char *exchange_url;
+
+  /**
+   * Merchant instance.  Sometimes used to get the tip reserve
+   * private key by reading the appropriate config section.
+   */
+  const char *instance;
+
+  /**
+   * Configuration filename.  Used to get the tip reserve key
+   * filename, used to obtain a public key to write in the
+   * transfer subject.
+   */
+  const char *config_filename;
 };
 
 
@@ -198,11 +211,58 @@ fakebank_transfer_run (void *cls,
     }
     else
     {
+      if (NULL != fts->instance)
+      {
+        GNUNET_assert (NULL != fts->config_filename);
+        char *section;
+        char *keys;
+        struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
+        struct GNUNET_CONFIGURATION_Handle *cfg;
+        cfg = GNUNET_CONFIGURATION_create ();
+        GNUNET_asprintf (&section,
+                         "merchant-instance-%s",
+                         fts->instance);
+        if (GNUNET_OK !=
+            GNUNET_CONFIGURATION_get_value_string
+              (cfg,
+               section,
+               "TIP_RESERVE_PRIV_FILENAME",
+               &keys))
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Configuration fails to specify reserve"
+                      " private key filename in section %s\n",
+                      section);
+          GNUNET_free (section);
+          TALER_TESTING_interpreter_fail (is);
+          return;
+        }
+        priv = GNUNET_CRYPTO_eddsa_key_create_from_file (keys);
+        if (NULL == priv)
+        {
+          GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+                                     section,
+                                     "TIP_RESERVE_PRIV_FILENAME",
+                                     "Failed to read private key");
+          GNUNET_free (keys);
+          GNUNET_free (section);
+          TALER_TESTING_interpreter_fail (is);
+          return;
+        }
+        fts->reserve_priv.eddsa_priv = *priv;
+        GNUNET_free (priv);
+        GNUNET_CONFIGURATION_destroy (cfg);
+      }
+      else
+      {
+      /* No referenced reserve, no instance to take priv
+       * from, no explicit subject given: create new key! */
       struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
 
       priv = GNUNET_CRYPTO_eddsa_key_create ();
       fts->reserve_priv.eddsa_priv = *priv;
       GNUNET_free (priv);
+      }
     }
     GNUNET_CRYPTO_eddsa_key_get_public
       (&fts->reserve_priv.eddsa_priv, &reserve_pub.eddsa_pub);
@@ -431,4 +491,52 @@ TALER_TESTING_cmd_fakebank_transfer_with_ref
 }
 
 
+/**
+ * Create fakebank_transfer command with custom subject.
+ *
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_fakebank_transfer_with_instance
+  (const char *label,
+   const char *amount,
+   const char *bank_url,
+   uint64_t debit_account_no,
+   uint64_t credit_account_no,
+   const char *auth_username,
+   const char *auth_password,
+   const char *instance,
+   const char *exchange_url,
+   const char *config_filename)
+{
+  struct TALER_TESTING_Command cmd;
+  struct FakebankTransferState *fts;
+
+  fts = GNUNET_new (struct FakebankTransferState);
+  fts->bank_url = bank_url;
+  fts->credit_account_no = credit_account_no;
+  fts->debit_account_no = debit_account_no;
+  fts->auth_username = auth_username;
+  fts->auth_password = auth_password;
+  fts->instance = instance;
+  fts->exchange_url = exchange_url;
+  fts->config_filename = config_filename;
+  if (GNUNET_OK !=
+      TALER_string_to_amount (amount,
+                              &fts->amount))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Failed to parse amount `%s' at %s\n",
+                amount,
+                label);
+    GNUNET_assert (0);
+  }
+  cmd.cls = fts;
+  cmd.label = label;
+  cmd.run = &fakebank_transfer_run;
+  cmd.cleanup = &fakebank_transfer_cleanup;
+  cmd.traits = &fakebank_transfer_traits;
+  return cmd;
+}
+
+
 /* end of testing_api_cmd_fakebank_transfer.c */
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 2a03b0c..4416247 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -433,6 +433,22 @@ TALER_TESTING_cmd_fakebank_transfer_with_ref
    const char *ref,
    const char *exchange_url);
 
+/**
+ * Create fakebank_transfer command with custom subject.
+ *
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_fakebank_transfer_with_instance
+  (const char *label,
+   const char *amount,
+   const char *bank_url,
+   uint64_t debit_account_no,
+   uint64_t credit_account_no,
+   const char *auth_username,
+   const char *auth_password,
+   const char *instance,
+   const char *exchange_url,
+   const char *config_filename);
 
 /**
  * Execute taler-exchange-wirewatch process.

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



reply via email to

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