summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-07-03 17:03:07 +0200
committerChristian Grothoff <christian@grothoff.org>2023-07-03 17:03:07 +0200
commit474ea4a802d7c7f944c9ce93fa4e916b48c1e6c5 (patch)
tree65afe4b7ef3a1ee4016eba1c09af1009f8ebf99f
parent537a490ff91cda40997886dc38c457e3c43900bc (diff)
downloadmerchant-474ea4a802d7c7f944c9ce93fa4e916b48c1e6c5.tar.gz
merchant-474ea4a802d7c7f944c9ce93fa4e916b48c1e6c5.tar.bz2
merchant-474ea4a802d7c7f944c9ce93fa4e916b48c1e6c5.zip
-fix merchant FTBFS
-rw-r--r--src/backend/taler-merchant-httpd_post-tips-ID-pickup.c115
-rw-r--r--src/include/taler_merchant_service.h19
-rw-r--r--src/lib/merchant_api_tip_pickup.c20
-rw-r--r--src/testing/testing_api_cmd_tip_pickup.c2
4 files changed, 50 insertions, 106 deletions
diff --git a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c
index 7cfc4beb..a87ea710 100644
--- a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c
+++ b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c
@@ -73,7 +73,7 @@ struct PlanchetOperation
/**
* Find operation (while active), later NULL.
*/
- struct TMH_EXCHANGES_FindOperation *fo;
+ struct TMH_EXCHANGES_Find2Operation *fo;
/**
* Withdraw handle (NULL while @e fo is active).
@@ -118,6 +118,11 @@ struct PickupContext
struct TMH_HandlerContext *hc;
/**
+ * Base URL of the exchange we withdraw from.
+ */
+ char *exchange_url;
+
+ /**
* Timeout task.
*/
struct GNUNET_SCHEDULER_Task *tt;
@@ -140,7 +145,7 @@ struct PickupContext
/**
* Find operation (while active), later NULL.
*/
- struct TMH_EXCHANGES_FindOperation *fo;
+ struct TMH_EXCHANGES_Find2Operation *fo;
/**
* Which reserve are we draining?
@@ -224,14 +229,14 @@ stop_operations (struct PickupContext *pc)
}
if (NULL != pc->fo)
{
- TMH_EXCHANGES_find_exchange_cancel (pc->fo);
+ TMH_EXCHANGES_keys4exchange_cancel (pc->fo);
pc->fo = NULL;
}
while (NULL != (po = pc->po_head))
{
if (NULL != po->fo)
{
- TMH_EXCHANGES_find_exchange_cancel (po->fo);
+ TMH_EXCHANGES_keys4exchange_cancel (po->fo);
po->fo = NULL;
}
if (NULL != po->w2h)
@@ -279,6 +284,7 @@ pick_context_cleanup (void *cls)
GNUNET_array_grow (pc->planchets,
pc->planchets_length,
0);
+ GNUNET_free (pc->exchange_url);
GNUNET_free (pc);
}
@@ -377,23 +383,18 @@ withdraw_cb (void *cls,
* withdraws the planchet from the exchange.
*
* @param cls closure, with our `struct PlanchetOperation *`
- * @param hr HTTP response details
- * @param eh handle to the exchange context
- * @param ih internal handle to the exchange
+ * @param keys keys for the exchange
*/
static void
do_withdraw (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr,
- struct TALER_EXCHANGE_Handle *eh,
- struct TMH_Exchange *ih)
+ struct TALER_EXCHANGE_Keys *keys)
{
struct PlanchetOperation *po = cls;
struct PickupContext *pc = po->pc;
- (void) ih;
po->fo = NULL;
TMH_db->preflight (TMH_db->cls);
- if (NULL == hr)
+ if (NULL == keys)
{
stop_operations (pc);
GNUNET_CONTAINER_DLL_remove (pc->po_head,
@@ -408,24 +409,9 @@ do_withdraw (void *cls,
TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
return;
}
- if (NULL == eh)
- {
- stop_operations (pc);
- GNUNET_CONTAINER_DLL_remove (pc->po_head,
- pc->po_tail,
- po);
- GNUNET_free (po);
- pc->http_status = MHD_HTTP_BAD_GATEWAY;
- pc->response =
- TALER_MHD_MAKE_JSON_PACK (
- TALER_JSON_pack_ec (
- TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE),
- TMH_pack_exchange_reply (hr));
- MHD_resume_connection (pc->connection);
- TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
- return;
- }
- po->w2h = TALER_EXCHANGE_withdraw2 (eh,
+ po->w2h = TALER_EXCHANGE_withdraw2 (merchant_curl_ctx,
+ pc->exchange_url,
+ keys,
&po->pd,
&pc->reserve_priv,
&withdraw_cb,
@@ -441,13 +427,11 @@ do_withdraw (void *cls,
* completed, the HTTP processing is resumed.
*
* @param[in,out] pc a pending pickup operation that includes @a planchet
- * @param exchange_url identifies an exchange to do the pickup from
* @param planchet details about the coin to pick up
* @param offset offset of @a planchet in the list, needed to process the reply
*/
static void
try_withdraw (struct PickupContext *pc,
- const char *exchange_url,
const struct TALER_PlanchetDetail *planchet,
unsigned int offset)
{
@@ -458,8 +442,7 @@ try_withdraw (struct PickupContext *pc,
po->pc = pc;
po->pd = *planchet;
po->offset = offset;
- po->fo = TMH_EXCHANGES_find_exchange (exchange_url,
- false,
+ po->fo = TMH_EXCHANGES_keys4exchange (pc->exchange_url,
&do_withdraw,
po);
GNUNET_assert (NULL != po->fo);
@@ -500,52 +483,22 @@ do_timeout (void *cls)
* provided by the client.
*
* @param cls closure, with our `struct PickupContext *`
- * @param hr HTTP response details
- * @param eh handle to the exchange context
- * @param ih internal handle to the exchange
+ * @param keys the keys of the exchange
*/
static void
compute_total_requested (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr,
- struct TALER_EXCHANGE_Handle *eh,
- struct TMH_Exchange *ih)
+ struct TALER_EXCHANGE_Keys *keys)
{
struct PickupContext *pc = cls;
- const struct TALER_EXCHANGE_Keys *keys;
- (void) ih;
pc->fo = NULL;
stop_operations (pc); /* stops timeout job */
- if (NULL == hr)
+ if (NULL == keys)
{
pc->http_status = MHD_HTTP_GATEWAY_TIMEOUT;
pc->response = TALER_MHD_MAKE_JSON_PACK (
TALER_JSON_pack_ec (
- TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT));
- MHD_resume_connection (pc->connection);
- TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
- return;
- }
- if (NULL == eh)
- {
- pc->http_status = MHD_HTTP_BAD_GATEWAY;
- pc->response =
- TALER_MHD_MAKE_JSON_PACK (
- TALER_JSON_pack_ec (
- TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE),
- TMH_pack_exchange_reply (hr));
- MHD_resume_connection (pc->connection);
- TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
- return;
- }
- if (NULL == (keys = TALER_EXCHANGE_get_keys (eh)))
- {
- pc->http_status = MHD_HTTP_BAD_GATEWAY;
- pc->response =
- TALER_MHD_MAKE_JSON_PACK (
- TALER_JSON_pack_ec (
- TALER_EC_MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE),
- TMH_pack_exchange_reply (hr));
+ TALER_EC_MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE));
MHD_resume_connection (pc->connection);
TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
return;
@@ -566,8 +519,7 @@ compute_total_requested (void *cls,
pc->response =
TALER_MHD_MAKE_JSON_PACK (
TALER_JSON_pack_ec (
- TALER_EC_MERCHANT_TIP_PICKUP_DENOMINATION_UNKNOWN),
- TMH_pack_exchange_reply (hr));
+ TALER_EC_MERCHANT_TIP_PICKUP_DENOMINATION_UNKNOWN));
MHD_resume_connection (pc->connection);
TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
return;
@@ -644,7 +596,6 @@ TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh,
struct TMH_HandlerContext *hc)
{
struct PickupContext *pc = hc->ctx;
- char *exchange_url;
char *next_url;
struct TALER_Amount total_authorized;
struct TALER_Amount total_picked_up;
@@ -763,7 +714,7 @@ TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh,
&total_authorized,
&total_picked_up,
&expiration,
- &exchange_url,
+ &pc->exchange_url,
&next_url,
&pc->reserve_priv);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
@@ -775,11 +726,9 @@ TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh,
pc->tt = GNUNET_SCHEDULER_add_delayed (EXCHANGE_TIMEOUT,
&do_timeout,
pc);
- pc->fo = TMH_EXCHANGES_find_exchange (exchange_url,
- false,
+ pc->fo = TMH_EXCHANGES_keys4exchange (pc->exchange_url,
&compute_total_requested,
pc);
- GNUNET_free (exchange_url);
return MHD_YES;
}
@@ -813,11 +762,12 @@ RETRY:
memset (sigs,
0,
sizeof (sigs));
+ GNUNET_free (pc->exchange_url);
qs = TMH_db->lookup_pickup (TMH_db->cls,
hc->instance->settings.id,
&pc->tip_id,
&pc->pickup_id,
- &exchange_url,
+ &pc->exchange_url,
&pc->reserve_priv,
pc->planchets_length,
sigs);
@@ -852,11 +802,9 @@ RETRY:
GNUNET_h2s (&pc->pickup_id.hash),
i);
try_withdraw (pc,
- exchange_url,
&pc->planchets[i],
i);
}
- GNUNET_free (exchange_url);
if (rollback)
return MHD_YES;
/* we got _all_ signatures, can continue! */
@@ -910,14 +858,14 @@ RETRY:
NULL);
}
}
-
+ GNUNET_free (pc->exchange_url);
qs = TMH_db->lookup_tip (TMH_db->cls,
hc->instance->settings.id,
&pc->tip_id,
&total_authorized,
&total_picked_up,
&expiration,
- &exchange_url,
+ &pc->exchange_url,
&next_url,
&pc->reserve_priv);
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
@@ -934,7 +882,6 @@ RETRY:
GNUNET_free (next_url);
if (GNUNET_TIME_absolute_is_past (expiration.abs_time))
{
- GNUNET_free (exchange_url);
TMH_db->rollback (TMH_db->cls);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_GONE,
@@ -946,7 +893,6 @@ RETRY:
&total_authorized,
&total_picked_up))
{
- GNUNET_free (exchange_url);
GNUNET_break_op (0);
TMH_db->rollback (TMH_db->cls);
return TALER_MHD_reply_with_error (connection,
@@ -960,7 +906,6 @@ RETRY:
&pc->total_requested))
{
/* total_remaining < pc->total_requested */
- GNUNET_free (exchange_url);
GNUNET_break_op (0);
TMH_db->rollback (TMH_db->cls);
return TALER_MHD_reply_with_error (connection,
@@ -984,7 +929,6 @@ RETRY:
TMH_db->rollback (TMH_db->cls);
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
goto RETRY;
- GNUNET_free (exchange_url);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_STORE_FAILED,
@@ -996,7 +940,6 @@ RETRY:
TMH_db->rollback (TMH_db->cls);
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
goto RETRY;
- GNUNET_free (exchange_url);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_COMMIT_FAILED,
@@ -1012,10 +955,8 @@ RETRY:
for (unsigned int i = 0; i<pc->planchets_length; i++)
{
try_withdraw (pc,
- exchange_url,
&pc->planchets[i],
i);
}
- GNUNET_free (exchange_url);
return MHD_YES;
}
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 3d64833f..874a8a8c 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -4617,7 +4617,7 @@ struct TALER_MERCHANT_PlanchetData
* backend that a customer wants to pick up a tip.
*
* @param ctx execution context
- * @param exchange handle to the exchange we are picking up the tip from
+ * @param exchange_url base URL of the exchange
* @param backend_url base URL of the merchant backend
* @param tip_id unique identifier for the tip
* @param num_planchets number of planchets provided in @a pds
@@ -4627,14 +4627,15 @@ struct TALER_MERCHANT_PlanchetData
* @return handle for this operation, NULL upon errors
*/
struct TALER_MERCHANT_TipPickupHandle *
-TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx,
- struct TALER_EXCHANGE_Handle *exchange,
- const char *backend_url,
- const struct TALER_TipIdentifierP *tip_id,
- unsigned int num_planchets,
- const struct TALER_MERCHANT_PlanchetData planchets[],
- TALER_MERCHANT_TipPickupCallback pickup_cb,
- void *pickup_cb_cls);
+TALER_MERCHANT_tip_pickup (
+ struct GNUNET_CURL_Context *ctx,
+ const char *exchange_url,
+ const char *backend_url,
+ const struct TALER_TipIdentifierP *tip_id,
+ unsigned int num_planchets,
+ const struct TALER_MERCHANT_PlanchetData planchets[],
+ TALER_MERCHANT_TipPickupCallback pickup_cb,
+ void *pickup_cb_cls);
/**
diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c
index cd1f2035..e8cee8ec 100644
--- a/src/lib/merchant_api_tip_pickup.c
+++ b/src/lib/merchant_api_tip_pickup.c
@@ -327,14 +327,15 @@ csr_cb (void *cls,
struct TALER_MERCHANT_TipPickupHandle *
-TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx,
- struct TALER_EXCHANGE_Handle *exchange,
- const char *backend_url,
- const struct TALER_TipIdentifierP *tip_id,
- unsigned int num_planchets,
- const struct TALER_MERCHANT_PlanchetData *pds,
- TALER_MERCHANT_TipPickupCallback pickup_cb,
- void *pickup_cb_cls)
+TALER_MERCHANT_tip_pickup (
+ struct GNUNET_CURL_Context *ctx,
+ const char *exchange_url,
+ const char *backend_url,
+ const struct TALER_TipIdentifierP *tip_id,
+ unsigned int num_planchets,
+ const struct TALER_MERCHANT_PlanchetData *pds,
+ TALER_MERCHANT_TipPickupCallback pickup_cb,
+ void *pickup_cb_cls)
{
struct TALER_MERCHANT_TipPickupHandle *tp;
@@ -376,7 +377,8 @@ TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx,
{
TALER_cs_withdraw_nonce_derive (&pd->ps,
&pd->nonce);
- pd->csr = TALER_EXCHANGE_csr_withdraw (exchange,
+ pd->csr = TALER_EXCHANGE_csr_withdraw (ctx,
+ exchange_url,
&pd->pk,
&pd->nonce,
&csr_cb,
diff --git a/src/testing/testing_api_cmd_tip_pickup.c b/src/testing/testing_api_cmd_tip_pickup.c
index 139510bc..be510d7a 100644
--- a/src/testing/testing_api_cmd_tip_pickup.c
+++ b/src/testing/testing_api_cmd_tip_pickup.c
@@ -285,7 +285,7 @@ tip_pickup_run (void *cls,
TALER_TESTING_FAIL (is);
tps->tpo = TALER_MERCHANT_tip_pickup (
TALER_TESTING_interpreter_get_context (is),
- exchange,
+ TALER_TESTING_get_exchange_url (is),
tps->merchant_url,
tip_id,
num_planchets,