merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit a8b2456ecf47e2650f8bac1da3cc25b4ace54d24
parent 586342ce6ecc2ac34e067ea0b745fe156fe72133
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Fri, 13 Oct 2023 09:26:25 +0200

return only accepted currencies from /config

Diffstat:
Msrc/backend/taler-merchant-httpd_config.c | 10+++++-----
Msrc/backend/taler-merchant-httpd_exchanges.c | 18++++++++++++++++++
Msrc/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 @@ -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 @@ -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 @@ -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