[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.
- [taler-merchant] branch master updated (829354b0 -> 28b80ac7), gnunet, 2023/10/13
- [taler-merchant] 01/06: -first hack at multicurrency support in merchant, gnunet, 2023/10/13
- [taler-merchant] 03/06: return only accepted currencies from /config,
gnunet <=
- [taler-merchant] 02/06: store expected currency as per configuration with exchange, gnunet, 2023/10/13
- [taler-merchant] 06/06: add currency specification parsing to /config logic in libtalermerchant, gnunet, 2023/10/13
- [taler-merchant] 04/06: work towards multi-currency support, gnunet, 2023/10/13
- [taler-merchant] 05/06: more work on multicurrency support: use checks everywhere..., gnunet, 2023/10/13