summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-10-08 22:51:51 +0200
committerChristian Grothoff <grothoff@gnunet.org>2023-10-08 22:51:51 +0200
commit116904c7ff6b7b9972c5c77080e0bf7cd9240217 (patch)
tree291d459f8c272ad7523d368a15bec5c2aeb90d6b
parentaab4d45dfe909afc1f6c2c1bf31143c1ec0f1e1c (diff)
downloadmerchant-116904c7ff6b7b9972c5c77080e0bf7cd9240217.tar.gz
merchant-116904c7ff6b7b9972c5c77080e0bf7cd9240217.tar.bz2
merchant-116904c7ff6b7b9972c5c77080e0bf7cd9240217.zip
dd 51 work
-rw-r--r--src/backend/taler-merchant-httpd.c20
-rw-r--r--src/backend/taler-merchant-httpd.h10
-rw-r--r--src/backend/taler-merchant-httpd_config.c15
3 files changed, 45 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index 00d49b70..dd6e5a07 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -147,6 +147,16 @@ struct GNUNET_CONTAINER_MultiHashMap *TMH_by_id_map;
struct GNUNET_TIME_Relative TMH_legal_expiration;
/**
+ * Length of the TMH_cspecs array.
+ */
+unsigned int TMH_num_cspecs;
+
+/**
+ * Rendering specs for currencies.
+ */
+struct TALER_CurrencySpecification *TMH_cspecs;
+
+/**
* The port we are running on
*/
static uint16_t port;
@@ -2161,6 +2171,16 @@ run (void *cls,
GNUNET_SCHEDULER_shutdown ();
return;
}
+
+ if (GNUNET_OK !=
+ TALER_CONFIG_parse_currencies (cfg,
+ &TMH_num_cspecs,
+ &TMH_cspecs))
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (cfg,
"merchant",
diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h
index eaeef55e..3f34557e 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -672,6 +672,16 @@ struct TMH_SuspendedConnection
extern char *TMH_currency;
/**
+ * Length of the TMH_cspecs array.
+ */
+extern unsigned int TMH_num_cspecs;
+
+/**
+ * Rendering specs for currencies.
+ */
+extern struct TALER_CurrencySpecification *TMH_cspecs;
+
+/**
* Inform the auditor for all deposit confirmations (global option)
*/
extern int TMH_force_audit;
diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c
index c398fc28..461aeb06 100644
--- a/src/backend/taler-merchant-httpd_config.c
+++ b/src/backend/taler-merchant-httpd_config.c
@@ -56,9 +56,24 @@ MH_handler_config (struct TMH_RequestHandler *rh,
(void) hc;
if (NULL == response)
{
+ json_t *specs = json_object ();
+
+ GNUNET_assert (NULL != specs);
+ for (unsigned int i=0;i<TMH_num_cspecs;i++)
+ {
+ 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)));
+ }
response = TALER_MHD_MAKE_JSON_PACK (
GNUNET_JSON_pack_string ("currency",
TMH_currency),
+ GNUNET_JSON_pack_object_steal ("currencies",
+ specs),
GNUNET_JSON_pack_string ("name",
"taler-merchant"),
GNUNET_JSON_pack_string ("version",