aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-09-23 18:39:17 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-09-23 18:39:17 +0200
commit63994abe1e2780d3a43e261090d3261e8d91a854 (patch)
tree2d2fb235f05d12fcd5d9ea9c34be29c6e37b51c5
parent7d50af6651ea4e0a15960434e1d574596552ead7 (diff)
implement instances via one base URL per instance
Previously, instances were addressed in various ways depending on then request (GET parameter, some instance_id in the POST body). With this commit, users of the merchant backend don't see the instance, they just see another base URL.
-rw-r--r--src/backend/taler-merchant-httpd.c110
-rw-r--r--src/backend/taler-merchant-httpd.h22
-rw-r--r--src/backend/taler-merchant-httpd_check-payment.c15
-rw-r--r--src/backend/taler-merchant-httpd_check-payment.h5
-rw-r--r--src/backend/taler-merchant-httpd_config.c14
-rw-r--r--src/backend/taler-merchant-httpd_config.h5
-rw-r--r--src/backend/taler-merchant-httpd_history.c10
-rw-r--r--src/backend/taler-merchant-httpd_history.h5
-rw-r--r--src/backend/taler-merchant-httpd_mhd.c15
-rw-r--r--src/backend/taler-merchant-httpd_mhd.h15
-rw-r--r--src/backend/taler-merchant-httpd_pay.c45
-rw-r--r--src/backend/taler-merchant-httpd_pay.h5
-rw-r--r--src/backend/taler-merchant-httpd_proposal.c244
-rw-r--r--src/backend/taler-merchant-httpd_proposal.h8
-rw-r--r--src/backend/taler-merchant-httpd_refund.c35
-rw-r--r--src/backend/taler-merchant-httpd_refund.h10
-rw-r--r--src/backend/taler-merchant-httpd_tip-authorize.c18
-rw-r--r--src/backend/taler-merchant-httpd_tip-authorize.h5
-rw-r--r--src/backend/taler-merchant-httpd_tip-pickup.c18
-rw-r--r--src/backend/taler-merchant-httpd_tip-pickup.h10
-rw-r--r--src/backend/taler-merchant-httpd_tip-query.c29
-rw-r--r--src/backend/taler-merchant-httpd_tip-query.h5
-rw-r--r--src/backend/taler-merchant-httpd_track-transaction.c27
-rw-r--r--src/backend/taler-merchant-httpd_track-transaction.h5
-rw-r--r--src/backend/taler-merchant-httpd_track-transfer.c14
-rw-r--r--src/backend/taler-merchant-httpd_track-transfer.h5
-rw-r--r--src/include/taler_merchant_service.h23
-rw-r--r--src/include/taler_merchant_testing_lib.h14
-rw-r--r--src/lib/merchant_api_check_payment.c6
-rw-r--r--src/lib/merchant_api_history.c16
-rw-r--r--src/lib/merchant_api_pay.c11
-rw-r--r--src/lib/merchant_api_proposal.c30
-rw-r--r--src/lib/merchant_api_refund.c19
-rw-r--r--src/lib/merchant_api_tip_authorize.c6
-rw-r--r--src/lib/merchant_api_tip_pickup.c2
-rw-r--r--src/lib/merchant_api_tip_query.c5
-rw-r--r--src/lib/merchant_api_track_transaction.c12
-rw-r--r--src/lib/merchant_api_track_transfer.c5
-rw-r--r--src/lib/test_merchant_api.c98
-rw-r--r--src/lib/test_merchant_api_twisted.c68
-rw-r--r--src/lib/testing_api_cmd_history.c7
-rw-r--r--src/lib/testing_api_cmd_pay.c2
-rw-r--r--src/lib/testing_api_cmd_proposal.c24
-rw-r--r--src/lib/testing_api_cmd_refund.c2
-rw-r--r--src/lib/testing_api_cmd_tip.c26
-rw-r--r--src/lib/testing_api_cmd_track.c2
-rw-r--r--src/merchant-tools/taler-merchant-benchmark.c33
47 files changed, 470 insertions, 640 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index 5269c4c4..0accbb85 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -301,6 +301,10 @@ url_handler (void *cls,
struct TM_HandlerContext *hc;
struct GNUNET_AsyncScopeId aid;
const char *correlation_id = NULL;
+ char *instance_id;
+ char *effective_url;
+ int ret;
+
hc = *con_cls;
@@ -338,23 +342,53 @@ url_handler (void *cls,
method,
url);
- for (unsigned int i = 0; NULL != handlers[i].url; i++)
+ /* Find out the merchant backend instance for the request.
+ * If there is an instance, remove the instance specification
+ * from the beginning of the request URL. */
+ {
+ const char *instance_prefix = "/instances/";
+ if (0 == strncmp (url, instance_prefix, strlen (instance_prefix)))
+ {
+ // url starts with "/instance/"
+ instance_id = GNUNET_strdup (url + strlen (instance_prefix));
+ char *slash = strchr (instance_id, '/');
+ if (NULL == slash)
+ {
+ GNUNET_free (instance_id);
+ return TMH_MHD_handler_static_response (&h404,
+ connection,
+ con_cls,
+ upload_data,
+ upload_data_size,
+ NULL);
+ }
+ effective_url = GNUNET_strdup (slash);
+ *slash = '\0';
+ }
+ else
+ {
+ effective_url = GNUNET_strdup (url);
+ instance_id = NULL;
+ }
+ }
+
+
+ for (unsigned int i=0;NULL != handlers[i].url;i++)
{
struct TMH_RequestHandler *rh = &handlers[i];
- if ( (0 == strcmp (url,
- rh->url)) &&
+ if ( (0 == strcasecmp (effective_url,
+ rh->url)) &&
( (NULL == rh->method) ||
(0 == strcasecmp (method,
rh->method)) ) )
{
- int ret;
-
ret = rh->handler (rh,
- connection,
- con_cls,
- upload_data,
- upload_data_size);
+ connection,
+ con_cls,
+ upload_data,
+ upload_data_size,
+ instance_id);
hc = *con_cls;
if (NULL != hc)
{
@@ -363,14 +397,18 @@ url_handler (void *cls,
* we get another callack for this request. */
hc->async_scope_id = aid;
}
+ GNUNET_free_non_null (instance_id);
return ret;
}
}
- return TMH_MHD_handler_static_response (&h404,
- connection,
- con_cls,
- upload_data,
- upload_data_size);
+ ret = TMH_MHD_handler_static_response (&h404,
+ connection,
+ con_cls,
+ upload_data,
+ upload_data_size,
+ instance_id);
+ GNUNET_free_non_null (instance_id);
+ return ret;
}
@@ -1132,23 +1170,26 @@ instances_iterator_cb (void *cls,
/**
- * Lookup a merchant instance by its name.
+ * Lookup a merchant instance by its instance ID.
*
- * @param name name of the instance to resolve
+ * @param instance_id identifier of the instance to resolve
* @return NULL if that instance is unknown to us
*/
struct MerchantInstance *
-TMH_lookup_instance (const char *name)
+TMH_lookup_instance (const char *instance_id)
{
struct GNUNET_HashCode h_instance;
- GNUNET_CRYPTO_hash (name,
- strlen (name),
+ if (NULL == instance_id)
+ instance_id = "default";
+
+ GNUNET_CRYPTO_hash (instance_id,
+ strlen (instance_id),
&h_instance);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Looking for by-id key %s of '%s' in hashmap\n",
GNUNET_h2s (&h_instance),
- name);
+ instance_id);
/* We're fine if that returns NULL, the calling routine knows how
to handle that */
return GNUNET_CONTAINER_multihashmap_get (by_id_map,
@@ -1157,35 +1198,6 @@ TMH_lookup_instance (const char *name)
/**
- * Extract merchant instance from the given JSON; if not
- * 'instance' field was found, then "default" instance is
- * returned.
- *
- * @param json the JSON to inspect; it is not required to
- * comply with any particular format. It will only be checked
- * if the field "instance" is there.
- * @return a pointer to a `struct MerchantInstance`. This will be
- * the 'default' merchant if the frontend did not specify any
- * "instance" field. The user should not care to free the returned
- * value, as it is taken from a global array that will be freed
- * by the general shutdown routine. NULL if the frontend specified
- * a wrong instance
- */
-struct MerchantInstance *
-TMH_lookup_instance_json (struct json_t *json)
-{
- struct json_t *instance;
- const char *instance_str;
-
- if (NULL == (instance = json_object_get (json, "instance")))
- instance_str = "default";
- else
- instance_str = json_string_value (instance);
- return TMH_lookup_instance (instance_str);
-}
-
-
-/**
* Iterate over locations in config in order to populate
* the location data.
*
diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h
index ee3d88fe..4e939b96 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -203,13 +203,16 @@ struct TMH_RequestHandler
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id mechant backend instance ID, or NULL if no explicit
+ * instance has been specified
* @return MHD result code
*/
int (*handler)(struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
/**
* Default response code.
@@ -351,21 +354,4 @@ struct MerchantInstance *
TMH_lookup_instance (const char *name);
-/**
- * Extract merchant instance from the given JSON
- *
- * @param json the JSON to inspect; it is not required to
- * comply with any particular format. It will only be checked
- * if the field "instance" is there.
- * @return a pointer to a #struct MerchantInstance. This will be
- * the 'default' merchant if the frontend did not specif any
- * "instance" field. The user should not care to free the returned
- * value, as it is taken from a global array that will be freed
- * by the general shutdown routine. NULL if the frontend specified
- * a wrong instance
- */
-struct MerchantInstance *
-TMH_lookup_instance_json (struct json_t *json);
-
-
#endif
diff --git a/src/backend/taler-merchant-httpd_check-payment.c b/src/backend/taler-merchant-httpd_check-payment.c
index 59ed60d1..2ba4cc4a 100644
--- a/src/backend/taler-merchant-httpd_check-payment.c
+++ b/src/backend/taler-merchant-httpd_check-payment.c
@@ -291,6 +291,8 @@ check_order_and_request_payment (struct MHD_Connection *connection,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -298,12 +300,12 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
const char *order_id;
const char *contract_url;
const char *session_id;
- const char *instance_str;
const char *fulfillment_url;
char *final_contract_url;
char *h_contract_terms_str;
@@ -315,12 +317,7 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
int ret;
int refunded;
- instance_str = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "instance");
- if (NULL == instance_str)
- instance_str = "default";
- mi = TMH_lookup_instance (instance_str);
+ mi = TMH_lookup_instance (instance_id);
if (NULL == mi)
return TMH_RESPONSE_reply_bad_request (connection,
TALER_EC_CHECK_PAYMENT_INSTANCE_UNKNOWN,
@@ -343,7 +340,7 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
{
final_contract_url = TALER_url_absolute_mhd (connection,
"/public/proposal",
- "instance", instance_str,
+ "instance", instance_id,
"order_id", order_id,
NULL);
GNUNET_assert (NULL != final_contract_url);
diff --git a/src/backend/taler-merchant-httpd_check-payment.h b/src/backend/taler-merchant-httpd_check-payment.h
index 14c2a67b..98fa3a11 100644
--- a/src/backend/taler-merchant-httpd_check-payment.h
+++ b/src/backend/taler-merchant-httpd_check-payment.h
@@ -34,6 +34,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -41,6 +43,7 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c
index 51d44729..3e7b7b39 100644
--- a/src/backend/taler-merchant-httpd_config.c
+++ b/src/backend/taler-merchant-httpd_config.c
@@ -39,6 +39,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -46,19 +48,13 @@ MH_handler_config (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
int ret;
- const char *instance_str;
struct MerchantInstance *mi;
- instance_str = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "instance");
- if (NULL == instance_str)
- instance_str = "default";
-
- mi = TMH_lookup_instance (instance_str);
+ mi = TMH_lookup_instance (instance_id);
if (NULL == mi)
return TMH_RESPONSE_reply_bad_request (connection,
diff --git a/src/backend/taler-merchant-httpd_config.h b/src/backend/taler-merchant-httpd_config.h
index cff766eb..08594a5f 100644
--- a/src/backend/taler-merchant-httpd_config.h
+++ b/src/backend/taler-merchant-httpd_config.h
@@ -31,6 +31,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -38,6 +40,7 @@ MH_handler_config (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/backend/taler-merchant-httpd_history.c b/src/backend/taler-merchant-httpd_history.c
index 2d620890..36ca7290 100644
--- a/src/backend/taler-merchant-httpd_history.c
+++ b/src/backend/taler-merchant-httpd_history.c
@@ -122,6 +122,8 @@ pd_cb (void *cls,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -129,7 +131,8 @@ MH_handler_history (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
#define LOG_INFO(...) GNUNET_log (GNUNET_ERROR_TYPE_INFO, __VA_ARGS__)
const char *str;
@@ -172,10 +175,7 @@ MH_handler_history (struct TMH_RequestHandler *rh,
}
}
- str = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "instance");
- mi = TMH_lookup_instance (NULL != str ? str : "default");
+ mi = TMH_lookup_instance (instance_id);
if (NULL == mi)
{
diff --git a/src/backend/taler-merchant-httpd_history.h b/src/backend/taler-merchant-httpd_history.h
index a06e926f..5ea2ed23 100644
--- a/src/backend/taler-merchant-httpd_history.h
+++ b/src/backend/taler-merchant-httpd_history.h
@@ -34,6 +34,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -41,7 +43,8 @@ MH_handler_history (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
/* end of taler-merchant-httpd_history.c */
#endif
diff --git a/src/backend/taler-merchant-httpd_mhd.c b/src/backend/taler-merchant-httpd_mhd.c
index e4e5329c..a17485cc 100644
--- a/src/backend/taler-merchant-httpd_mhd.c
+++ b/src/backend/taler-merchant-httpd_mhd.c
@@ -37,6 +37,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -44,7 +46,8 @@ TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
struct MHD_Response *response;
int ret;
@@ -81,6 +84,8 @@ TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -88,7 +93,8 @@ TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
const char *agpl =
"This server is licensed under the Affero GPL. You will now be redirected to the source code.";
@@ -136,6 +142,8 @@ TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -143,7 +151,8 @@ TMH_MHD_handler_send_json_pack_error (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
return TMH_RESPONSE_reply_json_pack (connection,
rh->response_code,
diff --git a/src/backend/taler-merchant-httpd_mhd.h b/src/backend/taler-merchant-httpd_mhd.h
index 5f0e69be..0ec9830b 100644
--- a/src/backend/taler-merchant-httpd_mhd.h
+++ b/src/backend/taler-merchant-httpd_mhd.h
@@ -37,6 +37,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -44,7 +46,8 @@ TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
/**
@@ -56,6 +59,8 @@ TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -63,7 +68,8 @@ TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
/**
@@ -98,6 +104,8 @@ TMH_MHD_helper_send_json_pack (struct TMH_RequestHandler *rh,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -105,7 +113,8 @@ TMH_MHD_handler_send_json_pack_error (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
index d381c7ee..e72a8e25 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -1471,27 +1471,6 @@ parse_pay (struct MHD_Connection *connection,
pc->mode = PC_MODE_PAY;
else
pc->mode = PC_MODE_ABORT_REFUND;
- pc->mi = TMH_lookup_instance_json (merchant);
- if (NULL == pc->mi)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unable to find the specified instance\n");
- GNUNET_JSON_parse_free (spec);
- if (MHD_NO ==
- TMH_RESPONSE_reply_not_found (connection,
- TALER_EC_PAY_INSTANCE_UNKNOWN,
- "Unknown instance given"))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_NO;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "/pay: picked instance %s\n",
- pc->mi->id);
-
{
const char *fulfillment_url;
struct GNUNET_JSON_Specification espec[] = {
@@ -2136,6 +2115,8 @@ handler_pay_json (struct MHD_Connection *connection,
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a
* upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -2143,7 +2124,8 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
struct PayContext *pc;
int res;
@@ -2160,6 +2142,25 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
pc->hc.cc = &pay_context_cleanup;
pc->connection = connection;
*connection_cls = pc;
+ pc->mi = TMH_lookup_instance (instance_id);
+ if (NULL == pc->mi)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to find the specified instance\n");
+ if (MHD_NO ==
+ TMH_RESPONSE_reply_not_found (connection,
+ TALER_EC_PAY_INSTANCE_UNKNOWN,
+ "Unknown instance given"))
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_NO;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "/pay: picked instance %s\n",
+ pc->mi->id);
+
}
else
{
diff --git a/src/backend/taler-merchant-httpd_pay.h b/src/backend/taler-merchant-httpd_pay.h
index d4f4958a..cffb13bb 100644
--- a/src/backend/taler-merchant-httpd_pay.h
+++ b/src/backend/taler-merchant-httpd_pay.h
@@ -40,6 +40,8 @@ MH_force_pc_resume (void);
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -47,6 +49,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c
index a93d6f17..7f61d215 100644
--- a/src/backend/taler-merchant-httpd_proposal.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -149,10 +149,10 @@ json_parse_cleanup (struct TM_HandlerContext *hc)
*/
static int
proposal_put (struct MHD_Connection *connection,
- json_t *order)
+ json_t *order,
+ const struct MerchantInstance *mi)
{
int res;
- struct MerchantInstance *mi;
struct TALER_Amount total;
const char *order_id;
const char *summary;
@@ -182,7 +182,6 @@ proposal_put (struct MHD_Connection *connection,
GNUNET_JSON_spec_end ()
};
enum GNUNET_DB_QueryStatus qs;
- const char *instance;
struct WireMethod *wm;
/* Add order_id if it doesn't exist. */
@@ -309,111 +308,81 @@ proposal_put (struct MHD_Connection *connection,
json_array ());
}
- instance = json_string_value (json_object_get (order,
- "instance"));
- if (NULL == instance)
- {
- TALER_LOG_DEBUG ("Giving 'default' instance\n");
- instance = "default";
- }
-
/* Fill in merchant information if necessary */
+ if (NULL == json_object_get (order, "merchant"))
{
- /* The frontend either fully specifieds the "merchant" field,
- * or just gives the backend the "instance" name and lets it
- * fill out. */
- struct MerchantInstance *my_mi = TMH_lookup_instance (instance);
-
- if (NULL == my_mi)
+ const char *mj = NULL;
+ const char *ma = NULL;
+ json_t *locations;
+ char *label;
+ json_t *jmerchant;
+
+ jmerchant = json_object ();
+ json_object_set_new (jmerchant,
+ "name",
+ json_string (mi->name));
+ json_object_set_new (jmerchant,
+ "instance",
+ json_string (mi->id));
+ locations = json_object_get (order,
+ "locations");
+ if (NULL != locations)
{
- TALER_LOG_WARNING ("Does 'default' instance exist?\n");
- return TMH_RESPONSE_reply_not_found
- (connection,
- TALER_EC_CONTRACT_INSTANCE_UNKNOWN,
- "merchant instance (order:instance) not found");
- }
-
- /**
- * Potential bug: if the outer 'instance' field is not
- * given and the 'merchant' object is also missing, then
- * is not possible to extract the instance!
- */
- if (NULL == json_object_get (order,
- "merchant"))
- {
- const char *mj = NULL;
- const char *ma = NULL;
- json_t *locations;
- char *label;
- json_t *jmerchant;
-
- jmerchant = json_object ();
- json_object_set_new (jmerchant,
- "name",
- json_string (my_mi->name));
- json_object_set_new (jmerchant,
- "instance",
- json_string (instance));
- locations = json_object_get (order,
- "locations");
- if (NULL != locations)
+ json_t *loca;
+ json_t *locj;
+
+ /* Handle merchant address */
+ GNUNET_assert (0 < GNUNET_asprintf (&label,
+ "%s-address",
+ mi->id));
+ loca = json_object_get (default_locations,
+ label);
+ if (NULL != loca)
+ {
+ loca = json_deep_copy (loca);
+ ma = STANDARD_LABEL_MERCHANT_ADDRESS;
+ json_object_set_new (locations,
+ ma,
+ loca);
+ json_object_set_new (jmerchant,
+ "address",
+ json_string (ma));
+ }
+ GNUNET_free (label);
+
+ /* Handle merchant jurisdiction */
+ GNUNET_assert (0 < GNUNET_asprintf (&label,
+ "%s-jurisdiction",
+ mi->id));
+ locj = json_object_get (default_locations,
+ label);
+ if (NULL != locj)
{
- json_t *loca;
- json_t *locj;
-
- /* Handle merchant address */
- GNUNET_assert (0 < GNUNET_asprintf (&label,
- "%s-address",
- my_mi->id));
- loca = json_object_get (default_locations,
- label);
- if (NULL != loca)
+ if ( (NULL != loca) &&
+ (1 == json_equal (locj,
+ loca)) )
{
- loca = json_deep_copy (loca);
- ma = STANDARD_LABEL_MERCHANT_ADDRESS;
- json_object_set_new (locations,
- ma,
- loca);
- json_object_set_new (jmerchant,
- "address",
- json_string (ma));
+ /* addresses equal, re-use */
+ mj = ma;
}
- GNUNET_free (label);
-
- /* Handle merchant jurisdiction */
- GNUNET_assert (0 < GNUNET_asprintf (&label,
- "%s-jurisdiction",
- my_mi->id));
- locj = json_object_get (default_locations,
- label);
- if (NULL != locj)
+ else
{
- if ( (NULL != loca) &&
- (1 == json_equal (locj,
- loca)) )
- {
- /* addresses equal, re-use */
- mj = ma;
- }
- else
- {
- locj = json_deep_copy (locj);
- mj = STANDARD_LABEL_MERCHANT_JURISDICTION;
- json_object_set_new (locations,
- mj,
- locj);
- }
- json_object_set_new (merchant,
- "jurisdiction",
- json_string (mj));
+ locj = json_deep_copy (locj);
+ mj = STANDARD_LABEL_MERCHANT_JURISDICTION;
+ json_object_set_new (locations,
+ mj,
+ locj);
}
- GNUNET_free (label);
- } /* have locations */
- json_object_set_new (order,
- "merchant",
- jmerchant);
- } /* needed to synthesize merchant info */
- } /* scope of 'my_mi' */
+ json_object_set_new (merchant,
+ "jurisdiction",
+ json_string (mj));
+ }
+ GNUNET_free (label);
+ } /* have locations */
+ json_object_set_new (order,
+ "merchant",
+ jmerchant);
+ } /* needed to synthesize merchant info */
/* extract fields we need to sign separately */
res = TMH_PARSE_json_data (connection,
@@ -444,45 +413,6 @@ proposal_put (struct MHD_Connection *connection,
"order:products");
}
- mi = TMH_lookup_instance_json (merchant);
-
- if (NULL == mi)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Not able to find the specified instance\n");
- GNUNET_JSON_parse_free (spec);
- return TMH_RESPONSE_reply_not_found
- (connection,
- TALER_EC_CONTRACT_INSTANCE_UNKNOWN,
- "Unknown instance (order:merchant:instance) given");
- }
-
- /* The outer instance field, and the one included
- * in the merchant object are different */
- if (0 != strcmp (mi->id,
- instance))
- {
- TALER_LOG_ERROR
- ("Inconsistent instance specified"
- " by merchant ('%s' vs '%s')\n",
- instance,
- mi->id);
-
- TALER_LOG_DEBUG ("Dump wrong order: %s\n",
- json_dumps (order,
- JSON_INDENT (1)));
-
- return TMH_RESPONSE_reply_not_found
- (connection,
- TALER_EC_CONTRACT_INSTANCE_INCONSISTENT,
- "Inconsistent instance given");
- }
-
- /* Setting the instance on the order directly is just a shortcut,
- the wallet shouldn't see that. */
- json_object_del (order, "instance");
- instance = NULL;
-
/* add fields to the contract that the backend should provide */
json_object_set (order,
"exchanges",
@@ -499,7 +429,7 @@ proposal_put (struct MHD_Connection *connection,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No wire method available for"
- " specified instance\n");
+ " instance '%s'\n", mi->id);
GNUNET_JSON_parse_free (spec);
return TMH_RESPONSE_reply_not_found
(connection,
@@ -618,10 +548,12 @@ proposal_put (struct MHD_Connection *connection,
*
* @param connection the MHD connection to handle
* @param[in,out] connection_cls the connection's closure
- * (can be updated)
+ * (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in
- * @a upload_data
+ * @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -629,10 +561,12 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
int res;
struct TMH_JsonParseContext *ctx;
+ struct MerchantInstance *mi;
json_t *root;
json_t *order;
@@ -662,6 +596,12 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh,
(NULL == root) )
return MHD_YES;
+ mi = TMH_lookup_instance (instance_id);
+ if (NULL == mi)
+ return TMH_RESPONSE_reply_not_found (connection,
+ TALER_EC_CONTRACT_INSTANCE_UNKNOWN,
+ "instance");
+
order = json_object_get (root,
"order");
if (NULL == order)
@@ -672,8 +612,7 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh,
"order");
}
else
- res = proposal_put (connection,
- order);
+ res = proposal_put (connection, order, mi);
json_decref (root);
return res;
}
@@ -691,6 +630,8 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -698,10 +639,10 @@ MH_handler_proposal_lookup (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
const char *order_id;
- const char *instance;
const char *nonce;
int res;
enum GNUNET_DB_QueryStatus qs;
@@ -710,14 +651,7 @@ MH_handler_proposal_lookup (struct TMH_RequestHandler *rh,
struct GNUNET_CRYPTO_EddsaSignature merchant_sig;
const char *stored_nonce;
- instance = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "instance");
- if (NULL == instance)
- return TMH_RESPONSE_reply_arg_missing (connection,
- TALER_EC_PARAMETER_MISSING,
- "instance");
- mi = TMH_lookup_instance (instance);
+ mi = TMH_lookup_instance (instance_id);
if (NULL == mi)
return TMH_RESPONSE_reply_not_found (connection,
TALER_EC_CONTRACT_INSTANCE_UNKNOWN,
diff --git a/src/backend/taler-merchant-httpd_proposal.h b/src/backend/taler-merchant-httpd_proposal.h
index fe5b319a..137c32a6 100644
--- a/src/backend/taler-merchant-httpd_proposal.h
+++ b/src/backend/taler-merchant-httpd_proposal.h
@@ -33,6 +33,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -40,7 +42,8 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
/**
@@ -60,5 +63,6 @@ MH_handler_proposal_lookup (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/backend/taler-merchant-httpd_refund.c b/src/backend/taler-merchant-httpd_refund.c
index 1f80491c..a20149a1 100644
--- a/src/backend/taler-merchant-httpd_refund.c
+++ b/src/backend/taler-merchant-httpd_refund.c
@@ -155,6 +155,8 @@ json_parse_cleanup (struct TM_HandlerContext *hc)
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -162,7 +164,8 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
int res;
struct TMH_JsonParseContext *ctx;
@@ -171,7 +174,6 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
json_t *contract_terms;
const char *order_id;
const char *reason;
- const char *merchant;
struct MerchantInstance *mi;
struct GNUNET_HashCode h_contract_terms;
struct TALER_MerchantRefundConfirmationPS confirmation;
@@ -180,7 +182,6 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
TALER_JSON_spec_amount ("refund", &refund),
GNUNET_JSON_spec_string ("order_id", &order_id),
GNUNET_JSON_spec_string ("reason", &reason),
- GNUNET_JSON_spec_string ("instance", &merchant),
GNUNET_JSON_spec_end ()
};
enum GNUNET_DB_QueryStatus qs;
@@ -226,11 +227,12 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
return MHD_NO;
}
- mi = TMH_lookup_instance (merchant);
+ mi = TMH_lookup_instance (instance_id);
if (NULL == mi)
{
+ GNUNET_assert (NULL != instance_id);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "No instance found\n");
+ "Instance '%s' not found\n", instance_id);
GNUNET_JSON_parse_free (spec);
json_decref (root);
return TMH_RESPONSE_reply_not_found (connection,
@@ -491,6 +493,8 @@ process_refunds_cb (void *cls,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -498,34 +502,23 @@ MH_handler_refund_lookup (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
const char *order_id;
- const char *instance;
struct GNUNET_HashCode h_contract_terms;
json_t *contract_terms;
struct MerchantInstance *mi;
enum GNUNET_DB_QueryStatus qs;
- instance = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "instance");
- if (NULL == instance)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Argument 'instance' not given\n");
- return TMH_RESPONSE_reply_arg_missing (connection,
- TALER_EC_PARAMETER_MISSING,
- "instance");
- }
-
- mi = TMH_lookup_instance (instance);
+ mi = TMH_lookup_instance (instance_id);
if (NULL == mi)
{
+ GNUNET_assert (NULL != instance_id);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unknown instance given: %s\n",
- instance);
+ instance_id);
return TMH_RESPONSE_reply_not_found (connection,
TALER_EC_REFUND_INSTANCE_UNKNOWN,
"Unknown instance given");
diff --git a/src/backend/taler-merchant-httpd_refund.h b/src/backend/taler-merchant-httpd_refund.h
index 32083273..eadd24a9 100644
--- a/src/backend/taler-merchant-httpd_refund.h
+++ b/src/backend/taler-merchant-httpd_refund.h
@@ -34,6 +34,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -41,7 +43,8 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
/**
@@ -52,6 +55,8 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -59,7 +64,8 @@ MH_handler_refund_lookup (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
/**
* Get the JSON representation of a refund.
diff --git a/src/backend/taler-merchant-httpd_tip-authorize.c b/src/backend/taler-merchant-httpd_tip-authorize.c
index 4c2451e8..1a79d772 100644
--- a/src/backend/taler-merchant-httpd_tip-authorize.c
+++ b/src/backend/taler-merchant-httpd_tip-authorize.c
@@ -45,11 +45,6 @@ struct TipAuthContext
void *json_parse_context;
/**
- * Merchant instance to use.
- */
- const char *instance;
-
- /**
* Justification to use.
*/
const char *justification;
@@ -112,6 +107,8 @@ cleanup_tac (struct TM_HandlerContext *hc)
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -119,7 +116,8 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
struct TipAuthContext *tac;
int res;
@@ -153,7 +151,6 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
{
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount ("amount", &tac->amount),
- GNUNET_JSON_spec_string ("instance", &tac->instance),
GNUNET_JSON_spec_string ("justification", &tac->justification),
GNUNET_JSON_spec_end()
};
@@ -181,12 +178,13 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
tac->parsed_json = GNUNET_YES;
}
- mi = TMH_lookup_instance (tac->instance);
+ mi = TMH_lookup_instance (instance_id);
if (NULL == mi)
{
+ GNUNET_assert (NULL != instance_id);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Instance `%s' not configured\n",
- tac->instance);
+ instance_id);
return TMH_RESPONSE_reply_not_found (connection,
TALER_EC_TIP_AUTHORIZE_INSTANCE_UNKNOWN,
"unknown instance");
@@ -195,7 +193,7 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Instance `%s' not configured for tipping\n",
- tac->instance);
+ (NULL != instance_id) ? instance_id : "default");
return TMH_RESPONSE_reply_not_found (connection,
TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP,
"exchange for tipping not configured for the instance");
diff --git a/src/backend/taler-merchant-httpd_tip-authorize.h b/src/backend/taler-merchant-httpd_tip-authorize.h
index b7c3b9a1..025b9580 100644
--- a/src/backend/taler-merchant-httpd_tip-authorize.h
+++ b/src/backend/taler-merchant-httpd_tip-authorize.h
@@ -32,6 +32,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -39,6 +41,7 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/backend/taler-merchant-httpd_tip-pickup.c b/src/backend/taler-merchant-httpd_tip-pickup.c
index eba99e38..6232c4b8 100644
--- a/src/backend/taler-merchant-httpd_tip-pickup.c
+++ b/src/backend/taler-merchant-httpd_tip-pickup.c
@@ -494,6 +494,8 @@ parse_planchet (struct MHD_Connection *connection,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -501,7 +503,8 @@ MH_handler_tip_pickup (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
int res;
struct GNUNET_HashCode tip_id;
@@ -608,6 +611,8 @@ MH_handler_tip_pickup (struct TMH_RequestHandler *rh,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -615,10 +620,10 @@ MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
struct MerchantInstance *mi;
- const char *instance_str;
const char *tip_id_str;
char *exchange_url;
json_t *extra;
@@ -630,12 +635,7 @@ MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh,
int ret;
int qs;
- instance_str = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "instance");
- if (NULL == instance_str)
- instance_str = "default";
- mi = TMH_lookup_instance (instance_str);
+ mi = TMH_lookup_instance (instance_id);
if (NULL == mi)
return TMH_RESPONSE_reply_bad_request (connection,
TALER_EC_TIP_INSTANCE_UNKNOWN,
diff --git a/src/backend/taler-merchant-httpd_tip-pickup.h b/src/backend/taler-merchant-httpd_tip-pickup.h
index 181725a7..f0e9733d 100644
--- a/src/backend/taler-merchant-httpd_tip-pickup.h
+++ b/src/backend/taler-merchant-httpd_tip-pickup.h
@@ -32,6 +32,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -39,7 +41,8 @@ MH_handler_tip_pickup (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
/**
* Manages a GET /tip-pickup call.
@@ -49,6 +52,8 @@ MH_handler_tip_pickup (struct TMH_RequestHandler *rh,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -56,7 +61,8 @@ MH_handler_tip_pickup_get (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/backend/taler-merchant-httpd_tip-query.c b/src/backend/taler-merchant-httpd_tip-query.c
index 2b90b795..bd61a3e6 100644
--- a/src/backend/taler-merchant-httpd_tip-query.c
+++ b/src/backend/taler-merchant-httpd_tip-query.c
@@ -52,6 +52,12 @@ struct TipQueryContext
const char *instance;
/**
+ * GNUNET_YES if the tip query has already been processed
+ * and we can queue the response.
+ */
+ int processed;
+
+ /**
* Context for checking the tipping reserve's status.
*/
struct CheckTipReserve ctr;
@@ -126,6 +132,8 @@ generate_final_response (struct TipQueryContext *tqc)
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -133,7 +141,8 @@ MH_handler_tip_query (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
struct TipQueryContext *tqc;
struct MerchantInstance *mi;
@@ -172,28 +181,21 @@ MH_handler_tip_query (struct TMH_RequestHandler *rh,
return res;
}
- if (NULL != tqc->instance)
+ if (GNUNET_YES == tqc->processed)
{
/* We've been here before, so TMH_check_tip_reserve() must have
finished and left the result for us. Finish processing. */
return generate_final_response (tqc);
}
- /* No error yet, so first time here, let's query the exchange */
- tqc->instance = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "instance");
- if (NULL == tqc->instance)
- return TMH_RESPONSE_reply_arg_missing (connection,
- TALER_EC_PARAMETER_MISSING,
- "instance");
- mi = TMH_lookup_instance (tqc->instance);
+ mi = TMH_lookup_instance (instance_id);
if (NULL == mi)
{
+ GNUNET_assert (NULL != instance_id);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Instance `%s' not configured\n",
- tqc->instance);
+ instance_id);
return TMH_RESPONSE_reply_not_found (connection,
TALER_EC_TIP_AUTHORIZE_INSTANCE_UNKNOWN,
"unknown instance");
@@ -202,7 +204,7 @@ MH_handler_tip_query (struct TMH_RequestHandler *rh,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Instance `%s' not configured for tipping\n",
- tqc->instance);
+ instance_id);
return TMH_RESPONSE_reply_not_found (connection,
TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP,
"exchange for tipping not configured for the instance");
@@ -236,6 +238,7 @@ MH_handler_tip_query (struct TMH_RequestHandler *rh,
}
}
+ tqc->processed = GNUNET_YES;
TMH_check_tip_reserve (&tqc->ctr,
mi->tip_exchange);
return MHD_YES;
diff --git a/src/backend/taler-merchant-httpd_tip-query.h b/src/backend/taler-merchant-httpd_tip-query.h
index f3a9ebff..10b1e1be 100644
--- a/src/backend/taler-merchant-httpd_tip-query.h
+++ b/src/backend/taler-merchant-httpd_tip-query.h
@@ -31,6 +31,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -38,6 +40,7 @@ MH_handler_tip_query (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c
index 6879612d..1376aa9a 100644
--- a/src/backend/taler-merchant-httpd_track-transaction.c
+++ b/src/backend/taler-merchant-httpd_track-transaction.c
@@ -1037,6 +1037,8 @@ find_exchange (struct TrackTransactionContext *tctx)
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -1044,13 +1046,12 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
struct TrackTransactionContext *tctx;
const char *order_id;
- const char *instance;
enum GNUNET_DB_QueryStatus qs;
- struct GNUNET_HashCode h_instance;
struct json_t *contract_terms;
if (NULL == *connection_cls)
@@ -1105,26 +1106,16 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh,
return TMH_RESPONSE_reply_arg_missing (connection,
TALER_EC_PARAMETER_MISSING,
"order_id");
- instance = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "instance");
- if (NULL == instance)
- instance = "default";
-
- GNUNET_CRYPTO_hash (instance,
- strlen (instance),
- &h_instance);
-
- tctx->mi = GNUNET_CONTAINER_multihashmap_get (by_id_map,
- &h_instance);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Tracking on behalf of instance '%s'\n",
- instance);
+ tctx->mi = TMH_lookup_instance (instance_id);
if (NULL == tctx->mi)
return TMH_RESPONSE_reply_not_found (connection,
TALER_EC_TRACK_TRANSACTION_INSTANCE_UNKNOWN,
"unknown instance");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Tracking on behalf of instance '%s'\n",
+ instance_id);
+
/* Map order id to contract terms; the objective is to get
the contract term's hashcode so as to retrieve all the
diff --git a/src/backend/taler-merchant-httpd_track-transaction.h b/src/backend/taler-merchant-httpd_track-transaction.h
index 30896bf3..7efecaa9 100644
--- a/src/backend/taler-merchant-httpd_track-transaction.h
+++ b/src/backend/taler-merchant-httpd_track-transaction.h
@@ -32,6 +32,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -39,7 +41,8 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/backend/taler-merchant-httpd_track-transfer.c b/src/backend/taler-merchant-httpd_track-transfer.c
index 54810037..f833c7e9 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.c
+++ b/src/backend/taler-merchant-httpd_track-transfer.c
@@ -881,6 +881,8 @@ proof_cb (void *cls,
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -888,12 +890,12 @@ MH_handler_track_transfer (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *instance_id)
{
struct TrackTransferContext *rctx;
const char *str;
const char *url;
- const char *instance_str;
const char *wire_method;
int ret;
enum GNUNET_DB_QueryStatus qs;
@@ -973,13 +975,7 @@ MH_handler_track_transfer (struct TMH_RequestHandler *rh,
}
rctx->wire_method = GNUNET_strdup (wire_method);
- instance_str = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "instance");
- if (NULL == instance_str)
- instance_str = "default";
-
- rctx->mi = TMH_lookup_instance (instance_str);
+ rctx->mi = TMH_lookup_instance (instance_id);
if (NULL == rctx->mi)
return TMH_RESPONSE_reply_not_found (connection,
TALER_EC_TRACK_TRANSFER_INSTANCE_UNKNOWN,
diff --git a/src/backend/taler-merchant-httpd_track-transfer.h b/src/backend/taler-merchant-httpd_track-transfer.h
index 13a173c9..8da998dc 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.h
+++ b/src/backend/taler-merchant-httpd_track-transfer.h
@@ -34,6 +34,8 @@
* @param[in,out] connection_cls the connection's closure (can be updated)
* @param upload_data upload data
* @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param instance_id merchant backend instance ID or NULL is no instance
+ * has been explicitly specified
* @return MHD result code
*/
int
@@ -41,7 +43,8 @@ MH_handler_track_transfer (struct TMH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *instance_id);
#endif
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 82ac7160..f219be61 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -66,7 +66,6 @@ struct TALER_MERCHANT_RefundLookupOperation *
TALER_MERCHANT_refund_lookup (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *order_id,
- const char *instance,
TALER_MERCHANT_RefundLookupCallback cb,
void *cb_cls);
@@ -108,7 +107,6 @@ typedef void
* @param order_id id of the order whose refund is to be increased
* @param refund amount to which increase the refund
* @param reason human-readable reason justifying the refund
- * @param instance id of the merchant instance issuing the request
* @param cb callback processing the response from /refund
* @param cb_cls closure for cb
*/
@@ -118,7 +116,6 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context *ctx,
const char *order_id,
const struct TALER_Amount *refund,
const char *reason,
- const char *instance,
TALER_MERCHANT_RefundIncreaseCallback cb,
void *cb_cls);
@@ -227,7 +224,6 @@ struct TALER_MERCHANT_ProposalLookupOperation *
TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *order_id,
- const char *instance,
const struct GNUNET_CRYPTO_EddsaPublicKey *nonce,
TALER_MERCHANT_ProposalLookupOperationCallback plo_cb,
void *plo_cb_cls);
@@ -331,7 +327,6 @@ struct TALER_MERCHANT_PayCoin
*
* @param ctx execution context
* @param merchant_url base URL of the merchant
- * @param instance which merchant instance will receive this payment
* @param h_wire hash of the merchant’s account details
* @param h_contract hash of the contact of the merchant with the customer
* @param transaction_id transaction id for the transaction between merchant and customer
@@ -352,7 +347,6 @@ struct TALER_MERCHANT_PayCoin
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
const char *merchant_url,
- const char *instance,
const struct GNUNET_HashCode *h_contract,
const struct TALER_Amount *amount,
const struct TALER_Amount *max_fee,
@@ -424,7 +418,6 @@ typedef void
*
* @param ctx execution context
* @param merchant_url base URL of the merchant
- * @param instance which merchant instance will receive this payment
* @param h_wire hash of the merchant’s account details
* @param h_contract hash of the contact of the merchant with the customer
* @param transaction_id transaction id for the transaction between merchant and customer
@@ -445,7 +438,6 @@ typedef void
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_abort (struct GNUNET_CURL_Context *ctx,
const char *merchant_url,
- const char *instance,
const struct GNUNET_HashCode *h_contract,
const struct TALER_Amount *amount,
const struct TALER_Amount *max_fee,
@@ -524,7 +516,6 @@ struct TALER_MERCHANT_PaidCoin
*
* @param ctx execution context
* @param merchant_url base URL of the merchant
- * @param instance which merchant instance will receive this payment
* @param h_contract hash of the contact of the merchant with the customer
* @param amount total value of the contract to be paid to the merchant
* @param max_fee maximum fee covered by the merchant (according to the contract)
@@ -630,7 +621,6 @@ typedef void
*
* @param ctx execution context
* @param backend_url base URL of the backend
- * @param instance which merchant instance is going to be tracked
* @param wire_method wire method used for the wire transfer
* @param wtid base32 string indicating a wtid
* @param exchange base URL of the exchange in charge of returning the wanted information
@@ -641,7 +631,6 @@ typedef void
struct TALER_MERCHANT_TrackTransferHandle *
TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
const char *wire_method,
const struct TALER_WireTransferIdentifierRawP *wtid,
const char *exchange_url,
@@ -714,7 +703,6 @@ typedef void
*
* @param ctx execution context
* @param backend_url base URL of the backend
- * @param instance which merchant instance is going to be tracked
* @param transaction_id which transaction should we trace
* @param track_transaction_cb the callback to call when a reply for this request is available
* @param track_transaction_cb_cls closure for @a track_transaction_cb
@@ -723,7 +711,6 @@ typedef void
struct TALER_MERCHANT_TrackTransactionHandle *
TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
const char *order_id,
TALER_MERCHANT_TrackTransactionCallback track_transaction_cb,
void *track_transaction_cb_cls);
@@ -763,7 +750,6 @@ typedef void
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param instance which merchant instance is performing this call
* @param start return @a delta records starting from position @a start
* @param delta return @a delta records starting from position @a start
* @param date only transactions younger than/equals to date will be returned
@@ -774,7 +760,6 @@ typedef void
struct TALER_MERCHANT_HistoryOperation *
TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
unsigned long long start,
long long delta,
struct GNUNET_TIME_Absolute date,
@@ -786,7 +771,6 @@ TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param instance which merchant instance is performing this call
* @param start return `delta` records starting from position `start`.
* If given as zero, then no initial skip of `start` records is done.
* @param delta return `delta` records starting from position `start`
@@ -798,7 +782,6 @@ TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
struct TALER_MERCHANT_HistoryOperation *
TALER_MERCHANT_history_default_start (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
long long delta,
struct GNUNET_TIME_Absolute date,
TALER_MERCHANT_HistoryOperationCallback history_cb,
@@ -849,7 +832,6 @@ typedef void
* @param pickup_url frontend URL for where the tip can be picked up
* @param next_url where the browser should proceed after picking up the tip
* @param amount amount to be handed out as a tip
- * @param instance which backend instance should create the tip (identifies the reserve and exchange)
* @param justification which justification should be stored (human-readable reason for the tip)
* @param authorize_cb callback which will work the response gotten from the backend
* @param authorize_cb_cls closure to pass to @a authorize_cb
@@ -861,7 +843,6 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx,
const char *pickup_url,
const char *next_url,
const struct TALER_Amount *amount,
- const char *instance,
const char *justification,
TALER_MERCHANT_TipAuthorizeCallback authorize_cb,
void *authorize_cb_cls);
@@ -980,7 +961,6 @@ typedef void
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param instance instance used for the transaction
* @param order_id order id to identify the payment
* @parem session_id sesion id for the payment (or NULL if the payment is not bound to a session)
* @param check_payment_cb callback which will work the response gotten from the backend
@@ -990,7 +970,6 @@ typedef void
struct TALER_MERCHANT_CheckPaymentOperation *
TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
const char *order_id,
const char *session_id,
TALER_MERCHANT_CheckPaymentCallback check_payment_cb,
@@ -1053,13 +1032,11 @@ TALER_MERCHANT_tip_query_cancel (struct TALER_MERCHANT_TipQueryOperation *tqo);
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param instance instance to query
* @return handle for this operation, NULL upon errors
*/
struct TALER_MERCHANT_TipQueryOperation *
TALER_MERCHANT_tip_query (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
TALER_MERCHANT_TipQueryCallback query_cb,
void *query_cb_cls);
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
index 8442bf24..b250af62 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -73,7 +73,6 @@ TALER_TESTING_run_merchant (const char *config_filename,
* the proposal request.
* @param http_status expected HTTP status.
* @param order the order to PUT to the merchant.
- * @param instance merchant instance performing the operation.
*
* @return the command
*/
@@ -81,8 +80,7 @@ struct TALER_TESTING_Command
TALER_TESTING_cmd_proposal (const char *label,
const char *merchant_url,
unsigned int http_status,
- const char *order,
- const char *instance);
+ const char *order);
/**
* Make a "proposal lookup" command.
*
@@ -600,7 +598,6 @@ TALER_TESTING_get_trait_refund_entry
* the reserve from which the tip is going to be gotten.
* @param http_status the HTTP response code which is expected
* for this operation.
- * @param instance which merchant instance is running this CMD.
* @param justification human-readable justification for this
* tip authorization.
* @param amount the amount to authorize for tipping.
@@ -612,7 +609,6 @@ TALER_TESTING_cmd_tip_authorize_with_ec
const char *merchant_url,
const char *exchange_url,
unsigned int http_status,
- const char *instance,
const char *justification,
const char *amount,
enum TALER_ErrorCode ec);
@@ -642,7 +638,6 @@ TALER_TESTING_cmd_tip_authorize_fake
* the reserve from which the tip is going to be gotten.
* @param http_status the HTTP response code which is expected
* for this operation.
- * @param instance which merchant instance is running this CMD.
* @param justification human-readable justification for this
* tip authorization.
* @param amount the amount to authorize for tipping.
@@ -652,7 +647,6 @@ TALER_TESTING_cmd_tip_authorize (const char *label,
const char *merchant_url,
const char *exchange_url,
unsigned int http_status,
- const char *instance,
const char *justification,
const char *amount);
@@ -664,13 +658,11 @@ TALER_TESTING_cmd_tip_authorize (const char *label,
* server the /tip-query request.
* @param http_status expected HTTP response code for the
* /tip-query request.
- * @param instance the merchant instance running this CMD.
*/
struct TALER_TESTING_Command
TALER_TESTING_cmd_tip_query (const char *label,
const char *merchant_url,
- unsigned int http_status,
- const char *instance);
+ unsigned int http_status);
/**
* Define a /tip-query CMD equipped with a expected amount.
*
@@ -679,7 +671,6 @@ TALER_TESTING_cmd_tip_query (const char *label,
* server the /tip-query request.
* @param http_status expected HTTP response code for the
* /tip-query request.
- * @param instance the merchant instance running this CMD.
* @param expected_amount_picked_up expected amount already
* picked up.
* @param expected_amount_authorized expected amount that was
@@ -691,7 +682,6 @@ TALER_TESTING_cmd_tip_query_with_amounts
(const char *label,
const char *merchant_url,
unsigned int http_status,
- const char *instance,
const char *expected_amount_picked_up,
const char *expected_amount_authorized,
const char *expected_amount_available);
diff --git a/src/lib/merchant_api_check_payment.c b/src/lib/merchant_api_check_payment.c
index 8c057072..8848686d 100644
--- a/src/lib/merchant_api_check_payment.c
+++ b/src/lib/merchant_api_check_payment.c
@@ -174,7 +174,6 @@ handle_check_payment_finished (void *cls,
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param instance instance used for the transaction
* @param order_id order id to identify the payment
* @parem session_id sesion id for the payment (or NULL if the payment is not bound to a session)
* @param check_payment_cb callback which will work the response gotten from the backend
@@ -184,7 +183,6 @@ handle_check_payment_finished (void *cls,
struct TALER_MERCHANT_CheckPaymentOperation *
TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
const char *order_id,
const char *session_id,
TALER_MERCHANT_CheckPaymentCallback check_payment_cb,
@@ -194,15 +192,13 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx,
CURL *eh;
GNUNET_assert (NULL != backend_url);
- GNUNET_assert (NULL != instance);
GNUNET_assert (NULL != order_id);
cpo = GNUNET_new (struct TALER_MERCHANT_CheckPaymentOperation);
cpo->ctx = ctx;
cpo->cb = check_payment_cb;
cpo->cb_cls = check_payment_cb_cls;
- cpo->url = TALER_url_join (backend_url, "/check-payment",
- "instance", instance,
+ cpo->url = TALER_url_join (backend_url, "check-payment",
"order_id", order_id,
"session_id", session_id,
NULL);
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
index bab8d82a..d1cbfcfa 100644
--- a/src/lib/merchant_api_history.c
+++ b/src/lib/merchant_api_history.c
@@ -153,7 +153,6 @@ history_raw_cb (void *cls,
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param instance which merchant instance is performing this call
* @param start return `delta` records starting from position `start`.
* If given as zero, then no initial skip of `start` records is done.
* @param use_default_start do NOT include the 'start' argument in URL.
@@ -166,7 +165,6 @@ history_raw_cb (void *cls,
static struct TALER_MERCHANT_HistoryOperation *
TALER_MERCHANT_history2 (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
unsigned long long start,
int use_default_start,
long long delta,
@@ -184,21 +182,19 @@ TALER_MERCHANT_history2 (struct GNUNET_CURL_Context *ctx,
ho->cb = history_cb;
ho->cb_cls = history_cb_cls;
seconds = date.abs_value_us / 1000LL / 1000LL;
- base = TALER_url_join (backend_url, "/history", NULL);
+ base = TALER_url_join (backend_url, "history", NULL);
if (GNUNET_YES == use_default_start)
GNUNET_asprintf (&ho->url,
- "%s?date=%llu&instance=%s&delta=%lld",
+ "%s?date=%llu&delta=%lld",
base,
seconds,
- instance,
delta);
else
GNUNET_asprintf (&ho->url,
- "%s?date=%llu&instance=%s&delta=%lld&start=%llu",
+ "%s?date=%llu&delta=%lld&start=%llu",
base,
seconds,
- instance,
delta,
start);
@@ -232,7 +228,6 @@ TALER_MERCHANT_history2 (struct GNUNET_CURL_Context *ctx,
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param instance which merchant instance is performing this call
* @param start return `delta` records starting from position
* `start`. If given as zero, then no initial skip of
* `start` records is done.
@@ -249,7 +244,6 @@ struct TALER_MERCHANT_HistoryOperation *
TALER_MERCHANT_history_default_start
(struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
long long delta,
struct GNUNET_TIME_Absolute date,
TALER_MERCHANT_HistoryOperationCallback history_cb,
@@ -257,7 +251,6 @@ TALER_MERCHANT_history_default_start
{
return TALER_MERCHANT_history2 (ctx,
backend_url,
- instance,
/* fake 'start' argument: will NOT be used */
-1,
/* Specifies "no start argument" in final URL */
@@ -274,7 +267,6 @@ TALER_MERCHANT_history_default_start
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param instance which merchant instance is performing this call
* @param start return `delta` records starting from position
* `start`. If given as zero, then no initial skip of
* `start` records is done.
@@ -291,7 +283,6 @@ struct TALER_MERCHANT_HistoryOperation *
TALER_MERCHANT_history
(struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
unsigned long long start,
long long delta,
struct GNUNET_TIME_Absolute date,
@@ -300,7 +291,6 @@ TALER_MERCHANT_history
{
return TALER_MERCHANT_history2 (ctx,
backend_url,
- instance,
start,
GNUNET_NO,
delta,
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index 0505e950..c7919a04 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -598,7 +598,7 @@ request_pay_generic
ph->abort_cb_cls = abort_cb_cls;
ph->pay_cb = pay_cb;
ph->pay_cb_cls = pay_cb_cls;
- ph->url = TALER_url_join (merchant_url, "/public/pay", NULL);
+ ph->url = TALER_url_join (merchant_url, "public/pay", NULL);
ph->num_coins = num_coins;
ph->coins = GNUNET_new_array (num_coins,
struct TALER_MERCHANT_PaidCoin);
@@ -639,8 +639,6 @@ request_pay_generic
*
* @param ctx the execution loop context
* @param merchant_url base URL of the merchant's backend
- * @param instance which merchant instance will receive this
- * payment
* @param h_contract_terms hashcode of the proposal being paid
* @param amount total value of the contract to be paid to the
* merchant
@@ -668,7 +666,6 @@ request_pay_generic
static struct TALER_MERCHANT_Pay *
prepare_pay_generic (struct GNUNET_CURL_Context *ctx,
const char *merchant_url,
- const char *instance,
const struct GNUNET_HashCode *h_contract_terms,
const struct TALER_Amount *amount,
const struct TALER_Amount *max_fee,
@@ -774,7 +771,6 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx,
*
* @param ctx the execution loop context
* @param merchant_url base URL of the merchant's backend
- * @param instance which merchant instance will receive this payment
* @param h_contract_terms hashcode of the proposal being paid
* @param amount total value of the contract to be paid to the merchant
* @param max_fee maximum fee covered by the merchant (according to the contract)
@@ -794,7 +790,6 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx,
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
const char *merchant_url,
- const char *instance,
const struct GNUNET_HashCode *h_contract_terms,
const struct TALER_Amount *amount,
const struct TALER_Amount *max_fee,
@@ -812,7 +807,6 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
{
return prepare_pay_generic (ctx,
merchant_url,
- instance,
h_contract_terms,
amount,
max_fee,
@@ -839,7 +833,6 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
*
* @param ctx execution context
* @param merchant_url base URL of the merchant
- * @param instance which merchant instance will receive this payment
* @param h_wire hash of the merchant’s account details
* @param h_contract hash of the contact of the merchant with the customer
* @param transaction_id transaction id for the transaction between merchant and customer
@@ -860,7 +853,6 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_abort (struct GNUNET_CURL_Context *ctx,
const char *merchant_url,
- const char *instance,
const struct GNUNET_HashCode *h_contract,
const struct TALER_Amount *amount,
const struct TALER_Amount *max_fee,
@@ -880,7 +872,6 @@ TALER_MERCHANT_pay_abort (struct GNUNET_CURL_Context *ctx,
ph = prepare_pay_generic (ctx,
merchant_url,
- instance,
h_contract,
amount,
max_fee,
diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c
index 25552bc0..83371eda 100644
--- a/src/lib/merchant_api_proposal.c
+++ b/src/lib/merchant_api_proposal.c
@@ -229,7 +229,7 @@ TALER_MERCHANT_order_put
po->ctx = ctx;
po->cb = proposal_cb;
po->cb_cls = proposal_cb_cls;
- po->url = TALER_url_join (backend_url, "/order", NULL);
+ po->url = TALER_url_join (backend_url, "order", NULL);
req = json_pack ("{s:O}",
"order", (json_t *) order);
eh = curl_easy_init ();
@@ -366,7 +366,6 @@ struct TALER_MERCHANT_ProposalLookupOperation *
TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *order_id,
- const char *instance,
const struct
GNUNET_CRYPTO_EddsaPublicKey *nonce,
TALER_MERCHANT_ProposalLookupOperationCallback
@@ -375,38 +374,25 @@ TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx,
{
struct TALER_MERCHANT_ProposalLookupOperation *plo;
CURL *eh;
- char *base;
+ char *nonce_str = NULL;
plo = GNUNET_new (struct TALER_MERCHANT_ProposalLookupOperation);
plo->ctx = ctx;
plo->cb = plo_cb;
plo->cb_cls = plo_cb_cls;
- base = TALER_url_join (backend_url, "/public/proposal", NULL);
if (NULL != nonce)
{
- char *nonce_str;
plo->has_nonce = GNUNET_YES;
plo->nonce = *nonce;
nonce_str = GNUNET_STRINGS_data_to_string_alloc (nonce, sizeof (struct
GNUNET_CRYPTO_EddsaPublicKey));
- GNUNET_assert (NULL != nonce_str);
- GNUNET_asprintf (&plo->url,
- "%s?order_id=%s&instance=%s&nonce=%s",
- base,
- order_id,
- instance,
- nonce_str);
- GNUNET_free (nonce_str);
}
- else
- {
- GNUNET_asprintf (&plo->url,
- "%s?order_id=%s&instance=%s",
- base,
- order_id,
- instance);
- }
- GNUNET_free (base);
+ plo->url = TALER_url_join (backend_url, "public/proposal",
+ "order_id",
+ order_id,
+ "nonce",
+ nonce_str,
+ NULL);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"looking up proposal from %s\n",
plo->url);
diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c
index 76a01e5d..3f888099 100644
--- a/src/lib/merchant_api_refund.c
+++ b/src/lib/merchant_api_refund.c
@@ -190,7 +190,6 @@ TALER_MERCHANT_refund_increase_cancel (struct TALER_MERCHANT_RefundIncreaseOpera
* @param order_id id of the order whose refund is to be increased
* @param refund amount to which increase the refund
* @param reason human-readable reason justifying the refund
- * @param instance id of the merchant instance issuing the request
* @param cb callback processing the response from /refund
* @param cb_cls closure for cb
*/
@@ -200,7 +199,6 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context *ctx,
const char *order_id,
const struct TALER_Amount *refund,
const char *reason,
- const char *instance,
TALER_MERCHANT_RefundIncreaseCallback cb,
void *cb_cls)
{
@@ -212,12 +210,11 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context *ctx,
rio->ctx = ctx;
rio->cb = cb;
rio->cb_cls = cb_cls;
- rio->url = TALER_url_join (backend_url, "/refund", NULL);
- req = json_pack ("{s:o, s:s, s:s, s:s}",
+ rio->url = TALER_url_join (backend_url, "refund", NULL);
+ req = json_pack ("{s:o, s:s, s:s}",
"refund", TALER_JSON_from_amount (refund),
"order_id", order_id,
- "reason", reason,
- "instance", instance);
+ "reason", reason);
eh = curl_easy_init ();
if (GNUNET_OK != TALER_curl_easy_post (&rio->post_ctx,
@@ -333,26 +330,18 @@ struct TALER_MERCHANT_RefundLookupOperation *
TALER_MERCHANT_refund_lookup (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *order_id,
- const char *instance,
TALER_MERCHANT_RefundLookupCallback cb,
void *cb_cls)
{
struct TALER_MERCHANT_RefundLookupOperation *rlo;
CURL *eh;
- char *base;
rlo = GNUNET_new (struct TALER_MERCHANT_RefundLookupOperation);
rlo->ctx = ctx;
rlo->cb = cb;
rlo->cb_cls = cb_cls;
- base = TALER_url_join (backend_url, "/public/refund", NULL);
- GNUNET_asprintf (&rlo->url,
- "%s?instance=%s&order_id=%s",
- base,
- instance,
- order_id);
- GNUNET_free (base);
+ rlo->url = TALER_url_join (backend_url, "public/refund", "order_id", order_id, NULL);
eh = curl_easy_init ();
if (CURLE_OK != curl_easy_setopt (eh,
CURLOPT_URL,
diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c
index f79064a6..582c9a4e 100644
--- a/src/lib/merchant_api_tip_authorize.c
+++ b/src/lib/merchant_api_tip_authorize.c
@@ -179,7 +179,6 @@ handle_tip_authorize_finished (void *cls,
* @param pickup_url frontend URL for where the tip can be picked up
* @param next_url where the browser should proceed after picking up the tip
* @param amount amount to be handed out as a tip
- * @param instance which backend instance should create the tip (identifies the reserve and exchange)
* @param justification which justification should be stored (human-readable reason for the tip)
* @param authorize_cb callback which will work the response gotten from the backend
* @param authorize_cb_cls closure to pass to @a authorize_cb
@@ -191,7 +190,6 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx,
const char *pickup_url,
const char *next_url,
const struct TALER_Amount *amount,
- const char *instance,
const char *justification,
TALER_MERCHANT_TipAuthorizeCallback authorize_cb,
void *authorize_cb_cls)
@@ -204,16 +202,14 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx,
tao->ctx = ctx;
tao->cb = authorize_cb;
tao->cb_cls = authorize_cb_cls;
- tao->url = TALER_url_join (backend_url, "/tip-authorize", NULL);
+ tao->url = TALER_url_join (backend_url, "tip-authorize", NULL);
te_obj = json_pack ("{"
" s:o," /* amount */
- " s:s," /* instance */
" s:s," /* justification */
" s:s," /* pickup_url */
" s:s," /* next_url */
"}",
"amount", TALER_JSON_from_amount (amount),
- "instance", instance,
"justification", justification,
"pickup_url", pickup_url,
"next_url", next_url);
diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c
index e49151bc..116b994c 100644
--- a/src/lib/merchant_api_tip_pickup.c
+++ b/src/lib/merchant_api_tip_pickup.c
@@ -288,7 +288,7 @@ TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx,
tpo->cb_cls = pickup_cb_cls;
tpo->url = TALER_url_join (backend_url,
- "/public/tip-pickup",
+ "public/tip-pickup",
NULL);
eh = curl_easy_init ();
if (GNUNET_OK != TALER_curl_easy_post (&tpo->post_ctx,
diff --git a/src/lib/merchant_api_tip_query.c b/src/lib/merchant_api_tip_query.c
index d02de8b1..3887390b 100644
--- a/src/lib/merchant_api_tip_query.c
+++ b/src/lib/merchant_api_tip_query.c
@@ -187,13 +187,11 @@ handle_tip_query_finished (void *cls,
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
- * @param instance instance to query
* @return handle for this operation, NULL upon errors
*/
struct TALER_MERCHANT_TipQueryOperation *
TALER_MERCHANT_tip_query (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
TALER_MERCHANT_TipQueryCallback query_cb,
void *query_cb_cls)
{
@@ -204,8 +202,7 @@ TALER_MERCHANT_tip_query (struct GNUNET_CURL_Context *ctx,
tqo->ctx = ctx;
tqo->cb = query_cb;
tqo->cb_cls = query_cb_cls;
- tqo->url = TALER_url_join (backend_url, "/tip-query",
- "instance", instance,
+ tqo->url = TALER_url_join (backend_url, "tip-query",
NULL);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
diff --git a/src/lib/merchant_api_track_transaction.c b/src/lib/merchant_api_track_transaction.c
index 32393ece..e5cac2bb 100644
--- a/src/lib/merchant_api_track_transaction.c
+++ b/src/lib/merchant_api_track_transaction.c
@@ -134,7 +134,6 @@ handle_track_transaction_finished (void *cls,
*
* @param ctx execution context
* @param backend_url base URL of the backend
- * @param instance which merchant instance is going to be tracked
* @param order_id order id pointing to the transaction being tracked
* @param track_transaction_cb the callback to call when a reply for this request is available
* @param track_transaction_cb_cls closure for @a track_transaction_cb
@@ -143,26 +142,19 @@ handle_track_transaction_finished (void *cls,
struct TALER_MERCHANT_TrackTransactionHandle *
TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
const char *order_id,
TALER_MERCHANT_TrackTransactionCallback track_transaction_cb,
void *track_transaction_cb_cls)
{
struct TALER_MERCHANT_TrackTransactionHandle *tdo;
CURL *eh;
- char *base;
tdo = GNUNET_new (struct TALER_MERCHANT_TrackTransactionHandle);
tdo->ctx = ctx;
tdo->cb = track_transaction_cb;
tdo->cb_cls = track_transaction_cb_cls;
- base = TALER_url_join (backend_url, "/track/transaction", NULL);
- GNUNET_asprintf (&tdo->url,
- "%s?order_id=%s&instance=%s",
- base,
- order_id,
- instance);
- GNUNET_free (base);
+ tdo->url = TALER_url_join (backend_url, "track/transaction",
+ "order_id", order_id, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Requesting URL '%s'\n",
tdo->url);
diff --git a/src/lib/merchant_api_track_transfer.c b/src/lib/merchant_api_track_transfer.c
index b5105c54..df303b1b 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -219,7 +219,6 @@ handle_track_transfer_finished (void *cls,
*
* @param ctx execution context
* @param backend_url base URL of the backend
- * @param instance which merchant instance is going to be tracked
* @param wire_method wire method used for the wire transfer
* @param wtid base32 string indicating a wtid
* @param exchange_url base URL of the exchange in charge of returning the wanted information
@@ -230,7 +229,6 @@ handle_track_transfer_finished (void *cls,
struct TALER_MERCHANT_TrackTransferHandle *
TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const char *instance,
const char *wire_method,
const struct
TALER_WireTransferIdentifierRawP *wtid,
@@ -250,10 +248,9 @@ TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx,
tdo->ctx = ctx;
tdo->cb = track_transfer_cb; // very last to be called
tdo->cb_cls = track_transfer_cb_cls;
- tdo->url = TALER_url_join (backend_url, "/track/transfer",
+ tdo->url = TALER_url_join (backend_url, "track/transfer",
"wtid", wtid_str,
"exchange", exchange_url,
- "instance", instance,
"wire_method", wire_method,
NULL);
GNUNET_free (wtid_str);
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index 67df2b93..fa7a385d 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -62,6 +62,26 @@ static char *fakebank_url;
static char *merchant_url;
/**
+ * Merchant base URL for the tipping instance.
+ */
+static char *merchant_tip_instance_url;
+
+/**
+ * Merchant base URL for the tipping instance.
+ */
+static char *merchant_tip_instance_2_url;
+
+/**
+ * Merchant base URL for the tipping instance.
+ */
+static char *merchant_tip_instance_nulltip_url;
+
+/**
+ * Merchant base URL for a non-existent instance.
+ */
+static char *merchant_tip_unknown_instance_url;
+
+/**
* Merchant process.
*/
static struct GNUNET_OS_Process *merchantd;
@@ -212,8 +232,7 @@ run (void *cls,
\"summary\": \"merchant-lib testcase\",\
\"fulfillment_url\": \"https://example.com/\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:5}\"} ] }",
- NULL),
+ \"value\":\"{EUR:5}\"} ] }"),
TALER_TESTING_cmd_check_payment ("check-payment-1",
merchant_url,
@@ -287,8 +306,7 @@ run (void *cls,
\"summary\": \"useful product\",\
\"fulfillment_url\": \"https://example.com/\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:5}\"} ] }",
- NULL),
+ \"value\":\"{EUR:5}\"} ] }"),
TALER_TESTING_cmd_proposal_lookup ("fetch-proposal-2",
merchant_url,
@@ -485,8 +503,7 @@ run (void *cls,
\"summary\": \"useful product\",\
\"fulfillment_url\": \"https://example.com/\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:5}\"} ] }",
- NULL),
+ \"value\":\"{EUR:5}\"} ] }"),
/* Try to increase a non paid proposal. */
TALER_TESTING_cmd_refund_increase
@@ -551,8 +568,7 @@ run (void *cls,
\"summary\": \"merchant-lib testcase\",\
\"fulfillment_url\": \"https://example.com/\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:5}\"} ] }",
- NULL),
+ \"value\":\"{EUR:5}\"} ] }"),
TALER_TESTING_cmd_pay ("pay-unincreased-proposal",
merchant_url,
@@ -613,18 +629,16 @@ run (void *cls,
"EUR:20.04", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO),
TALER_TESTING_cmd_tip_authorize ("authorize-tip-1",
- merchant_url,
+ merchant_tip_instance_url,
exchange_url,
MHD_HTTP_OK,
- "tip",
"tip 1",
"EUR:5.01"),
TALER_TESTING_cmd_tip_authorize ("authorize-tip-2",
- merchant_url,
+ merchant_tip_instance_url,
exchange_url,
MHD_HTTP_OK,
- "tip",
"tip 2",
"EUR:5.01"),
@@ -635,51 +649,46 @@ run (void *cls,
* actually create a reserve. */
TALER_TESTING_cmd_tip_authorize_with_ec
("authorize-tip-null",
- merchant_url,
+ merchant_tip_instance_nulltip_url,
exchange_url,
MHD_HTTP_NOT_FOUND,
- "nulltip",
"tip 2",
"EUR:5.01",
TALER_EC_RESERVE_STATUS_UNKNOWN),
TALER_TESTING_cmd_tip_query ("query-tip-1",
- merchant_url,
- MHD_HTTP_OK,
- "tip"),
+ merchant_tip_instance_url,
+ MHD_HTTP_OK),
TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-2",
- merchant_url,
+ merchant_tip_instance_url,
MHD_HTTP_OK,
- "tip",
"EUR:0.0", // picked
"EUR:10.02", // auth
"EUR:20.04"),// ava
TALER_TESTING_cmd_tip_pickup ("pickup-tip-1",
- merchant_url,
+ merchant_tip_instance_url,
MHD_HTTP_OK,
"authorize-tip-1",
pickup_amounts_1),
TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-3",
- merchant_url,
+ merchant_tip_instance_url,
MHD_HTTP_OK,
- "tip",
"EUR:5.01", // picked
NULL, // auth
"EUR:15.03"),// ava
TALER_TESTING_cmd_tip_pickup ("pickup-tip-2",
- merchant_url,
+ merchant_tip_instance_url,
MHD_HTTP_OK,
"authorize-tip-2",
pickup_amounts_1),
TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-4",
- merchant_url,
+ merchant_tip_instance_url,
MHD_HTTP_OK,
- "tip",
"EUR:10.02", // pick
"EUR:10.02", // auth
"EUR:10.02"), // ava
@@ -708,20 +717,18 @@ run (void *cls,
TALER_TESTING_cmd_tip_authorize_with_ec
("authorize-tip-3-insufficient-funds",
- merchant_url,
+ merchant_tip_instance_2_url,
exchange_url,
MHD_HTTP_PRECONDITION_FAILED,
- "dtip",
"tip 3",
"EUR:2.02",
TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS),
TALER_TESTING_cmd_tip_authorize_with_ec
("authorize-tip-4-unknown-instance",
- merchant_url,
+ merchant_tip_unknown_instance_url,
exchange_url,
MHD_HTTP_NOT_FOUND,
- "unknown",
"tip 4",
"EUR:5.01",
TALER_EC_TIP_AUTHORIZE_INSTANCE_UNKNOWN),
@@ -731,14 +738,13 @@ run (void *cls,
merchant_url,
exchange_url,
MHD_HTTP_NOT_FOUND,
- "default",
"tip 5",
"EUR:5.01",
TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP),
TALER_TESTING_cmd_tip_pickup_with_ec
("pickup-tip-3-too-much",
- merchant_url,
+ merchant_tip_instance_url,
MHD_HTTP_CONFLICT,
"authorize-tip-1",
pickup_amounts_1,
@@ -749,7 +755,7 @@ run (void *cls,
TALER_TESTING_cmd_tip_pickup_with_ec
("pickup-non-existent-id",
- merchant_url,
+ merchant_tip_instance_url,
MHD_HTTP_NOT_FOUND,
"fake-tip-authorization",
pickup_amounts_1,
@@ -757,7 +763,7 @@ run (void *cls,
TALER_TESTING_cmd_proposal
("create-proposal-tip-1",
- merchant_url,
+ merchant_tip_instance_url,
MHD_HTTP_OK,
"{\"max_fee\":\
{\"currency\":\"EUR\",\
@@ -773,11 +779,10 @@ run (void *cls,
\"summary\": \"useful product\",\
\"fulfillment_url\": \"https://example.com/\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:5}\"} ] }",
- NULL),
+ \"value\":\"{EUR:5}\"} ] }"),
TALER_TESTING_cmd_pay ("deposit-tip-simple",
- merchant_url,
+ merchant_tip_instance_url,
MHD_HTTP_OK,
"create-proposal-tip-1",
"pickup-tip-1",
@@ -849,8 +854,7 @@ run (void *cls,
\"summary\": \"merchant-lib testcase\",\
\"fulfillment_url\": \"https://example.com/\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:10}\"} ] }",
- NULL),
+ \"value\":\"{EUR:10}\"} ] }"),
TALER_TESTING_cmd_pay ("pay-fail-partial-double-10",
merchant_url,
@@ -929,8 +933,7 @@ run (void *cls,
\"summary\": \"merchant-lib testcase\",\
\"fulfillment_url\": \"https://example.com/\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:10}\"} ] }",
- NULL),
+ \"value\":\"{EUR:10}\"} ] }"),
TALER_TESTING_cmd_pay ("pay-fail-partial-double-11-good",
merchant_url,
@@ -1008,7 +1011,7 @@ run (void *cls,
merchant_url,
MHD_HTTP_OK,
GNUNET_TIME_UNIT_ZERO_ABS,
- 5, /* Expected number of records */
+ 4, /* Expected number of records */
-100), /* Delta */
/**
* End the suite. Fixme: better to have a label for this
@@ -1043,6 +1046,19 @@ main (int argc,
(merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
return 77;
+ merchant_tip_instance_url = TALER_url_join (merchant_url,
+ "instances/tip/",
+ NULL);
+ merchant_tip_instance_2_url = TALER_url_join (merchant_url,
+ "instances/dtip/",
+ NULL);
+ merchant_tip_instance_nulltip_url = TALER_url_join (merchant_url,
+ "instances/nulltip/",
+ NULL);
+ merchant_tip_unknown_instance_url = TALER_url_join (merchant_url,
+ "instances/foo/",
+ NULL);
+
TALER_TESTING_cleanup_files (CONFIG_FILE);
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
diff --git a/src/lib/test_merchant_api_twisted.c b/src/lib/test_merchant_api_twisted.c
index 43f3ef6f..901823f4 100644
--- a/src/lib/test_merchant_api_twisted.c
+++ b/src/lib/test_merchant_api_twisted.c
@@ -75,6 +75,16 @@ static char *twister_exchange_url;
static char *twister_merchant_url;
/**
+ * Twister URL that proxies the merchant.
+ */
+static char *twister_merchant_url_instance_nonexistent;
+
+/**
+ * Twister URL that proxies the merchant.
+ */
+static char *twister_merchant_url_instance_tor;
+
+/**
* URL of the fakebank. Obtained from CONFIG_FILE's
* "exchange-wire-test:BANK_URI" option.
*/
@@ -238,8 +248,7 @@ run (void *cls,
\"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
\"products\": [ {\"description\":\"triggering bug 5719\",\
- \"value\":\"{EUR:1}\"} ] }",
- NULL),
+ \"value\":\"{EUR:1}\"} ] }"),
/**
* Instruct the Twister to malform the response given by
@@ -285,8 +294,7 @@ run (void *cls,
\"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:3}\"} ] }",
- NULL),
+ \"value\":\"{EUR:3}\"} ] }"),
/* Need any response code != 200. */
TALER_TESTING_cmd_hack_response_code
@@ -344,8 +352,7 @@ run (void *cls,
MHD_HTTP_BAD_REQUEST,
/* giving a valid JSON to not make it fail before
* data reaches the merchant. */
- "{\"not\": \"used\"}",
- NULL),
+ "{\"not\": \"used\"}"),
TALER_TESTING_cmd_hack_response_code
("proposal-500",
@@ -360,8 +367,7 @@ run (void *cls,
MHD_HTTP_INTERNAL_SERVER_ERROR,
/* giving a valid JSON to not make it fail before
* data reaches the merchant. */
- "{\"not\": \"used\"}",
- NULL),
+ "{\"not\": \"used\"}"),
/**
* Cause the PUT /proposal callback to be called
@@ -390,8 +396,7 @@ run (void *cls,
\"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:5}\"} ] }",
- NULL),
+ \"value\":\"{EUR:5}\"} ] }"),
/**
* Cause proposal to be invalid: this is achieved
* by deleting the "order_id" field of it.
@@ -417,20 +422,18 @@ run (void *cls,
\"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:5}\"} ] }",
- NULL),
+ \"value\":\"{EUR:5}\"} ] }"),
/**
* Cause a 404 Not Found response code,
* due to a non existing merchant instance.
*/
TALER_TESTING_cmd_proposal
("create-proposal-4",
- twister_merchant_url,
+ twister_merchant_url_instance_nonexistent,
MHD_HTTP_NOT_FOUND,
"{\"amount\":\"EUR:5\",\
\"fulfillment_url\": \"https://example.com/\",\
- \"summary\": \"merchant-lib testcase\"}",
- "non-existent-instance"),
+ \"summary\": \"merchant-lib testcase\"}"),
/* Cause a 404 Not Found from /proposal/lookup,
* due to a non existing order id being queried. */
@@ -476,8 +479,7 @@ run (void *cls,
\"fulfillment_url\": \"https://example.com/\",\
\"summary\": \"merchant-lib testcase\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:5}\"} ] }",
- NULL),
+ \"value\":\"{EUR:5}\"} ] }"),
/* Remove expected field. */
TALER_TESTING_cmd_delete_object ("remove-contract-terms",
@@ -569,7 +571,11 @@ run (void *cls,
TALER_TESTING_cmd_proposal
("create-proposal-unaggregation",
- twister_merchant_url,
+ /* Need a fresh instance in order to associate this
+ * proposal with a fresh h_wire; this way, this proposal
+ * won't get hooked by the aggregator gathering same-H_wire'd
+ * transactions. */
+ twister_merchant_url_instance_tor,
MHD_HTTP_OK,
"{\"max_fee\":\
{\"currency\":\"EUR\",\
@@ -578,7 +584,6 @@ run (void *cls,
\"refund_deadline\":\"\\/Date(2)\\/\",\
\"pay_deadline\":\"\\/Date(1)\\/\",\
\"wire_transfer_delay\":\"\\/Delay(30000)\\/\",\
- \"instance\":\"tor\",\
\"amount\":\
{\"currency\":\"EUR\",\
\"value\":5,\
@@ -586,12 +591,7 @@ run (void *cls,
\"summary\": \"unaggregated product\",\
\"fulfillment_url\": \"https://example.com/\",\
\"products\": [ {\"description\":\"unaggregated cream\",\
- \"value\":\"{EUR:5}\"} ] }",
- /* Need a fresh instance in order to associate this
- * proposal with a fresh h_wire; this way, this proposal
- * won't get hooked by the aggregator gathering same-H_wire'd
- * transactions. */
- "tor"),
+ \"value\":\"{EUR:5}\"} ] }"),
TALER_TESTING_cmd_pay
("pay-unaggregation",
@@ -652,8 +652,7 @@ run (void *cls,
\"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:2}\"} ] }",
- NULL),
+ \"value\":\"{EUR:2}\"} ] }"),
TALER_TESTING_cmd_pay ("deposit-simple-5383",
twister_merchant_url,
MHD_HTTP_OK,
@@ -744,8 +743,7 @@ run (void *cls,
\"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:3}\"} ] }",
- NULL),
+ \"value\":\"{EUR:3}\"} ] }"),
TALER_TESTING_cmd_check_payment ("check-payment-1",
twister_merchant_url,
@@ -862,8 +860,7 @@ run (void *cls,
\"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
\"products\": [ {\"description\":\"ice cream\",\
- \"value\":\"{EUR:3}\"} ] }",
- NULL),
+ \"value\":\"{EUR:3}\"} ] }"),
/* Will only pay _half_ the supposed price,
* so we'll then have the right to abort. */
@@ -948,8 +945,7 @@ run (void *cls,
\"value\":1,\
\"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
- \"products\": [ {\"description\": \"will succeed\"}] }",
- NULL),
+ \"products\": [ {\"description\": \"will succeed\"}] }"),
TALER_TESTING_cmd_proposal
("create-proposal-double-spend-1",
@@ -968,8 +964,7 @@ run (void *cls,
\"value\":1,\
\"fraction\":0},\
\"summary\": \"merchant-lib testcase\",\
- \"products\": [ {\"description\": \"will fail\"}] }",
- NULL),
+ \"products\": [ {\"description\": \"will fail\"}] }"),
TALER_TESTING_cmd_withdraw_amount
("withdraw-coin-double-spend",
@@ -1087,6 +1082,9 @@ main (int argc,
(PROXY_MERCHANT_CONFIG_FILE)))
return 77;
+ twister_merchant_url_instance_nonexistent = TALER_url_join (twister_exchange_url, "instances/foo/", NULL);
+ twister_merchant_url_instance_tor = TALER_url_join (twister_exchange_url, "instances/tor/", NULL);
+
TALER_TESTING_cleanup_files (CONFIG_FILE);
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
diff --git a/src/lib/testing_api_cmd_history.c b/src/lib/testing_api_cmd_history.c
index c9792680..6704fb93 100644
--- a/src/lib/testing_api_cmd_history.c
+++ b/src/lib/testing_api_cmd_history.c
@@ -43,11 +43,6 @@ struct HistoryState
unsigned int http_status;
/**
- * The merchant instance executing this CMD.
- */
- const char *instance;
-
- /**
* URL of the merchant backend serving the /history request.
*/
const char *merchant_url;
@@ -272,7 +267,6 @@ history_run (void *cls,
hs->ho = TALER_MERCHANT_history_default_start
(is->ctx,
hs->merchant_url,
- "default",
hs->nrows,
hs->time,
&history_cb,
@@ -282,7 +276,6 @@ history_run (void *cls,
case GNUNET_NO:
hs->ho = TALER_MERCHANT_history (is->ctx,
hs->merchant_url,
- "default",
hs->start,
hs->nrows,
hs->time,
diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c
index 7f1c82a7..3be5d8dd 100644
--- a/src/lib/testing_api_cmd_pay.c
+++ b/src/lib/testing_api_cmd_pay.c
@@ -386,7 +386,6 @@ check_payment_run (void *cls,
cps->cpo = TALER_MERCHANT_check_payment
(is->ctx,
cps->merchant_url,
- "default", // only default instance for now.
order_id,
NULL,
check_payment_cb,
@@ -854,7 +853,6 @@ _pay_run (const char *merchant_url,
ret = api_func (is->ctx,
merchant_url,
- "default", // instance
h_proposal,
&total_amount,
&max_fee,
diff --git a/src/lib/testing_api_cmd_proposal.c b/src/lib/testing_api_cmd_proposal.c
index f095f38f..f5e282c9 100644
--- a/src/lib/testing_api_cmd_proposal.c
+++ b/src/lib/testing_api_cmd_proposal.c
@@ -79,11 +79,6 @@ struct ProposalState
struct GNUNET_CRYPTO_EddsaPublicKey nonce;
/**
- * The merchant instance.
- */
- const char *instance;
-
- /**
* URL of the merchant backend.
*/
const char *merchant_url;
@@ -318,7 +313,6 @@ proposal_cb (void *cls,
(ps->is->ctx,
ps->merchant_url,
ps->order_id,
- ps->instance,
&ps->nonce,
&proposal_lookup_initial_cb,
ps)))
@@ -376,18 +370,6 @@ proposal_run (void *cls,
(GNUNET_CRYPTO_QUALITY_WEAK,
&ps->nonce,
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
- if (NULL != ps->instance)
- {
- json_t *merchant;
-
- merchant = json_object ();
- json_object_set_new (merchant,
- "instance",
- json_string (ps->instance));
- json_object_set_new (order,
- "merchant",
- merchant);
- }
ps->po = TALER_MERCHANT_order_put (is->ctx,
ps->merchant_url,
@@ -468,7 +450,6 @@ proposal_lookup_cleanup (void *cls,
* the proposal request.
* @param http_status expected HTTP status.
* @param order the order to PUT to the merchant.
- * @param instance merchant instance performing the operation.
*
* @return the command
*/
@@ -476,8 +457,7 @@ struct TALER_TESTING_Command
TALER_TESTING_cmd_proposal (const char *label,
const char *merchant_url,
unsigned int http_status,
- const char *order,
- const char *instance)
+ const char *order)
{
struct ProposalState *ps;
@@ -485,7 +465,6 @@ TALER_TESTING_cmd_proposal (const char *label,
ps->order = order;
ps->http_status = http_status;
ps->merchant_url = merchant_url;
- ps->instance = (NULL == instance) ? "default" : instance;
struct TALER_TESTING_Command cmd = {
.cls = ps,
@@ -580,7 +559,6 @@ proposal_lookup_run (void *cls,
pls->plo = TALER_MERCHANT_proposal_lookup (is->ctx,
pls->merchant_url,
order_id,
- "default",
nonce,
&proposal_lookup_cb,
pls);
diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c
index abe68f8e..f0ee31b5 100644
--- a/src/lib/testing_api_cmd_refund.c
+++ b/src/lib/testing_api_cmd_refund.c
@@ -221,7 +221,6 @@ refund_increase_run (void *cls,
ris->order_id,
&refund_amount,
ris->reason,
- "default",
&refund_increase_cb,
ris);
GNUNET_assert (NULL != ris->rio);
@@ -450,7 +449,6 @@ refund_lookup_run (void *cls,
rls->rlo = TALER_MERCHANT_refund_lookup (is->ctx,
rls->merchant_url,
rls->order_id,
- "default",
&refund_lookup_cb,
rls);
GNUNET_assert (NULL != rls->rlo);
diff --git a/src/lib/testing_api_cmd_tip.c b/src/lib/testing_api_cmd_tip.c
index 652bd95d..a5bbf2a1 100644
--- a/src/lib/testing_api_cmd_tip.c
+++ b/src/lib/testing_api_cmd_tip.c
@@ -139,11 +139,6 @@ struct TipQueryState
unsigned int http_status;
/**
- * Which merchant instance is running this CMD.
- */
- const char *instance;
-
- /**
* The handle to the current /tip-query request.
*/
struct TALER_MERCHANT_TipQueryOperation *tqo;
@@ -188,11 +183,6 @@ struct TipAuthorizeState
unsigned int http_status;
/**
- * Merchant instance running this CMD.
- */
- const char *instance;
-
- /**
* Human-readable justification for the
* tip authorization carried on by this CMD.
*/
@@ -345,7 +335,6 @@ tip_authorize_run (void *cls,
"http://merchant.com/pickup",
"http://merchant.com/continue",
&amount,
- tas->instance,
tas->justification,
tip_authorize_cb,
tas);
@@ -411,7 +400,6 @@ tip_authorize_cleanup (void *cls,
* the reserve from which the tip is going to be gotten.
* @param http_status the HTTP response code which is expected
* for this operation.
- * @param instance which merchant instance is running this CMD.
* @param justification human-readable justification for this
* tip authorization.
* @param amount the amount to authorize for tipping.
@@ -423,7 +411,6 @@ TALER_TESTING_cmd_tip_authorize_with_ec
const char *merchant_url,
const char *exchange_url,
unsigned int http_status,
- const char *instance,
const char *justification,
const char *amount,
enum TALER_ErrorCode ec)
@@ -432,7 +419,6 @@ TALER_TESTING_cmd_tip_authorize_with_ec
tas = GNUNET_new (struct TipAuthorizeState);
tas->merchant_url = merchant_url;
- tas->instance = instance;
tas->justification = justification;
tas->amount = amount;
tas->http_status = http_status;
@@ -461,7 +447,6 @@ TALER_TESTING_cmd_tip_authorize_with_ec
* the reserve from which the tip is going to be gotten.
* @param http_status the HTTP response code which is expected
* for this operation.
- * @param instance which merchant instance is running this CMD.
* @param justification human-readable justification for this
* tip authorization.
* @param amount the amount to authorize for tipping.
@@ -471,7 +456,6 @@ TALER_TESTING_cmd_tip_authorize (const char *label,
const char *merchant_url,
const char *exchange_url,
unsigned int http_status,
- const char *instance,
const char *justification,
const char *amount)
{
@@ -479,7 +463,6 @@ TALER_TESTING_cmd_tip_authorize (const char *label,
tas = GNUNET_new (struct TipAuthorizeState);
tas->merchant_url = merchant_url;
- tas->instance = instance;
tas->justification = justification;
tas->amount = amount;
tas->http_status = http_status;
@@ -631,7 +614,6 @@ tip_query_run (void *cls,
tqs->is = is;
tqs->tqo = TALER_MERCHANT_tip_query (is->ctx,
tqs->merchant_url,
- tqs->instance,
&tip_query_cb,
tqs);
GNUNET_assert (NULL != tqs->tqo);
@@ -646,7 +628,6 @@ tip_query_run (void *cls,
* server the /tip-query request.
* @param http_status expected HTTP response code for the
* /tip-query request.
- * @param instance the merchant instance running this CMD.
* @param expected_amount_picked_up expected amount already
* picked up.
* @param expected_amount_authorized expected amount that was
@@ -660,7 +641,6 @@ TALER_TESTING_cmd_tip_query_with_amounts
(const char *label,
const char *merchant_url,
unsigned int http_status,
- const char *instance,
const char *expected_amount_picked_up,
const char *expected_amount_authorized,
const char *expected_amount_available)
@@ -669,7 +649,6 @@ TALER_TESTING_cmd_tip_query_with_amounts
tqs = GNUNET_new (struct TipQueryState);
tqs->merchant_url = merchant_url;
- tqs->instance = instance;
tqs->http_status = http_status;
tqs->expected_amount_picked_up = expected_amount_picked_up;
tqs->expected_amount_authorized = expected_amount_authorized;
@@ -694,19 +673,16 @@ TALER_TESTING_cmd_tip_query_with_amounts
* server the /tip-query request.
* @param http_status expected HTTP response code for the
* /tip-query request.
- * @param instance the merchant instance running this CMD.
*/
struct TALER_TESTING_Command
TALER_TESTING_cmd_tip_query (const char *label,
const char *merchant_url,
- unsigned int http_status,
- const char *instance)
+ unsigned int http_status)
{
struct TipQueryState *tqs;
tqs = GNUNET_new (struct TipQueryState);
tqs->merchant_url = merchant_url;
- tqs->instance = instance;
tqs->http_status = http_status;
struct TALER_TESTING_Command cmd = {
diff --git a/src/lib/testing_api_cmd_track.c b/src/lib/testing_api_cmd_track.c
index 9cd4803b..1f1596a4 100644
--- a/src/lib/testing_api_cmd_track.c
+++ b/src/lib/testing_api_cmd_track.c
@@ -373,7 +373,6 @@ track_transfer_run (void *cls,
TALER_TESTING_FAIL (is);
tts->tth = TALER_MERCHANT_track_transfer (is->ctx,
tts->merchant_url,
- "default",
"x-taler-bank",
wtid,
exchange_url,
@@ -412,7 +411,6 @@ track_transaction_run (void *cls,
tts->tth = TALER_MERCHANT_track_transaction
(is->ctx,
tts->merchant_url,
- "default",
order_id,
&track_transaction_cb,
tts);
diff --git a/src/merchant-tools/taler-merchant-benchmark.c b/src/merchant-tools/taler-merchant-benchmark.c
index bf34a7e7..9bd80ff8 100644
--- a/src/merchant-tools/taler-merchant-benchmark.c
+++ b/src/merchant-tools/taler-merchant-benchmark.c
@@ -95,7 +95,12 @@ char *root_help_str = \
/**
* Alternative non default instance.
*/
-static char *alt_instance;
+static char *alt_instance_id;
+
+/**
+ * Base URL of the alternative non default instance.
+ */
+static char *alt_instance_url;
/**
* How many unaggregated payments we want to generate.
@@ -349,8 +354,7 @@ run (void *cls,
("create-proposal-1",
merchant_url,
MHD_HTTP_OK,
- order_worth_5,
- NULL),
+ order_worth_5),
TALER_TESTING_cmd_pay
("deposit-simple",
@@ -375,8 +379,7 @@ run (void *cls,
("create-proposal-2",
merchant_url,
MHD_HTTP_OK,
- order_worth_5_track,
- NULL),
+ order_worth_5_track),
TALER_TESTING_cmd_pay
("deposit-simple-2",
@@ -432,10 +435,9 @@ run (void *cls,
TALER_TESTING_cmd_proposal
("create-unaggregated-proposal",
- merchant_url,
+ alt_instance_url,
MHD_HTTP_OK,
- order_worth_5_unaggregated,
- alt_instance),
+ order_worth_5_unaggregated),
TALER_TESTING_cmd_pay
("deposit-unaggregated",
@@ -476,8 +478,7 @@ run (void *cls,
("create-twocoins-proposal",
merchant_url,
MHD_HTTP_OK,
- order_worth_10_2coins,
- NULL),
+ order_worth_10_2coins),
TALER_TESTING_cmd_pay
("deposit-twocoins",
@@ -629,7 +630,7 @@ main (int argc,
" never author now-deadlined transactions,"
" as they would get those far future ones"
" aggregated too.",
- &alt_instance),
+ &alt_instance_id),
GNUNET_GETOPT_option_string
('b',
@@ -755,7 +756,7 @@ main (int argc,
return 1;
}
- if ((GNUNET_YES == corner) && (NULL == alt_instance))
+ if ((GNUNET_YES == corner) && (NULL == alt_instance_id))
{
fprintf (stderr, "option '-i' is mandatory"
" with sub-command 'corner'!\n");
@@ -777,6 +778,14 @@ main (int argc,
return MISSING_MERCHANT_URL;
}
+ if (NULL != alt_instance_id)
+ {
+ GNUNET_assert (0 < GNUNET_asprintf (&alt_instance_url,
+ "%s/instances/%s/",
+ merchant_url,
+ &alt_instance_id));
+ }
+
if (NULL == (merchantd = TALER_TESTING_run_merchant
(cfg_filename, merchant_url)))
{