summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-11 18:47:38 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-11 18:47:38 +0200
commit68f197e97e45a577f4b0a9a271efdb76bbb203d5 (patch)
tree4ef8d45973e9926b47183afbda4ed8802db69f71
parent6ff02bc7ea9ca1b39cebf7ac381dfce46f267627 (diff)
downloadmerchant-68f197e97e45a577f4b0a9a271efdb76bbb203d5.tar.gz
merchant-68f197e97e45a577f4b0a9a271efdb76bbb203d5.tar.bz2
merchant-68f197e97e45a577f4b0a9a271efdb76bbb203d5.zip
implement payment target exposition in /config, finishes #4939
-rw-r--r--src/backend/taler-merchant-httpd_config.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c
index 27b46d7d..d6f6c922 100644
--- a/src/backend/taler-merchant-httpd_config.c
+++ b/src/backend/taler-merchant-httpd_config.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2019 Taler Systems SA
+ (C) 2019, 2020 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -55,7 +55,37 @@ add_instance (void *cls,
json_t *ja = cls;
struct MerchantInstance *mi = value;
char *url;
+ json_t *pta;
+ /* Compile array of all unique wire methods supported by this
+ instance */
+ pta = json_array ();
+ GNUNET_assert (NULL != pta);
+ for (struct WireMethod *wm = mi->wm_head;
+ NULL != wm;
+ wm = wm->next)
+ {
+ int duplicate = GNUNET_NO;
+
+ if (! wm->active)
+ break;
+ /* Yes, O(n^2), but really how many bank accounts can an
+ instance realistically have for this to matter? */
+ for (struct WireMethod *pm = mi->wm_head;
+ pm != wm;
+ pm = pm->next)
+ if (0 == strcasecmp (pm->wire_method,
+ wm->wire_method))
+ {
+ duplicate = GNUNET_YES;
+ break;
+ }
+ if (duplicate)
+ continue;
+ GNUNET_assert (0 ==
+ json_array_append_new (pta,
+ json_string (wm->wire_method)));
+ }
GNUNET_asprintf (&url,
"/%s/",
mi->id);
@@ -64,14 +94,16 @@ add_instance (void *cls,
ja,
json_pack (
(NULL != mi->tip_exchange)
- ? "{s:s, s:s, s:o, s:s}"
- : "{s:s, s:s, s:o}",
+ ? "{s:s, s:s, s:o, s:o, s:s}"
+ : "{s:s, s:s, s:o, s:o}",
"name",
mi->name,
"backend_base_url",
url,
"merchant_pub",
GNUNET_JSON_from_data_auto (&mi->pubkey),
+ "payment_targets",
+ pta,
/* optional: */
"tipping_exchange_baseurl",
mi->tip_exchange)));