gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 03/06: return only accepted currencies from /config


From: gnunet
Subject: [taler-merchant] 03/06: return only accepted currencies from /config
Date: Fri, 13 Oct 2023 21:16:58 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit a8b2456ecf47e2650f8bac1da3cc25b4ace54d24
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Fri Oct 13 09:26:25 2023 +0200

    return only accepted currencies from /config
---
 src/backend/taler-merchant-httpd_config.c    | 10 +++++-----
 src/backend/taler-merchant-httpd_exchanges.c | 18 ++++++++++++++++++
 src/backend/taler-merchant-httpd_exchanges.h | 20 +++++++++++++++-----
 3 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_config.c 
b/src/backend/taler-merchant-httpd_config.c
index 461aeb06..f1075ff5 100644
--- a/src/backend/taler-merchant-httpd_config.c
+++ b/src/backend/taler-merchant-httpd_config.c
@@ -63,11 +63,11 @@ MH_handler_config (struct TMH_RequestHandler *rh,
     {
       const struct TALER_CurrencySpecification *cspec = &TMH_cspecs[i];
 
-      /* FIXME: filter by currencies with configured exchange? */
-      GNUNET_assert (0 ==
-                     json_object_set_new (specs,
-                                          cspec->currency,
-                                          TALER_CONFIG_currency_specs_to_json 
(cspec)));
+      if (TMH_test_exchange_configured_for_currency (cspec->currency))
+        GNUNET_assert (0 ==
+                       json_object_set_new (specs,
+                                            cspec->currency,
+                                            
TALER_CONFIG_currency_specs_to_json (cspec)));
     }
     response = TALER_MHD_MAKE_JSON_PACK (
       GNUNET_JSON_pack_string ("currency",
diff --git a/src/backend/taler-merchant-httpd_exchanges.c 
b/src/backend/taler-merchant-httpd_exchanges.c
index 594809ef..170e59f8 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -1276,6 +1276,24 @@ TMH_exchange_get_trusted (TMH_ExchangeCallback cb,
 }
 
 
+bool
+TMH_test_exchange_configured_for_currency (
+  const char *currency)
+{
+  for (const struct TMH_Exchange *exchange = exchange_head;
+       NULL != exchange;
+       exchange = exchange->next)
+  {
+    if (! exchange->trusted)
+      continue;
+    if (0 == strcmp (currency,
+                     exchange->currency))
+      return true;
+  }
+  return false;
+}
+
+
 /**
  * Function called on each configuration section. Finds sections
  * about exchanges, parses the entries.
diff --git a/src/backend/taler-merchant-httpd_exchanges.h 
b/src/backend/taler-merchant-httpd_exchanges.h
index d8202922..86c8374d 100644
--- a/src/backend/taler-merchant-httpd_exchanges.h
+++ b/src/backend/taler-merchant-httpd_exchanges.h
@@ -140,8 +140,7 @@ TMH_EXCHANGES_get_master_pub (
 
 
 /**
- * Lookup current wire fee by @a exchange_url and
- * @a wire_method.
+ * Lookup current wire fee by @a exchange_url and @a wire_method.
  *
  * @param exchange the exchange to check
  * @param wire_method wire method to lookup fee by
@@ -158,9 +157,8 @@ TMH_EXCHANGES_lookup_wire_fee (
 
 
 /**
- * Check if we would trust @a ex to deposit funds
- * into our account @a wm. Checks that both @a ex
- * is trusted and that @a ex allows wire transfers
+ * Check if we would trust @a ex to deposit funds into our account @a
+ * wm. Checks that both @a ex is trusted and that @a ex allows wire transfers
  * into the account given in @a wm.
  *
  * @param exchange the exchange to check
@@ -173,4 +171,16 @@ TMH_exchange_check_debit (
   const struct TMH_WireMethod *wm);
 
 
+/**
+ * Check if we support the given currency (by having an
+ * exchange configured with it).
+ *
+ * @param currency currency to check
+ * @return true if the currency is supported
+ */
+bool
+TMH_test_exchange_configured_for_currency (
+  const char *currency);
+
+
 #endif

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