diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-12-17 22:17:02 +0800 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-12-17 22:17:02 +0800 |
commit | 21f67e8241e451a593b44562237cf9ae754c4eef (patch) | |
tree | c18377379da20e3951f4a20116bfc4d60a36a830 /src/backend | |
parent | 7891e62bf98bd884c8c993ae698f9a985dbacfbd (diff) | |
download | merchant-21f67e8241e451a593b44562237cf9ae754c4eef.tar.gz merchant-21f67e8241e451a593b44562237cf9ae754c4eef.tar.bz2 merchant-21f67e8241e451a593b44562237cf9ae754c4eef.zip |
-expand data returned from /config by merchant backend
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd_config.c | 38 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_exchanges.c | 8 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_exchanges.h | 13 |
3 files changed, 59 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c index 448b3dec..d53554f6 100644 --- a/src/backend/taler-merchant-httpd_config.c +++ b/src/backend/taler-merchant-httpd_config.c @@ -45,6 +45,38 @@ #define MERCHANT_PROTOCOL_VERSION "6:0:2" + +/** + * Callback on an exchange known to us. Does not warrant + * that the "keys" information is actually available for + * @a exchange. + * + * @param cls closure with `json_t *` array to expand + * @param url base URL of the exchange + * @param exchange internal handle for the exchange + */ +static void +add_exchange (void *cls, + const char *url, + const struct TMH_Exchange *exchange) +{ + json_t *xa = cls; + json_t *xi; + + xi = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("master_pub", + TMH_EXCHANGES_get_master_pub (exchange)), + GNUNET_JSON_pack_string ("currency", + TMH_EXCHANGES_get_currency (exchange)), + GNUNET_JSON_pack_string ("base_url", + url)); + GNUNET_assert (NULL != xi); + GNUNET_assert (0 == + json_array_append_new (xa, + xi)); +} + + MHD_RESULT MH_handler_config (struct TMH_RequestHandler *rh, struct MHD_Connection *connection, @@ -57,8 +89,12 @@ MH_handler_config (struct TMH_RequestHandler *rh, if (NULL == response) { json_t *specs = json_object (); + json_t *exchanges = json_array (); GNUNET_assert (NULL != specs); + GNUNET_assert (NULL != exchanges); + TMH_exchange_get_trusted (&add_exchange, + exchanges); for (unsigned int i=0;i<TMH_num_cspecs;i++) { const struct TALER_CurrencySpecification *cspec = &TMH_cspecs[i]; @@ -74,6 +110,8 @@ MH_handler_config (struct TMH_RequestHandler *rh, TMH_currency), GNUNET_JSON_pack_object_steal ("currencies", specs), + GNUNET_JSON_pack_array_steal ("exchanges", + exchanges), GNUNET_JSON_pack_string ("name", "taler-merchant"), GNUNET_JSON_pack_string ("version", diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c index 8a89235a..260a725a 100644 --- a/src/backend/taler-merchant-httpd_exchanges.c +++ b/src/backend/taler-merchant-httpd_exchanges.c @@ -372,6 +372,14 @@ TMH_EXCHANGES_get_master_pub ( } +const char * +TMH_EXCHANGES_get_currency ( + const struct TMH_Exchange *exchange) +{ + return exchange->currency; +} + + /** * Free data structures within @a ea, but not @a ea * pointer itself. diff --git a/src/backend/taler-merchant-httpd_exchanges.h b/src/backend/taler-merchant-httpd_exchanges.h index 86c8374d..892843f6 100644 --- a/src/backend/taler-merchant-httpd_exchanges.h +++ b/src/backend/taler-merchant-httpd_exchanges.h @@ -140,6 +140,19 @@ TMH_EXCHANGES_get_master_pub ( /** + * Return the currency of the given @a exchange. + * Will be returned from configuration for trusted + * exchanges. + * + * @param exchange exchange to get master public key for + * @return the currency of @a exchange + */ +const char * +TMH_EXCHANGES_get_currency ( + const struct TMH_Exchange *exchange); + + +/** * Lookup current wire fee by @a exchange_url and @a wire_method. * * @param exchange the exchange to check |