merchant

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

commit 586342ce6ecc2ac34e067ea0b745fe156fe72133
parent 98e316c848c6ba7dc86c56c9c4c4557925c43d6d
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Fri, 13 Oct 2023 09:20:42 +0200

store expected currency as per configuration with exchange

Diffstat:
Msrc/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 @@ -230,6 +230,11 @@ struct TMH_Exchange char *url; /** + * Currency offered by the exchange according to OUR configuration. + */ + char *currency; + + /** * A connection to this exchange */ struct TALER_EXCHANGE_GetKeysHandle *conn; @@ -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);