diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-10-13 09:26:25 +0200 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-10-13 21:16:50 +0200 |
commit | a8b2456ecf47e2650f8bac1da3cc25b4ace54d24 (patch) | |
tree | 73bc0c6f6371120d21c91a6b104bcb1b682234ee | |
parent | 586342ce6ecc2ac34e067ea0b745fe156fe72133 (diff) |
return only accepted currencies from /config
-rw-r--r-- | src/backend/taler-merchant-httpd_config.c | 10 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_exchanges.c | 18 | ||||
-rw-r--r-- | 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 |