summaryrefslogtreecommitdiff
path: root/src/exchange-lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-13 16:36:10 +0200
committerChristian Grothoff <christian@grothoff.org>2016-06-13 16:36:10 +0200
commit6cd71bebbf143b62c8b99adcc51e34898fd11512 (patch)
treea225894da263371453482578fd678471ea7ea7d8 /src/exchange-lib
parent2a58f470afb74046c811a4ee521176af83a52588 (diff)
downloadexchange-6cd71bebbf143b62c8b99adcc51e34898fd11512.tar.gz
exchange-6cd71bebbf143b62c8b99adcc51e34898fd11512.tar.bz2
exchange-6cd71bebbf143b62c8b99adcc51e34898fd11512.zip
implement #4569
Diffstat (limited to 'src/exchange-lib')
-rw-r--r--src/exchange-lib/exchange_api_admin.c5
-rw-r--r--src/exchange-lib/exchange_api_handle.c26
-rw-r--r--src/exchange-lib/exchange_api_handle.h11
-rw-r--r--src/exchange-lib/test_exchange_api.c1
4 files changed, 37 insertions, 6 deletions
diff --git a/src/exchange-lib/exchange_api_admin.c b/src/exchange-lib/exchange_api_admin.c
index 0452a9546..0d3129186 100644
--- a/src/exchange-lib/exchange_api_admin.c
+++ b/src/exchange-lib/exchange_api_admin.c
@@ -141,6 +141,7 @@ handle_admin_add_incoming_finished (void *cls,
* to the operators of the exchange.
*
* @param exchange the exchange handle; the exchange must be ready to operate
+ * @param admin_url URL of the administrative interface of the exchange
* @param reserve_pub public key of the reserve
* @param amount amount that was deposited
* @param execution_date when did we receive the amount
@@ -156,6 +157,7 @@ handle_admin_add_incoming_finished (void *cls,
*/
struct TALER_EXCHANGE_AdminAddIncomingHandle *
TALER_EXCHANGE_admin_add_incoming (struct TALER_EXCHANGE_Handle *exchange,
+ const char *admin_url,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount,
struct GNUNET_TIME_Absolute execution_date,
@@ -188,7 +190,8 @@ TALER_EXCHANGE_admin_add_incoming (struct TALER_EXCHANGE_Handle *exchange,
aai->exchange = exchange;
aai->cb = res_cb;
aai->cb_cls = res_cb_cls;
- aai->url = MAH_path_to_url (exchange, "/admin/add/incoming");
+ aai->url = MAH_path_to_url2 (admin_url,
+ "/admin/add/incoming");
eh = curl_easy_init ();
GNUNET_assert (NULL != (aai->json_enc =
diff --git a/src/exchange-lib/exchange_api_handle.c b/src/exchange-lib/exchange_api_handle.c
index b9104869e..318fd9e6b 100644
--- a/src/exchange-lib/exchange_api_handle.c
+++ b/src/exchange-lib/exchange_api_handle.c
@@ -779,23 +779,39 @@ MAH_handle_is_ready (struct TALER_EXCHANGE_Handle *h)
/**
* Obtain the URL to use for an API request.
*
- * @param h the exchange handle to query
+ * @param base_url base URL of the exchange (i.e. "http://exchange/")
* @param path Taler API path (i.e. "/reserve/withdraw")
* @return the full URI to use with cURL
*/
char *
-MAH_path_to_url (struct TALER_EXCHANGE_Handle *h,
+MAH_path_to_url (struct TALER_EXCHANGE_Handle *exchange,
const char *path)
{
+ return MAH_path_to_url2 (exchange->url,
+ path);
+}
+
+
+/**
+ * Obtain the URL to use for an API request.
+ *
+ * @param base_url base URL of the exchange (i.e. "http://exchange/")
+ * @param path Taler API path (i.e. "/reserve/withdraw")
+ * @return the full URI to use with cURL
+ */
+char *
+MAH_path_to_url2 (const char *base_url,
+ const char *path)
+{
char *url;
if ( ('/' == path[0]) &&
- (0 < strlen (h->url)) &&
- ('/' == h->url[strlen (h->url) - 1]) )
+ (0 < strlen (base_url)) &&
+ ('/' == base_url[strlen (base_url) - 1]) )
path++; /* avoid generating URL with "//" from concat */
GNUNET_asprintf (&url,
"%s%s",
- h->url,
+ base_url,
path);
return url;
}
diff --git a/src/exchange-lib/exchange_api_handle.h b/src/exchange-lib/exchange_api_handle.h
index 2cf2166d0..6a5661508 100644
--- a/src/exchange-lib/exchange_api_handle.h
+++ b/src/exchange-lib/exchange_api_handle.h
@@ -55,5 +55,16 @@ char *
MAH_path_to_url (struct TALER_EXCHANGE_Handle *h,
const char *path);
+/**
+ * Obtain the URL to use for an API request.
+ *
+ * @param base_url base URL of the exchange (i.e. "http://exchange/")
+ * @param path Taler API path (i.e. "/reserve/withdraw")
+ * @return the full URI to use with cURL
+ */
+char *
+MAH_path_to_url2 (const char *base_url,
+ const char *path);
+
/* end of exchange_api_handle.h */
diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c
index 337fd297b..d0e2632e0 100644
--- a/src/exchange-lib/test_exchange_api.c
+++ b/src/exchange-lib/test_exchange_api.c
@@ -1753,6 +1753,7 @@ interpreter_run (void *cls)
GNUNET_TIME_round_abs (&execution_date);
cmd->details.admin_add_incoming.aih
= TALER_EXCHANGE_admin_add_incoming (exchange,
+ "http://localhost:18080/",
&reserve_pub,
&amount,
execution_date,