diff --git a/src/include/taler_auditor_service.h b/src/include/taler_auditor_service.h index 5ee41c3b1..2c6685c1c 100644 --- a/src/include/taler_auditor_service.h +++ b/src/include/taler_auditor_service.h @@ -277,7 +277,8 @@ typedef void * finished processing the /version reply). If either check fails, we do * NOT initiate the transaction with the auditor and instead return NULL. * - * @param auditor the auditor handle; the auditor must be ready to operate + * @param ctx the context for CURL requests + * @param url HTTP base URL for the auditor * @param h_wire hash of merchant wire details * @param h_policy hash over the policy, if any * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the auditor) @@ -301,7 +302,8 @@ typedef void */ struct TALER_AUDITOR_DepositConfirmationHandle * TALER_AUDITOR_deposit_confirmation ( - struct TALER_AUDITOR_Handle *auditor, + struct GNUNET_CURL_Context *ctx, + const char *url, const struct TALER_MerchantWireHashP *h_wire, const struct TALER_ExtensionPolicyHashP *h_policy, const struct TALER_PrivateContractHashP *h_contract_terms, diff --git a/src/lib/auditor_api_deposit_confirmation.c b/src/lib/auditor_api_deposit_confirmation.c index 93cdaed93..21479c106 100644 --- a/src/lib/auditor_api_deposit_confirmation.c +++ b/src/lib/auditor_api_deposit_confirmation.c @@ -38,11 +38,6 @@ struct TALER_AUDITOR_DepositConfirmationHandle { - /** - * The connection to auditor this request handle will use - */ - struct TALER_AUDITOR_Handle *auditor; - /** * The url for this request. */ @@ -237,7 +232,8 @@ verify_signatures (const struct TALER_MerchantWireHashP *h_wire, struct TALER_AUDITOR_DepositConfirmationHandle * TALER_AUDITOR_deposit_confirmation ( - struct TALER_AUDITOR_Handle *auditor, + struct GNUNET_CURL_Context *ctx, + const char *url, const struct TALER_MerchantWireHashP *h_wire, const struct TALER_ExtensionPolicyHashP *h_policy, const struct TALER_PrivateContractHashP *h_contract_terms, @@ -258,12 +254,9 @@ TALER_AUDITOR_deposit_confirmation ( void *cb_cls) { struct TALER_AUDITOR_DepositConfirmationHandle *dh; - struct GNUNET_CURL_Context *ctx; json_t *deposit_confirmation_obj; CURL *eh; - GNUNET_assert (GNUNET_YES == - TALER_AUDITOR_handle_is_ready_ (auditor)); if (GNUNET_OK != verify_signatures (h_wire, h_policy, @@ -322,18 +315,17 @@ TALER_AUDITOR_deposit_confirmation ( GNUNET_JSON_pack_data_auto ("exchange_pub", exchange_pub)); dh = GNUNET_new (struct TALER_AUDITOR_DepositConfirmationHandle); - dh->auditor = auditor; dh->cb = cb; dh->cb_cls = cb_cls; - dh->url = TALER_AUDITOR_path_to_url_ (auditor, - "/deposit-confirmation"); + dh->url = TALER_url_join (url, + "deposit-confirmation", + NULL); if (NULL == dh->url) { GNUNET_free (dh); return NULL; } eh = TALER_AUDITOR_curl_easy_get_ (dh->url); - if ( (NULL == eh) || (CURLE_OK != curl_easy_setopt (eh, @@ -356,7 +348,6 @@ TALER_AUDITOR_deposit_confirmation ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for deposit-confirmation: `%s'\n", dh->url); - ctx = TALER_AUDITOR_handle_to_context_ (auditor); dh->job = GNUNET_CURL_job_add2 (ctx, eh, dh->ctx.headers, diff --git a/src/lib/exchange_api_batch_deposit.c b/src/lib/exchange_api_batch_deposit.c index 544407a38..bb17737fa 100644 --- a/src/lib/exchange_api_batch_deposit.c +++ b/src/lib/exchange_api_batch_deposit.c @@ -55,6 +55,11 @@ struct TALER_EXCHANGE_BatchDepositHandle */ struct TALER_EXCHANGE_Handle *exchange; + /** + * Context for our curl request(s). + */ + struct GNUNET_CURL_Context *ctx; + /** * The url for this request. */ @@ -64,7 +69,7 @@ struct TALER_EXCHANGE_BatchDepositHandle * Context for #TEH_curl_easy_post(). Keeps the data that must * persist for Curl to make the upload. */ - struct TALER_CURL_PostContext ctx; + struct TALER_CURL_PostContext post_ctx; /** * Handle for the request. @@ -136,13 +141,13 @@ struct TALER_EXCHANGE_BatchDepositHandle * launch a deposit confirmation interaction. * * @param cls closure - * @param ah handle to the auditor + * @param auditor_url base URL of the auditor * @param auditor_pub public key of the auditor * @return NULL if no deposit confirmation interaction was launched */ static struct TEAH_AuditorInteractionEntry * auditor_cb (void *cls, - struct TALER_AUDITOR_Handle *ah, + const char *auditor_url, const struct TALER_AuditorPublicKeyP *auditor_pub) { struct TALER_EXCHANGE_BatchDepositHandle *dh = cls; @@ -183,7 +188,8 @@ auditor_cb (void *cls, &dki->fees.deposit)); aie = GNUNET_new (struct TEAH_AuditorInteractionEntry); aie->dch = TALER_AUDITOR_deposit_confirmation ( - ah, + dh->ctx, + auditor_url, &dh->h_wire, &dh->h_policy, &dh->dcd.h_contract_terms, @@ -464,7 +470,6 @@ TALER_EXCHANGE_batch_deposit ( { const struct TALER_EXCHANGE_Keys *key_state; struct TALER_EXCHANGE_BatchDepositHandle *dh; - struct GNUNET_CURL_Context *ctx; json_t *deposit_obj; json_t *deposits; CURL *eh; @@ -600,7 +605,7 @@ TALER_EXCHANGE_batch_deposit ( eh = TALER_EXCHANGE_curl_easy_get_ (dh->url); if ( (NULL == eh) || (GNUNET_OK != - TALER_curl_easy_post (&dh->ctx, + TALER_curl_easy_post (&dh->post_ctx, eh, deposit_obj)) ) { @@ -618,10 +623,10 @@ TALER_EXCHANGE_batch_deposit ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for deposit: `%s'\n", dh->url); - ctx = TEAH_handle_to_context (exchange); - dh->job = GNUNET_CURL_job_add2 (ctx, + dh->ctx = TEAH_handle_to_context (exchange); + dh->job = GNUNET_CURL_job_add2 (dh->ctx, eh, - dh->ctx.headers, + dh->post_ctx.headers, &handle_deposit_finished, dh); return dh; @@ -648,7 +653,7 @@ TALER_EXCHANGE_batch_deposit_cancel ( GNUNET_free (deposit->url); GNUNET_free (deposit->cdds); GNUNET_free (deposit->exchange_sigs); - TALER_curl_easy_post_finished (&deposit->ctx); + TALER_curl_easy_post_finished (&deposit->post_ctx); GNUNET_free (deposit); } diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c index 5a0073f3f..6f8d348f4 100644 --- a/src/lib/exchange_api_deposit.c +++ b/src/lib/exchange_api_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2021 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -55,6 +55,11 @@ struct TALER_EXCHANGE_DepositHandle */ struct TALER_EXCHANGE_Handle *exchange; + /** + * Our CURL context. + */ + struct GNUNET_CURL_Context *ctx; + /** * The url for this request. */ @@ -64,7 +69,7 @@ struct TALER_EXCHANGE_DepositHandle * Context for #TEH_curl_easy_post(). Keeps the data that must * persist for Curl to make the upload. */ - struct TALER_CURL_PostContext ctx; + struct TALER_CURL_PostContext post_ctx; /** * Handle for the request. @@ -131,13 +136,13 @@ struct TALER_EXCHANGE_DepositHandle * launch a deposit confirmation interaction. * * @param cls closure - * @param ah handle to the auditor + * @param auditor_url base URL of the auditor * @param auditor_pub public key of the auditor * @return NULL if no deposit confirmation interaction was launched */ static struct TEAH_AuditorInteractionEntry * auditor_cb (void *cls, - struct TALER_AUDITOR_Handle *ah, + const char *auditor_url, const struct TALER_AuditorPublicKeyP *auditor_pub) { struct TALER_EXCHANGE_DepositHandle *dh = cls; @@ -175,7 +180,8 @@ auditor_cb (void *cls, &dki->fees.deposit)); aie = GNUNET_new (struct TEAH_AuditorInteractionEntry); aie->dch = TALER_AUDITOR_deposit_confirmation ( - ah, + dh->ctx, + auditor_url, &dh->h_wire, &dh->h_policy, &dh->dcd.h_contract_terms, @@ -389,7 +395,6 @@ TALER_EXCHANGE_deposit ( { const struct TALER_EXCHANGE_Keys *key_state; struct TALER_EXCHANGE_DepositHandle *dh; - struct GNUNET_CURL_Context *ctx; json_t *deposit_obj; CURL *eh; const struct TALER_EXCHANGE_DenomPublicKey *dki; @@ -506,7 +511,7 @@ TALER_EXCHANGE_deposit ( eh = TALER_EXCHANGE_curl_easy_get_ (dh->url); if ( (NULL == eh) || (GNUNET_OK != - TALER_curl_easy_post (&dh->ctx, + TALER_curl_easy_post (&dh->post_ctx, eh, deposit_obj)) ) { @@ -523,10 +528,10 @@ TALER_EXCHANGE_deposit ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for deposit: `%s'\n", dh->url); - ctx = TEAH_handle_to_context (exchange); - dh->job = GNUNET_CURL_job_add2 (ctx, + dh->ctx = TEAH_handle_to_context (exchange); + dh->job = GNUNET_CURL_job_add2 (dh->ctx, eh, - dh->ctx.headers, + dh->post_ctx.headers, &handle_deposit_finished, dh); return dh; @@ -549,7 +554,7 @@ TALER_EXCHANGE_deposit_cancel (struct TALER_EXCHANGE_DepositHandle *deposit) deposit->job = NULL; } GNUNET_free (deposit->url); - TALER_curl_easy_post_finished (&deposit->ctx); + TALER_curl_easy_post_finished (&deposit->post_ctx); GNUNET_free (deposit); } diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index 7b815f28b..0d9bf0416 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -211,7 +211,7 @@ TEAH_get_auditors_for_dc (struct TALER_EXCHANGE_Handle *h, if (! ale->is_up) continue; aie = ac (ac_cls, - ale->ah, + ale->auditor_url, &ale->auditor_pub); if (NULL != aie) { diff --git a/src/lib/exchange_api_handle.h b/src/lib/exchange_api_handle.h index 47be99d4e..8e3b10654 100644 --- a/src/lib/exchange_api_handle.h +++ b/src/lib/exchange_api_handle.h @@ -178,13 +178,13 @@ struct TALER_EXCHANGE_Handle * launch a deposit confirmation interaction. * * @param cls closure - * @param ah handle to the auditor + * @param auditor_url base URL of the auditor * @param auditor_pub public key of the auditor * @return NULL if no deposit confirmation interaction was launched */ typedef struct TEAH_AuditorInteractionEntry * (*TEAH_AuditorCallback)(void *cls, - struct TALER_AUDITOR_Handle *ah, + const char *auditor_url, const struct TALER_AuditorPublicKeyP *auditor_pub); diff --git a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c index c2a4bcc24..5c7b76a31 100644 --- a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c +++ b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c @@ -210,7 +210,7 @@ deposit_confirmation_run (void *cls, const struct TALER_CoinSpendPrivateKeyP *coin_priv; const struct TALER_EXCHANGE_Keys *keys; const struct TALER_EXCHANGE_SigningPublicKey *spk; - struct TALER_AUDITOR_Handle *auditor; + const char *auditor_url; struct TALER_EXCHANGE_Handle *exchange = TALER_TESTING_get_exchange (is); @@ -231,9 +231,14 @@ deposit_confirmation_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_auditor (auditor_cmd, - &auditor)); + if (GNUNET_OK != + TALER_TESTING_get_trait_auditor_url (auditor_cmd, + &auditor_url)) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } } deposit_cmd = TALER_TESTING_interpreter_lookup_command (is, @@ -319,25 +324,27 @@ deposit_confirmation_run (void *cls, if (GNUNET_TIME_absolute_is_zero (refund_deadline.abs_time)) refund_deadline = timestamp; } - dcs->dc = TALER_AUDITOR_deposit_confirmation (auditor, - &h_wire, - &no_h_policy, - &h_contract_terms, - *exchange_timestamp, - *wire_deadline, - refund_deadline, - &amount_without_fee, - &coin_pub, - &merchant_pub, - exchange_pub, - exchange_sig, - &keys->master_pub, - spk->valid_from, - spk->valid_until, - spk->valid_legal, - &spk->master_sig, - &deposit_confirmation_cb, - dcs); + dcs->dc = TALER_AUDITOR_deposit_confirmation ( + TALER_TESTING_interpreter_get_context (is), + auditor_url, + &h_wire, + &no_h_policy, + &h_contract_terms, + *exchange_timestamp, + *wire_deadline, + refund_deadline, + &amount_without_fee, + &coin_pub, + &merchant_pub, + exchange_pub, + exchange_sig, + &keys->master_pub, + spk->valid_from, + spk->valid_until, + spk->valid_legal, + &spk->master_sig, + &deposit_confirmation_cb, + dcs); if (NULL == dcs->dc) {