gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 02/06: store expected currency as per configuration wit


From: gnunet
Subject: [taler-merchant] 02/06: store expected currency as per configuration with exchange
Date: Fri, 13 Oct 2023 21:16:57 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit 586342ce6ecc2ac34e067ea0b745fe156fe72133
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Fri Oct 13 09:20:42 2023 +0200

    store expected currency as per configuration with exchange
---
 src/backend/taler-merchant-httpd_exchanges.c | 44 +++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/src/backend/taler-merchant-httpd_exchanges.c 
b/src/backend/taler-merchant-httpd_exchanges.c
index 9b41e230..594809ef 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -229,6 +229,11 @@ struct TMH_Exchange
    */
   char *url;
 
+  /**
+   * Currency offered by the exchange according to OUR configuration.
+   */
+  char *currency;
+
   /**
    * A connection to this exchange
    */
@@ -1113,6 +1118,18 @@ keys_mgmt_cb (void *cls,
     TALER_EXCHANGE_keys_decref (keys);
     return;
   }
+  if (0 != strcmp (exchange->currency,
+                   keys->currency))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "/keys response from `%s' is for currency `%s', but we 
expected `%s'\n",
+                exchange->url,
+                keys->currency,
+                exchange->currency);
+    fail_and_retry (exchange);
+    TALER_EXCHANGE_keys_decref (keys);
+    return;
+  }
   TMH_db->preflight (TMH_db->cls);
   for (unsigned int r = 0; r<MAX_RETRIES; r++)
   {
@@ -1274,6 +1291,7 @@ accept_exchanges (void *cls,
   char *url;
   char *mks;
   struct TMH_Exchange *exchange;
+  char *currency;
 
   if (GNUNET_SYSERR == trusted_exchange_count)
     return;
@@ -1292,8 +1310,24 @@ accept_exchanges (void *cls,
                                "EXCHANGE_BASE_URL");
     return;
   }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             section,
+                                             "CURRENCY",
+                                             &currency))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               section,
+                               "CURRENCY");
+    GNUNET_free (url);
+    return;
+  }
   exchange = lookup_exchange (url);
   GNUNET_free (url);
+  if (NULL == exchange->currency)
+    exchange->currency = currency;
+  else
+    GNUNET_free (currency);
   if (GNUNET_OK ==
       GNUNET_CONFIGURATION_get_value_string (cfg,
                                              section,
@@ -1383,7 +1417,15 @@ update_exchange_keys (void *cls,
     GNUNET_break (0);
     return;
   }
-
+  if (0 != strcmp (keys->currency,
+                   exchange->currency))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "/keys cached in our database are for currency `%s', but we 
expected `%s'\n",
+                keys->currency,
+                exchange->currency);
+    return;
+  }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Loaded /keys from database with %u accounts\n",
               keys->accounts_len);

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