diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-06-25 19:10:26 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-06-25 19:10:26 +0200 |
commit | 421129a32ed88fee49108c76e67c16b60f95116b (patch) | |
tree | 48238febcdf91df64e1fe35ddaa5958c373ce372 /src/lib | |
parent | 75733ee00efc6d5342ed8b4fccd637efaebdce06 (diff) | |
download | exchange-421129a32ed88fee49108c76e67c16b60f95116b.tar.xz |
next round of exchange API atomization
Diffstat (limited to 'src/lib')
21 files changed, 297 insertions, 348 deletions
diff --git a/src/lib/exchange_api_batch_withdraw2.c b/src/lib/exchange_api_batch_withdraw2.c index 04c2c0100..6dd421cea 100644 --- a/src/lib/exchange_api_batch_withdraw2.c +++ b/src/lib/exchange_api_batch_withdraw2.c @@ -218,14 +218,15 @@ reserve_batch_withdraw_payment_required ( } if (GNUNET_OK != - TALER_EXCHANGE_parse_reserve_history (wh->exchange, - history, - &wh->reserve_pub, - balance.currency, - &total_in_from_history, - &total_out_from_history, - len, - rhistory)) + TALER_EXCHANGE_parse_reserve_history ( + TALER_EXCHANGE_get_keys (wh->exchange), + history, + &wh->reserve_pub, + balance.currency, + &total_in_from_history, + &total_out_from_history, + len, + rhistory)) { GNUNET_break_op (0); TALER_EXCHANGE_free_reserve_history (rhistory, diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 8bbc6c472..f43673d76 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -34,9 +34,9 @@ struct HistoryParseContext { /** - * Exchange we use. + * Keys of the exchange we use. */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * Our reserve public key. @@ -187,7 +187,7 @@ parse_withdraw (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, const struct TALER_EXCHANGE_Keys *key_state; const struct TALER_EXCHANGE_DenomPublicKey *dki; - key_state = TALER_EXCHANGE_get_keys (uc->exchange); + key_state = uc->keys; dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state, &h_denom_pub); if ( (GNUNET_YES != @@ -275,7 +275,7 @@ parse_recoup (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, GNUNET_break_op (0); return GNUNET_SYSERR; } - key_state = TALER_EXCHANGE_get_keys (uc->exchange); + key_state = uc->keys; if (GNUNET_OK != TALER_EXCHANGE_test_signing_key (key_state, &rh->details. @@ -349,7 +349,7 @@ parse_closing (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, GNUNET_break_op (0); return GNUNET_SYSERR; } - key_state = TALER_EXCHANGE_get_keys (uc->exchange); + key_state = uc->keys; if (GNUNET_OK != TALER_EXCHANGE_test_signing_key ( key_state, @@ -647,7 +647,7 @@ parse_close (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, enum GNUNET_GenericReturnValue TALER_EXCHANGE_parse_reserve_history ( - struct TALER_EXCHANGE_Handle *exchange, + struct TALER_EXCHANGE_Keys *keys, const json_t *history, const struct TALER_ReservePublicKeyP *reserve_pub, const char *currency, @@ -673,7 +673,7 @@ TALER_EXCHANGE_parse_reserve_history ( }; struct GNUNET_HashCode uuid[history_length]; struct HistoryParseContext uc = { - .exchange = exchange, + .keys = keys, .reserve_pub = reserve_pub, .uuids = uuid, .total_in = total_in, diff --git a/src/lib/exchange_api_csr_melt.c b/src/lib/exchange_api_csr_melt.c index 67b1a9b7e..da6c392aa 100644 --- a/src/lib/exchange_api_csr_melt.c +++ b/src/lib/exchange_api_csr_melt.c @@ -38,10 +38,6 @@ */ struct TALER_EXCHANGE_CsRMeltHandle { - /** - * The connection to exchange this request handle will use - */ - struct TALER_EXCHANGE_Handle *exchange; /** * Function to call with the result. @@ -220,12 +216,14 @@ handle_csr_finished (void *cls, struct TALER_EXCHANGE_CsRMeltHandle * -TALER_EXCHANGE_csr_melt (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_RefreshMasterSecretP *rms, - unsigned int nks_len, - struct TALER_EXCHANGE_NonceKey *nks, - TALER_EXCHANGE_CsRMeltCallback res_cb, - void *res_cb_cls) +TALER_EXCHANGE_csr_melt ( + struct GNUNET_CURL_Context *ctx, + const char *url, + const struct TALER_RefreshMasterSecretP *rms, + unsigned int nks_len, + struct TALER_EXCHANGE_NonceKey *nks, + TALER_EXCHANGE_CsRMeltCallback res_cb, + void *res_cb_cls) { struct TALER_EXCHANGE_CsRMeltHandle *csrh; json_t *csr_arr; @@ -242,7 +240,6 @@ TALER_EXCHANGE_csr_melt (struct TALER_EXCHANGE_Handle *exchange, return NULL; } csrh = GNUNET_new (struct TALER_EXCHANGE_CsRMeltHandle); - csrh->exchange = exchange; csrh->cb = res_cb; csrh->cb_cls = res_cb_cls; csr_arr = json_array (); @@ -262,8 +259,9 @@ TALER_EXCHANGE_csr_melt (struct TALER_EXCHANGE_Handle *exchange, json_array_append_new (csr_arr, csr_obj)); } - csrh->url = TEAH_path_to_url (exchange, - "/csr-melt"); + csrh->url = TALER_url_join (url, + "csr-melt", + NULL); if (NULL == csrh->url) { json_decref (csr_arr); @@ -272,7 +270,6 @@ TALER_EXCHANGE_csr_melt (struct TALER_EXCHANGE_Handle *exchange, } { CURL *eh; - struct GNUNET_CURL_Context *ctx; json_t *req; req = GNUNET_JSON_PACK ( @@ -280,7 +277,6 @@ TALER_EXCHANGE_csr_melt (struct TALER_EXCHANGE_Handle *exchange, rms), GNUNET_JSON_pack_array_steal ("nks", csr_arr)); - ctx = TEAH_handle_to_context (exchange); eh = TALER_EXCHANGE_curl_easy_get_ (csrh->url); if ( (NULL == eh) || (GNUNET_OK != diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c index 9ec25e45a..8b145dabd 100644 --- a/src/lib/exchange_api_deposits_get.c +++ b/src/lib/exchange_api_deposits_get.c @@ -39,9 +39,9 @@ struct TALER_EXCHANGE_DepositGetHandle { /** - * The connection to exchange this request handle will use + * The keys of the this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -131,7 +131,7 @@ handle_deposit_wtid_finished (void *cls, }; const struct TALER_EXCHANGE_Keys *key_state; - key_state = TALER_EXCHANGE_get_keys (dwh->exchange); + key_state = dwh->keys; GNUNET_assert (NULL != key_state); if (GNUNET_OK != GNUNET_JSON_parse (j, @@ -255,7 +255,9 @@ handle_deposit_wtid_finished (void *cls, struct TALER_EXCHANGE_DepositGetHandle * TALER_EXCHANGE_deposits_get ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_MerchantPrivateKeyP *merchant_priv, const struct TALER_MerchantWireHashP *h_wire, const struct TALER_PrivateContractHashP *h_contract_terms, @@ -267,7 +269,6 @@ TALER_EXCHANGE_deposits_get ( struct TALER_MerchantPublicKeyP merchant; struct TALER_MerchantSignatureP merchant_sig; struct TALER_EXCHANGE_DepositGetHandle *dwh; - struct GNUNET_CURL_Context *ctx; CURL *eh; char arg_str[(sizeof (struct TALER_CoinSpendPublicKeyP) + sizeof (struct TALER_MerchantWireHashP) @@ -275,12 +276,6 @@ TALER_EXCHANGE_deposits_get ( + sizeof (struct TALER_PrivateContractHashP) + sizeof (struct TALER_MerchantSignatureP)) * 2 + 48]; - if (GNUNET_YES != - TEAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } GNUNET_CRYPTO_eddsa_key_get_public (&merchant_priv->eddsa_priv, &merchant.eddsa_pub); TALER_merchant_deposit_sign (h_contract_terms, @@ -339,7 +334,7 @@ TALER_EXCHANGE_deposits_get ( GNUNET_snprintf (arg_str, sizeof (arg_str), - "/deposits/%s/%s/%s/%s?merchant_sig=%s%s%s", + "deposits/%s/%s/%s/%s?merchant_sig=%s%s%s", whash_str, mpub_str, chash_str, @@ -352,11 +347,11 @@ TALER_EXCHANGE_deposits_get ( } dwh = GNUNET_new (struct TALER_EXCHANGE_DepositGetHandle); - dwh->exchange = exchange; dwh->cb = cb; dwh->cb_cls = cb_cls; - dwh->url = TEAH_path_to_url (exchange, - arg_str); + dwh->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == dwh->url) { GNUNET_free (dwh); @@ -365,7 +360,6 @@ TALER_EXCHANGE_deposits_get ( dwh->h_wire = *h_wire; dwh->h_contract_terms = *h_contract_terms; dwh->coin_pub = *coin_pub; - eh = TALER_EXCHANGE_curl_easy_get_ (dwh->url); if (NULL == eh) { @@ -374,11 +368,11 @@ TALER_EXCHANGE_deposits_get ( GNUNET_free (dwh); return NULL; } - ctx = TEAH_handle_to_context (exchange); dwh->job = GNUNET_CURL_job_add (ctx, eh, &handle_deposit_wtid_finished, dwh); + dwh->keys = TALER_EXCHANGE_keys_incref (keys); return dwh; } @@ -393,6 +387,7 @@ TALER_EXCHANGE_deposits_get_cancel (struct TALER_EXCHANGE_DepositGetHandle *dwh) } GNUNET_free (dwh->url); TALER_curl_easy_post_finished (&dwh->ctx); + TALER_EXCHANGE_keys_decref (dwh->keys); GNUNET_free (dwh); } diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index 7e3021129..fe73f0504 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -2239,6 +2239,20 @@ TALER_EXCHANGE_get_keys_raw (struct TALER_EXCHANGE_Handle *exchange) } +/** + * Obtain the keys from the exchange in the raw JSON format. + * + * @param keys the keys structure + * @return the keys in raw JSON + */ +json_t * +TALER_EXCHANGE_keys_to_json (struct TALER_EXCHANGE_Keys *keys) +{ + // FIXME! + return NULL; +} + + struct TALER_EXCHANGE_Keys * TALER_EXCHANGE_keys_incref (struct TALER_EXCHANGE_Keys *keys) { diff --git a/src/lib/exchange_api_melt.c b/src/lib/exchange_api_melt.c index 3a8144a3c..1da4184d2 100644 --- a/src/lib/exchange_api_melt.c +++ b/src/lib/exchange_api_melt.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2022 Taler Systems SA + Copyright (C) 2015-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 @@ -41,9 +41,9 @@ struct TALER_EXCHANGE_MeltHandle { /** - * The connection to exchange this request handle will use + * The keys of the this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -51,6 +51,16 @@ struct TALER_EXCHANGE_MeltHandle char *url; /** + * The exchange base url. + */ + char *exchange_url; + + /** + * Curl context. + */ + struct GNUNET_CURL_Context *cctx; + + /** * Context for #TEH_curl_easy_post(). Keeps the data that must * persist for Curl to make the upload. */ @@ -159,7 +169,7 @@ verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh, return GNUNET_SYSERR; } /* check that exchange signing key is permitted */ - key_state = TALER_EXCHANGE_get_keys (mh->exchange); + key_state = mh->keys; if (GNUNET_OK != TALER_EXCHANGE_test_signing_key (key_state, exchange_pub)) @@ -211,7 +221,7 @@ handle_melt_finished (void *cls, const struct TALER_EXCHANGE_Keys *keys; mh->job = NULL; - keys = TALER_EXCHANGE_get_keys (mh->exchange); + keys = mh->keys; switch (response_code) { case 0: @@ -309,7 +319,6 @@ start_melt (struct TALER_EXCHANGE_MeltHandle *mh) const struct TALER_EXCHANGE_Keys *key_state; json_t *melt_obj; CURL *eh; - struct GNUNET_CURL_Context *ctx; char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32]; struct TALER_DenominationHashP h_denom_pub; struct TALER_ExchangeWithdrawValues alg_values[mh->rd->fresh_pks_len]; @@ -371,19 +380,19 @@ start_melt (struct TALER_EXCHANGE_MeltHandle *mh) *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/coins/%s/melt", + "coins/%s/melt", pub_str); } - ctx = TEAH_handle_to_context (mh->exchange); - key_state = TALER_EXCHANGE_get_keys (mh->exchange); + key_state = mh->keys; mh->dki = TALER_EXCHANGE_get_denomination_key (key_state, &mh->md.melted_coin.pub_key); /* and now we can at last begin the actual request handling */ - mh->url = TEAH_path_to_url (mh->exchange, - arg_str); + mh->url = TALER_url_join (mh->exchange_url, + arg_str, + NULL); if (NULL == mh->url) { json_decref (melt_obj); @@ -403,7 +412,7 @@ start_melt (struct TALER_EXCHANGE_MeltHandle *mh) return GNUNET_SYSERR; } json_decref (melt_obj); - mh->job = GNUNET_CURL_job_add2 (ctx, + mh->job = GNUNET_CURL_job_add2 (mh->cctx, eh, mh->ctx.headers, &handle_melt_finished, @@ -496,11 +505,14 @@ csr_cb (void *cls, struct TALER_EXCHANGE_MeltHandle * -TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_RefreshMasterSecretP *rms, - const struct TALER_EXCHANGE_RefreshData *rd, - TALER_EXCHANGE_MeltCallback melt_cb, - void *melt_cb_cls) +TALER_EXCHANGE_melt ( + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, + const struct TALER_RefreshMasterSecretP *rms, + const struct TALER_EXCHANGE_RefreshData *rd, + TALER_EXCHANGE_MeltCallback melt_cb, + void *melt_cb_cls) { struct TALER_EXCHANGE_NonceKey nks[GNUNET_NZL (rd->fresh_pks_len)]; unsigned int nks_off = 0; @@ -511,11 +523,10 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, GNUNET_break (0); return NULL; } - GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); mh = GNUNET_new (struct TALER_EXCHANGE_MeltHandle); mh->noreveal_index = TALER_CNC_KAPPA; /* invalid value */ - mh->exchange = exchange; + mh->cctx = ctx; + mh->exchange_url = GNUNET_strdup (url); mh->rd = rd; mh->rms = *rms; mh->melt_cb = melt_cb; @@ -545,9 +556,11 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, break; } } + mh->keys = TALER_EXCHANGE_keys_incref (keys); if (0 != nks_off) { - mh->csr = TALER_EXCHANGE_csr_melt (exchange, + mh->csr = TALER_EXCHANGE_csr_melt (ctx, + url, rms, nks_off, nks, @@ -588,7 +601,9 @@ TALER_EXCHANGE_melt_cancel (struct TALER_EXCHANGE_MeltHandle *mh) TALER_EXCHANGE_free_melt_data_ (&mh->md); /* does not free 'md' itself */ GNUNET_free (mh->mbds); GNUNET_free (mh->url); + GNUNET_free (mh->exchange_url); TALER_curl_easy_post_finished (&mh->ctx); + TALER_EXCHANGE_keys_decref (mh->keys); GNUNET_free (mh); } diff --git a/src/lib/exchange_api_purse_create_with_deposit.c b/src/lib/exchange_api_purse_create_with_deposit.c index a2618d639..af05bf923 100644 --- a/src/lib/exchange_api_purse_create_with_deposit.c +++ b/src/lib/exchange_api_purse_create_with_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-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 @@ -73,9 +73,9 @@ struct TALER_EXCHANGE_PurseCreateDepositHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -83,6 +83,11 @@ struct TALER_EXCHANGE_PurseCreateDepositHandle char *url; /** + * The base URL of the exchange. + */ + char *exchange_url; + + /** * Context for #TEH_curl_easy_post(). Keeps the data that must * persist for Curl to make the upload. */ @@ -170,10 +175,9 @@ handle_purse_create_deposit_finished (void *cls, .hr.reply = j, .hr.http_status = (unsigned int) response_code }; - const struct TALER_EXCHANGE_Keys *keys; + const struct TALER_EXCHANGE_Keys *keys = pch->keys; pch->job = NULL; - keys = TALER_EXCHANGE_get_keys (pch->exchange); switch (response_code) { case 0: @@ -181,7 +185,6 @@ handle_purse_create_deposit_finished (void *cls, break; case MHD_HTTP_OK: { - const struct TALER_EXCHANGE_Keys *key_state; struct GNUNET_TIME_Timestamp etime; struct TALER_Amount total_deposited; struct TALER_ExchangeSignatureP exchange_sig; @@ -209,9 +212,8 @@ handle_purse_create_deposit_finished (void *cls, dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; break; } - key_state = TALER_EXCHANGE_get_keys (pch->exchange); if (GNUNET_OK != - TALER_EXCHANGE_test_signing_key (key_state, + TALER_EXCHANGE_test_signing_key (keys, &exchange_pub)) { GNUNET_break_op (0); @@ -387,7 +389,7 @@ handle_purse_create_deposit_finished (void *cls, if (GNUNET_OK != TALER_EXCHANGE_check_purse_coin_conflict_ ( &pch->purse_pub, - pch->exchange->url, + pch->exchange_url, j, &h_denom_pub, &phac, @@ -496,7 +498,9 @@ handle_purse_create_deposit_finished (void *cls, struct TALER_EXCHANGE_PurseCreateDepositHandle * TALER_EXCHANGE_purse_create_with_deposit ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_PurseContractPrivateKeyP *purse_priv, const struct TALER_PurseMergePrivateKeyP *merge_priv, const struct TALER_ContractDiffiePrivateP *contract_priv, @@ -508,16 +512,13 @@ TALER_EXCHANGE_purse_create_with_deposit ( void *cb_cls) { struct TALER_EXCHANGE_PurseCreateDepositHandle *pch; - struct GNUNET_CURL_Context *ctx; json_t *create_obj; json_t *deposit_arr; CURL *eh; char arg_str[sizeof (pch->purse_pub) * 2 + 32]; - char *url; uint32_t min_age = 0; pch = GNUNET_new (struct TALER_EXCHANGE_PurseCreateDepositHandle); - pch->exchange = exchange; pch->cb = cb; pch->cb_cls = cb_cls; { @@ -542,8 +543,6 @@ TALER_EXCHANGE_purse_create_with_deposit ( return NULL; } } - GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); if (GNUNET_OK != TALER_JSON_contract_hash (contract_terms, &pch->h_contract_terms)) @@ -565,13 +564,14 @@ TALER_EXCHANGE_purse_create_with_deposit ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/purses/%s/create", + "purses/%s/create", pub_str); } GNUNET_CRYPTO_eddsa_key_get_public (&merge_priv->eddsa_priv, &pch->merge_pub.eddsa_pub); - pch->url = TEAH_path_to_url (exchange, - arg_str); + pch->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == pch->url) { GNUNET_break (0); @@ -583,8 +583,6 @@ TALER_EXCHANGE_purse_create_with_deposit ( struct Deposit); deposit_arr = json_array (); GNUNET_assert (NULL != deposit_arr); - url = TEAH_path_to_url (exchange, - "/"); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Signing with URL `%s'\n", url); @@ -610,7 +608,6 @@ TALER_EXCHANGE_purse_create_with_deposit ( { GNUNET_break (0); json_decref (deposit_arr); - GNUNET_free (url); GNUNET_free (pch); return NULL; } @@ -648,7 +645,6 @@ TALER_EXCHANGE_purse_create_with_deposit ( json_array_append_new (deposit_arr, jdeposit)); } - GNUNET_free (url); TALER_wallet_purse_create_sign (pch->purse_expiration, &pch->h_contract_terms, &pch->merge_pub, @@ -714,7 +710,8 @@ TALER_EXCHANGE_purse_create_with_deposit ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for purse create with deposit: `%s'\n", pch->url); - ctx = TEAH_handle_to_context (exchange); + pch->keys = TALER_EXCHANGE_keys_incref (keys); + pch->exchange_url = GNUNET_strdup (url); pch->job = GNUNET_CURL_job_add2 (ctx, eh, pch->ctx.headers, @@ -734,8 +731,10 @@ TALER_EXCHANGE_purse_create_with_deposit_cancel ( pch->job = NULL; } GNUNET_free (pch->econtract.econtract); + GNUNET_free (pch->exchange_url); GNUNET_free (pch->url); GNUNET_free (pch->deposits); + TALER_EXCHANGE_keys_decref (pch->keys); TALER_curl_easy_post_finished (&pch->ctx); GNUNET_free (pch); } diff --git a/src/lib/exchange_api_purse_create_with_merge.c b/src/lib/exchange_api_purse_create_with_merge.c index 460239fc8..0c8878342 100644 --- a/src/lib/exchange_api_purse_create_with_merge.c +++ b/src/lib/exchange_api_purse_create_with_merge.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-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 @@ -41,9 +41,9 @@ struct TALER_EXCHANGE_PurseCreateMergeHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -51,6 +51,11 @@ struct TALER_EXCHANGE_PurseCreateMergeHandle char *url; /** + * The exchange base URL. + */ + char *exchange_url; + + /** * Context for #TEH_curl_easy_post(). Keeps the data that must * persist for Curl to make the upload. */ @@ -157,7 +162,6 @@ handle_purse_create_with_merge_finished (void *cls, break; case MHD_HTTP_OK: { - const struct TALER_EXCHANGE_Keys *key_state; struct GNUNET_TIME_Timestamp etime; struct TALER_Amount total_deposited; struct TALER_ExchangeSignatureP exchange_sig; @@ -184,9 +188,8 @@ handle_purse_create_with_merge_finished (void *cls, dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; break; } - key_state = TALER_EXCHANGE_get_keys (pcm->exchange); if (GNUNET_OK != - TALER_EXCHANGE_test_signing_key (key_state, + TALER_EXCHANGE_test_signing_key (pcm->keys, &exchange_pub)) { GNUNET_break_op (0); @@ -253,7 +256,7 @@ handle_purse_create_with_merge_finished (void *cls, &pcm->merge_sig, &pcm->merge_pub, &pcm->purse_pub, - pcm->exchange->url, + pcm->exchange_url, j)) { GNUNET_break_op (0); @@ -340,7 +343,9 @@ handle_purse_create_with_merge_finished (void *cls, struct TALER_EXCHANGE_PurseCreateMergeHandle * TALER_EXCHANGE_purse_create_with_merge ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, const struct TALER_PurseContractPrivateKeyP *purse_priv, const struct TALER_PurseMergePrivateKeyP *merge_priv, @@ -353,7 +358,6 @@ TALER_EXCHANGE_purse_create_with_merge ( void *cb_cls) { struct TALER_EXCHANGE_PurseCreateMergeHandle *pcm; - struct GNUNET_CURL_Context *ctx; json_t *create_with_merge_obj; CURL *eh; char arg_str[sizeof (pcm->reserve_pub) * 2 + 32]; @@ -362,7 +366,6 @@ TALER_EXCHANGE_purse_create_with_merge ( enum TALER_WalletAccountMergeFlags flags; pcm = GNUNET_new (struct TALER_EXCHANGE_PurseCreateMergeHandle); - pcm->exchange = exchange; pcm->cb = cb; pcm->cb_cls = cb_cls; if (GNUNET_OK != @@ -409,7 +412,7 @@ TALER_EXCHANGE_purse_create_with_merge ( const struct TALER_EXCHANGE_GlobalFee *gf; gf = TALER_EXCHANGE_get_global_fee ( - TALER_EXCHANGE_get_keys (exchange), + keys, GNUNET_TIME_timestamp_get ()); purse_fee = gf->fees.purse; flags = TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE; @@ -422,8 +425,6 @@ TALER_EXCHANGE_purse_create_with_merge ( flags = TALER_WAMF_MODE_CREATE_FROM_PURSE_QUOTA; } - GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); { char pub_str[sizeof (pcm->reserve_pub) * 2]; char *end; @@ -436,11 +437,12 @@ TALER_EXCHANGE_purse_create_with_merge ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/reserves/%s/purse", + "reserves/%s/purse", pub_str); } - pcm->url = TEAH_path_to_url (exchange, - arg_str); + pcm->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == pcm->url) { GNUNET_break (0); @@ -457,7 +459,7 @@ TALER_EXCHANGE_purse_create_with_merge ( { char *payto_uri; - payto_uri = TALER_reserve_make_payto (exchange->url, + payto_uri = TALER_reserve_make_payto (url, &pcm->reserve_pub); TALER_wallet_purse_merge_sign (payto_uri, merge_timestamp, @@ -546,7 +548,8 @@ TALER_EXCHANGE_purse_create_with_merge ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for purse create_with_merge: `%s'\n", pcm->url); - ctx = TEAH_handle_to_context (exchange); + pcm->keys = TALER_EXCHANGE_keys_incref (keys); + pcm->exchange_url = GNUNET_strdup (url); pcm->job = GNUNET_CURL_job_add2 (ctx, eh, pcm->ctx.headers, @@ -566,7 +569,9 @@ TALER_EXCHANGE_purse_create_with_merge_cancel ( pcm->job = NULL; } GNUNET_free (pcm->url); + GNUNET_free (pcm->exchange_url); TALER_curl_easy_post_finished (&pcm->ctx); + TALER_EXCHANGE_keys_decref (pcm->keys); GNUNET_free (pcm->econtract.econtract); GNUNET_free (pcm); } diff --git a/src/lib/exchange_api_purse_deposit.c b/src/lib/exchange_api_purse_deposit.c index f88d23299..e1d38d16e 100644 --- a/src/lib/exchange_api_purse_deposit.c +++ b/src/lib/exchange_api_purse_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-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 @@ -73,9 +73,9 @@ struct TALER_EXCHANGE_PurseDepositHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -144,10 +144,9 @@ handle_purse_deposit_finished (void *cls, .hr.reply = j, .hr.http_status = (unsigned int) response_code }; - const struct TALER_EXCHANGE_Keys *keys; + const struct TALER_EXCHANGE_Keys *keys = pch->keys; pch->job = NULL; - keys = TALER_EXCHANGE_get_keys (pch->exchange); switch (response_code) { case 0: @@ -447,7 +446,9 @@ handle_purse_deposit_finished (void *cls, struct TALER_EXCHANGE_PurseDepositHandle * TALER_EXCHANGE_purse_deposit ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const char *purse_exchange_url, const struct TALER_PurseContractPublicKeyP *purse_pub, uint8_t min_age, @@ -457,7 +458,6 @@ TALER_EXCHANGE_purse_deposit ( void *cb_cls) { struct TALER_EXCHANGE_PurseDepositHandle *pch; - struct GNUNET_CURL_Context *ctx; json_t *create_obj; json_t *deposit_arr; CURL *eh; @@ -470,11 +470,8 @@ TALER_EXCHANGE_purse_deposit ( GNUNET_break (0); return NULL; } - GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); pch = GNUNET_new (struct TALER_EXCHANGE_PurseDepositHandle); pch->purse_pub = *purse_pub; - pch->exchange = exchange; pch->cb = cb; pch->cb_cls = cb_cls; { @@ -489,11 +486,12 @@ TALER_EXCHANGE_purse_deposit ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/purses/%s/deposit", + "purses/%s/deposit", pub_str); } - pch->url = TEAH_path_to_url (exchange, - arg_str); + pch->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == pch->url) { GNUNET_break (0); @@ -502,8 +500,7 @@ TALER_EXCHANGE_purse_deposit ( } deposit_arr = json_array (); GNUNET_assert (NULL != deposit_arr); - pch->base_url = TEAH_path_to_url (exchange, - "/"); + pch->base_url = GNUNET_strdup (url); pch->num_deposits = num_deposits; pch->coins = GNUNET_new_array (num_deposits, struct Coin); @@ -594,7 +591,7 @@ TALER_EXCHANGE_purse_deposit ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for purse deposit: `%s'\n", pch->url); - ctx = TEAH_handle_to_context (exchange); + pch->keys = TALER_EXCHANGE_keys_incref (keys); pch->job = GNUNET_CURL_job_add2 (ctx, eh, pch->ctx.headers, @@ -616,6 +613,7 @@ TALER_EXCHANGE_purse_deposit_cancel ( GNUNET_free (pch->base_url); GNUNET_free (pch->url); GNUNET_free (pch->coins); + TALER_EXCHANGE_keys_decref (pch->keys); TALER_curl_easy_post_finished (&pch->ctx); GNUNET_free (pch); } diff --git a/src/lib/exchange_api_purse_merge.c b/src/lib/exchange_api_purse_merge.c index 6e1995e0d..8fd952515 100644 --- a/src/lib/exchange_api_purse_merge.c +++ b/src/lib/exchange_api_purse_merge.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-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 @@ -41,9 +41,9 @@ struct TALER_EXCHANGE_AccountMergeHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -148,7 +148,6 @@ handle_purse_merge_finished (void *cls, break; case MHD_HTTP_OK: { - const struct TALER_EXCHANGE_Keys *key_state; struct TALER_Amount total_deposited; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("exchange_sig", @@ -173,9 +172,8 @@ handle_purse_merge_finished (void *cls, dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; break; } - key_state = TALER_EXCHANGE_get_keys (pch->exchange); if (GNUNET_OK != - TALER_EXCHANGE_test_signing_key (key_state, + TALER_EXCHANGE_test_signing_key (pch->keys, &dr.details.ok.exchange_pub)) { GNUNET_break_op (0); @@ -302,7 +300,9 @@ handle_purse_merge_finished (void *cls, struct TALER_EXCHANGE_AccountMergeHandle * TALER_EXCHANGE_account_merge ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const char *reserve_exchange_url, const struct TALER_ReservePrivateKeyP *reserve_priv, const struct TALER_PurseContractPublicKeyP *purse_pub, @@ -316,14 +316,12 @@ TALER_EXCHANGE_account_merge ( void *cb_cls) { struct TALER_EXCHANGE_AccountMergeHandle *pch; - struct GNUNET_CURL_Context *ctx; json_t *merge_obj; CURL *eh; char arg_str[sizeof (pch->purse_pub) * 2 + 32]; char *reserve_url; pch = GNUNET_new (struct TALER_EXCHANGE_AccountMergeHandle); - pch->exchange = exchange; pch->merge_priv = *merge_priv; pch->cb = cb; pch->cb_cls = cb_cls; @@ -332,14 +330,12 @@ TALER_EXCHANGE_account_merge ( pch->purse_expiration = purse_expiration; pch->purse_value_after_fees = *purse_value_after_fees; if (NULL == reserve_exchange_url) - pch->provider_url = GNUNET_strdup (exchange->url); + pch->provider_url = GNUNET_strdup (url); else pch->provider_url = GNUNET_strdup (reserve_exchange_url); GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv, &pch->reserve_pub.eddsa_pub); - GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); { char pub_str[sizeof (*purse_pub) * 2]; char *end; @@ -352,7 +348,7 @@ TALER_EXCHANGE_account_merge ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/purses/%s/merge", + "purses/%s/merge", pub_str); } reserve_url = TALER_reserve_make_payto (pch->provider_url, @@ -364,8 +360,9 @@ TALER_EXCHANGE_account_merge ( GNUNET_free (pch); return NULL; } - pch->url = TEAH_path_to_url (exchange, - arg_str); + pch->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == pch->url) { GNUNET_break (0); @@ -426,7 +423,7 @@ TALER_EXCHANGE_account_merge ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for purse merge: `%s'\n", pch->url); - ctx = TEAH_handle_to_context (exchange); + pch->keys = TALER_EXCHANGE_keys_incref (keys); pch->job = GNUNET_CURL_job_add2 (ctx, eh, pch->ctx.headers, @@ -448,6 +445,7 @@ TALER_EXCHANGE_account_merge_cancel ( GNUNET_free (pch->url); GNUNET_free (pch->provider_url); TALER_curl_easy_post_finished (&pch->ctx); + TALER_EXCHANGE_keys_decref (pch->keys); GNUNET_free (pch); } diff --git a/src/lib/exchange_api_purses_get.c b/src/lib/exchange_api_purses_get.c index 4c2fdd79c..7a6b2707f 100644 --- a/src/lib/exchange_api_purses_get.c +++ b/src/lib/exchange_api_purses_get.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-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 @@ -39,9 +39,9 @@ struct TALER_EXCHANGE_PurseGetHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -117,7 +117,6 @@ handle_purse_get_finished (void *cls, &exchange_sig), GNUNET_JSON_spec_end () }; - const struct TALER_EXCHANGE_Keys *key_state; if (GNUNET_OK != GNUNET_JSON_parse (j, @@ -130,9 +129,8 @@ handle_purse_get_finished (void *cls, break; } - key_state = TALER_EXCHANGE_get_keys (pgh->exchange); if (GNUNET_OK != - TALER_EXCHANGE_test_signing_key (key_state, + TALER_EXCHANGE_test_signing_key (pgh->keys, &exchange_pub)) { GNUNET_break_op (0); @@ -207,7 +205,9 @@ handle_purse_get_finished (void *cls, struct TALER_EXCHANGE_PurseGetHandle * TALER_EXCHANGE_purse_get ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_PurseContractPublicKeyP *purse_pub, struct GNUNET_TIME_Relative timeout, bool wait_for_merge, @@ -218,14 +218,7 @@ TALER_EXCHANGE_purse_get ( CURL *eh; char arg_str[sizeof (*purse_pub) * 2 + 64]; - if (GNUNET_YES != - TEAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } pgh = GNUNET_new (struct TALER_EXCHANGE_PurseGetHandle); - pgh->exchange = exchange; pgh->cb = cb; pgh->cb_cls = cb_cls; { @@ -247,19 +240,20 @@ TALER_EXCHANGE_purse_get ( if (GNUNET_TIME_relative_is_zero (timeout)) GNUNET_snprintf (arg_str, sizeof (arg_str), - "/purses/%s/%s", + "purses/%s/%s", cpub_str, wait_for_merge ? "merge" : "deposit"); else GNUNET_snprintf (arg_str, sizeof (arg_str), - "/purses/%s/%s?timeout_ms=%s", + "purses/%s/%s?timeout_ms=%s", cpub_str, wait_for_merge ? "merge" : "deposit", timeout_str); } - pgh->url = TEAH_path_to_url (exchange, - arg_str); + pgh->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == pgh->url) { GNUNET_free (pgh); @@ -273,10 +267,11 @@ TALER_EXCHANGE_purse_get ( GNUNET_free (pgh); return NULL; } - pgh->job = GNUNET_CURL_job_add (TEAH_handle_to_context (exchange), + pgh->job = GNUNET_CURL_job_add (ctx, eh, &handle_purse_get_finished, pgh); + pgh->keys = TALER_EXCHANGE_keys_incref (keys); return pgh; } @@ -291,6 +286,7 @@ TALER_EXCHANGE_purse_get_cancel ( pgh->job = NULL; } GNUNET_free (pgh->url); + TALER_EXCHANGE_keys_decref (pgh->keys); GNUNET_free (pgh); } diff --git a/src/lib/exchange_api_recoup.c b/src/lib/exchange_api_recoup.c index b89bda8b3..e7daff165 100644 --- a/src/lib/exchange_api_recoup.c +++ b/src/lib/exchange_api_recoup.c @@ -40,9 +40,9 @@ struct TALER_EXCHANGE_RecoupHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -143,10 +143,8 @@ handle_recoup_finished (void *cls, .hr.reply = j, .hr.http_status = (unsigned int) response_code }; - const struct TALER_EXCHANGE_Keys *keys; ph->job = NULL; - keys = TALER_EXCHANGE_get_keys (ph->exchange); switch (response_code) { case 0: @@ -177,7 +175,7 @@ handle_recoup_finished (void *cls, rr.hr.ec = TALER_JSON_get_error_code (j); rr.hr.hint = TALER_JSON_get_error_hint (j); if (GNUNET_OK != - TALER_EXCHANGE_get_min_denomination_ (keys, + TALER_EXCHANGE_get_min_denomination_ (ph->keys, &min_key)) { GNUNET_break (0); @@ -187,7 +185,7 @@ handle_recoup_finished (void *cls, } if (GNUNET_OK != TALER_EXCHANGE_check_coin_conflict_ ( - keys, + ph->keys, j, &ph->pk, &ph->coin_pub, @@ -244,16 +242,18 @@ handle_recoup_finished (void *cls, struct TALER_EXCHANGE_RecoupHandle * -TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_EXCHANGE_DenomPublicKey *pk, - const struct TALER_DenominationSignature *denom_sig, - const struct TALER_ExchangeWithdrawValues *exchange_vals, - const struct TALER_PlanchetMasterSecretP *ps, - TALER_EXCHANGE_RecoupResultCallback recoup_cb, - void *recoup_cb_cls) +TALER_EXCHANGE_recoup ( + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, + const struct TALER_EXCHANGE_DenomPublicKey *pk, + const struct TALER_DenominationSignature *denom_sig, + const struct TALER_ExchangeWithdrawValues *exchange_vals, + const struct TALER_PlanchetMasterSecretP *ps, + TALER_EXCHANGE_RecoupResultCallback recoup_cb, + void *recoup_cb_cls) { struct TALER_EXCHANGE_RecoupHandle *ph; - struct GNUNET_CURL_Context *ctx; struct TALER_DenominationHashP h_denom_pub; json_t *recoup_obj; CURL *eh; @@ -261,8 +261,6 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, struct TALER_CoinSpendPrivateKeyP coin_priv; union TALER_DenominationBlindingKeyP bks; - GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); ph = GNUNET_new (struct TALER_EXCHANGE_RecoupHandle); TALER_planchet_setup_coin_priv (ps, exchange_vals, @@ -319,19 +317,19 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/coins/%s/recoup", + "coins/%s/recoup", pub_str); } - ph->exchange = exchange; ph->pk = *pk; memset (&ph->pk.key, 0, sizeof (ph->pk.key)); /* zero out, as lifetime cannot be warranted */ ph->cb = recoup_cb; ph->cb_cls = recoup_cb_cls; - ph->url = TEAH_path_to_url (exchange, - arg_str); + ph->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == ph->url) { json_decref (recoup_obj); @@ -357,7 +355,7 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for recoup: `%s'\n", ph->url); - ctx = TEAH_handle_to_context (exchange); + ph->keys = TALER_EXCHANGE_keys_incref (keys); ph->job = GNUNET_CURL_job_add2 (ctx, eh, ph->ctx.headers, @@ -377,6 +375,7 @@ TALER_EXCHANGE_recoup_cancel (struct TALER_EXCHANGE_RecoupHandle *ph) } GNUNET_free (ph->url); TALER_curl_easy_post_finished (&ph->ctx); + TALER_EXCHANGE_keys_decref (ph->keys); GNUNET_free (ph); } diff --git a/src/lib/exchange_api_recoup_refresh.c b/src/lib/exchange_api_recoup_refresh.c index 7b42aa7eb..f5745deb0 100644 --- a/src/lib/exchange_api_recoup_refresh.c +++ b/src/lib/exchange_api_recoup_refresh.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2017-2022 Taler Systems SA + Copyright (C) 2017-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 @@ -40,9 +40,9 @@ struct TALER_EXCHANGE_RecoupRefreshHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -144,10 +144,8 @@ handle_recoup_refresh_finished (void *cls, .hr.reply = j, .hr.http_status = (unsigned int) response_code }; - const struct TALER_EXCHANGE_Keys *keys; ph->job = NULL; - keys = TALER_EXCHANGE_get_keys (ph->exchange); switch (response_code) { case 0: @@ -191,7 +189,7 @@ handle_recoup_refresh_finished (void *cls, rrr.hr.ec = TALER_JSON_get_error_code (j); rrr.hr.hint = TALER_JSON_get_error_hint (j); if (GNUNET_OK != - TALER_EXCHANGE_get_min_denomination_ (keys, + TALER_EXCHANGE_get_min_denomination_ (ph->keys, &min_key)) { GNUNET_break (0); @@ -201,7 +199,7 @@ handle_recoup_refresh_finished (void *cls, } if (GNUNET_OK != TALER_EXCHANGE_check_coin_conflict_ ( - keys, + ph->keys, j, &ph->pk, &ph->coin_pub, @@ -246,7 +244,9 @@ handle_recoup_refresh_finished (void *cls, struct TALER_EXCHANGE_RecoupRefreshHandle * TALER_EXCHANGE_recoup_refresh ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_EXCHANGE_DenomPublicKey *pk, const struct TALER_DenominationSignature *denom_sig, const struct TALER_ExchangeWithdrawValues *exchange_vals, @@ -257,7 +257,6 @@ TALER_EXCHANGE_recoup_refresh ( void *recoup_cb_cls) { struct TALER_EXCHANGE_RecoupRefreshHandle *ph; - struct GNUNET_CURL_Context *ctx; struct TALER_DenominationHashP h_denom_pub; json_t *recoup_obj; CURL *eh; @@ -266,10 +265,7 @@ TALER_EXCHANGE_recoup_refresh ( union TALER_DenominationBlindingKeyP bks; GNUNET_assert (NULL != recoup_cb); - GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); ph = GNUNET_new (struct TALER_EXCHANGE_RecoupRefreshHandle); - ph->exchange = exchange; ph->pk = *pk; memset (&ph->pk.key, 0, @@ -333,12 +329,13 @@ TALER_EXCHANGE_recoup_refresh ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/coins/%s/recoup-refresh", + "coins/%s/recoup-refresh", pub_str); } - ph->url = TEAH_path_to_url (exchange, - arg_str); + ph->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == ph->url) { json_decref (recoup_obj); @@ -364,7 +361,7 @@ TALER_EXCHANGE_recoup_refresh ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for recoup-refresh: `%s'\n", ph->url); - ctx = TEAH_handle_to_context (exchange); + ph->keys = TALER_EXCHANGE_keys_incref (keys); ph->job = GNUNET_CURL_job_add2 (ctx, eh, ph->ctx.headers, @@ -385,6 +382,7 @@ TALER_EXCHANGE_recoup_refresh_cancel ( } GNUNET_free (ph->url); TALER_curl_easy_post_finished (&ph->ctx); + TALER_EXCHANGE_keys_decref (ph->keys); GNUNET_free (ph); } diff --git a/src/lib/exchange_api_refreshes_reveal.c b/src/lib/exchange_api_refreshes_reveal.c index 50de76810..9b6f9b19c 100644 --- a/src/lib/exchange_api_refreshes_reveal.c +++ b/src/lib/exchange_api_refreshes_reveal.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2022 Taler Systems SA + Copyright (C) 2015-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 @@ -40,11 +40,6 @@ struct TALER_EXCHANGE_RefreshesRevealHandle { /** - * The connection to exchange this request handle will use - */ - struct TALER_EXCHANGE_Handle *exchange; - - /** * The url for this request. */ char *url; @@ -310,7 +305,8 @@ handle_refresh_reveal_finished (void *cls, struct TALER_EXCHANGE_RefreshesRevealHandle * TALER_EXCHANGE_refreshes_reveal ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, const struct TALER_RefreshMasterSecretP *rms, const struct TALER_EXCHANGE_RefreshData *rd, unsigned int num_coins, @@ -327,7 +323,6 @@ TALER_EXCHANGE_refreshes_reveal ( json_t *link_sigs; json_t *old_age_commitment = NULL; CURL *eh; - struct GNUNET_CURL_Context *ctx; struct MeltData md; char arg_str[sizeof (struct TALER_RefreshCommitmentP) * 2 + 32]; bool send_rms = false; @@ -342,12 +337,6 @@ TALER_EXCHANGE_refreshes_reveal ( GNUNET_break (0); return NULL; } - if (GNUNET_YES != - TEAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } if (GNUNET_OK != TALER_EXCHANGE_get_melt_data_ (rms, rd, @@ -467,22 +456,22 @@ TALER_EXCHANGE_refreshes_reveal ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/refreshes/%s/reveal", + "refreshes/%s/reveal", pub_str); } /* finally, we can actually issue the request */ rrh = GNUNET_new (struct TALER_EXCHANGE_RefreshesRevealHandle); - rrh->exchange = exchange; rrh->noreveal_index = noreveal_index; rrh->reveal_cb = reveal_cb; rrh->reveal_cb_cls = reveal_cb_cls; rrh->md = md; - rrh->alg_values = GNUNET_memdup (alg_values, - md.num_fresh_coins - * sizeof (struct - TALER_ExchangeWithdrawValues)); - rrh->url = TEAH_path_to_url (rrh->exchange, - arg_str); + rrh->alg_values + = GNUNET_memdup (alg_values, + md.num_fresh_coins + * sizeof (struct TALER_ExchangeWithdrawValues)); + rrh->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == rrh->url) { json_decref (reveal_obj); @@ -510,7 +499,6 @@ TALER_EXCHANGE_refreshes_reveal ( return NULL; } json_decref (reveal_obj); - ctx = TEAH_handle_to_context (rrh->exchange); rrh->job = GNUNET_CURL_job_add2 (ctx, eh, rrh->ctx.headers, diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 35524ca4b..83f9612df 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 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 @@ -39,9 +39,9 @@ struct TALER_EXCHANGE_RefundHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -117,7 +117,6 @@ verify_refund_signature_ok (struct TALER_EXCHANGE_RefundHandle *rh, struct TALER_ExchangePublicKeyP *exchange_pub, struct TALER_ExchangeSignatureP *exchange_sig) { - const struct TALER_EXCHANGE_Keys *key_state; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("exchange_sig", exchange_sig), @@ -134,9 +133,8 @@ verify_refund_signature_ok (struct TALER_EXCHANGE_RefundHandle *rh, GNUNET_break_op (0); return GNUNET_SYSERR; } - key_state = TALER_EXCHANGE_get_keys (rh->exchange); if (GNUNET_OK != - TALER_EXCHANGE_test_signing_key (key_state, + TALER_EXCHANGE_test_signing_key (rh->keys, exchange_pub)) { GNUNET_break_op (0); @@ -672,7 +670,9 @@ handle_refund_finished (void *cls, struct TALER_EXCHANGE_RefundHandle * TALER_EXCHANGE_refund ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_Amount *amount, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_CoinSpendPublicKeyP *coin_pub, @@ -684,13 +684,10 @@ TALER_EXCHANGE_refund ( struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_MerchantSignatureP merchant_sig; struct TALER_EXCHANGE_RefundHandle *rh; - struct GNUNET_CURL_Context *ctx; json_t *refund_obj; CURL *eh; char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32]; - GNUNET_assert (GNUNET_YES == - TEAH_handle_is_ready (exchange)); GNUNET_CRYPTO_eddsa_key_get_public (&merchant_priv->eddsa_priv, &merchant_pub.eddsa_pub); TALER_merchant_refund_sign (coin_pub, @@ -711,7 +708,7 @@ TALER_EXCHANGE_refund ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/coins/%s/refund", + "coins/%s/refund", pub_str); } refund_obj = GNUNET_JSON_PACK ( @@ -726,11 +723,11 @@ TALER_EXCHANGE_refund ( GNUNET_JSON_pack_data_auto ("merchant_sig", &merchant_sig)); rh = GNUNET_new (struct TALER_EXCHANGE_RefundHandle); - rh->exchange = exchange; rh->cb = cb; rh->cb_cls = cb_cls; - rh->url = TEAH_path_to_url (exchange, - arg_str); + rh->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == rh->url) { json_decref (refund_obj); @@ -761,7 +758,7 @@ TALER_EXCHANGE_refund ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "URL for refund: `%s'\n", rh->url); - ctx = TEAH_handle_to_context (exchange); + rh->keys = TALER_EXCHANGE_keys_incref (keys); rh->job = GNUNET_CURL_job_add2 (ctx, eh, rh->ctx.headers, @@ -781,6 +778,7 @@ TALER_EXCHANGE_refund_cancel (struct TALER_EXCHANGE_RefundHandle *refund) } GNUNET_free (refund->url); TALER_curl_easy_post_finished (&refund->ctx); + TALER_EXCHANGE_keys_decref (refund->keys); GNUNET_free (refund); } diff --git a/src/lib/exchange_api_reserves_close.c b/src/lib/exchange_api_reserves_close.c index 278d13101..a3769a22f 100644 --- a/src/lib/exchange_api_reserves_close.c +++ b/src/lib/exchange_api_reserves_close.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 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 @@ -39,11 +39,6 @@ struct TALER_EXCHANGE_ReservesCloseHandle { /** - * The connection to exchange this request handle will use - */ - struct TALER_EXCHANGE_Handle *exchange; - - /** * The url for this request. */ char *url; @@ -269,26 +264,19 @@ handle_reserves_close_finished (void *cls, struct TALER_EXCHANGE_ReservesCloseHandle * TALER_EXCHANGE_reserves_close ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, const struct TALER_ReservePrivateKeyP *reserve_priv, const char *target_payto_uri, TALER_EXCHANGE_ReservesCloseCallback cb, void *cb_cls) { struct TALER_EXCHANGE_ReservesCloseHandle *rch; - struct GNUNET_CURL_Context *ctx; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; struct TALER_PaytoHashP h_payto; - if (GNUNET_YES != - TEAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } rch = GNUNET_new (struct TALER_EXCHANGE_ReservesCloseHandle); - rch->exchange = exchange; rch->cb = cb; rch->cb_cls = cb_cls; rch->ts = GNUNET_TIME_timestamp_get (); @@ -306,11 +294,12 @@ TALER_EXCHANGE_reserves_close ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/reserves/%s/close", + "reserves/%s/close", pub_str); } - rch->url = TEAH_path_to_url (exchange, - arg_str); + rch->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == rch->url) { GNUNET_free (rch); @@ -357,7 +346,6 @@ TALER_EXCHANGE_reserves_close ( } json_decref (close_obj); } - ctx = TEAH_handle_to_context (exchange); rch->job = GNUNET_CURL_job_add2 (ctx, eh, rch->post_ctx.headers, diff --git a/src/lib/exchange_api_reserves_history.c b/src/lib/exchange_api_reserves_history.c index ccc11a270..a48e0c087 100644 --- a/src/lib/exchange_api_reserves_history.c +++ b/src/lib/exchange_api_reserves_history.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 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 @@ -39,9 +39,9 @@ struct TALER_EXCHANGE_ReservesHistoryHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -131,7 +131,7 @@ handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh, rhistory = GNUNET_new_array (len, struct TALER_EXCHANGE_ReserveHistoryEntry); if (GNUNET_OK != - TALER_EXCHANGE_parse_reserve_history (rsh->exchange, + TALER_EXCHANGE_parse_reserve_history (rsh->keys, history, &rsh->reserve_pub, rs.details.ok.balance.currency, @@ -250,26 +250,19 @@ handle_reserves_history_finished (void *cls, struct TALER_EXCHANGE_ReservesHistoryHandle * TALER_EXCHANGE_reserves_history ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, TALER_EXCHANGE_ReservesHistoryCallback cb, void *cb_cls) { struct TALER_EXCHANGE_ReservesHistoryHandle *rsh; - struct GNUNET_CURL_Context *ctx; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; - const struct TALER_EXCHANGE_Keys *keys; const struct TALER_EXCHANGE_GlobalFee *gf; - if (GNUNET_YES != - TEAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } rsh = GNUNET_new (struct TALER_EXCHANGE_ReservesHistoryHandle); - rsh->exchange = exchange; rsh->cb = cb; rsh->cb_cls = cb_cls; rsh->ts = GNUNET_TIME_timestamp_get (); @@ -287,11 +280,12 @@ TALER_EXCHANGE_reserves_history ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/reserves/%s/history", + "reserves/%s/history", pub_str); } - rsh->url = TEAH_path_to_url (exchange, - arg_str); + rsh->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == rsh->url) { GNUNET_free (rsh); @@ -305,15 +299,6 @@ TALER_EXCHANGE_reserves_history ( GNUNET_free (rsh); return NULL; } - keys = TALER_EXCHANGE_get_keys (exchange); - if (NULL == keys) - { - GNUNET_break (0); - curl_easy_cleanup (eh); - GNUNET_free (rsh->url); - GNUNET_free (rsh); - return NULL; - } gf = TALER_EXCHANGE_get_global_fee (keys, rsh->ts); if (NULL == gf) @@ -349,7 +334,7 @@ TALER_EXCHANGE_reserves_history ( } json_decref (history_obj); } - ctx = TEAH_handle_to_context (exchange); + rsh->keys = TALER_EXCHANGE_keys_incref (keys); rsh->job = GNUNET_CURL_job_add2 (ctx, eh, rsh->post_ctx.headers, @@ -370,6 +355,7 @@ TALER_EXCHANGE_reserves_history_cancel ( } TALER_curl_easy_post_finished (&rsh->post_ctx); GNUNET_free (rsh->url); + TALER_EXCHANGE_keys_decref (rsh->keys); GNUNET_free (rsh); } diff --git a/src/lib/exchange_api_reserves_open.c b/src/lib/exchange_api_reserves_open.c index 2b7ef0d90..b28333d51 100644 --- a/src/lib/exchange_api_reserves_open.c +++ b/src/lib/exchange_api_reserves_open.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 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 @@ -67,9 +67,9 @@ struct TALER_EXCHANGE_ReservesOpenHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -321,7 +321,6 @@ handle_reserves_open_finished (void *cls, break; case MHD_HTTP_CONFLICT: { - const struct TALER_EXCHANGE_Keys *keys; const struct CoinData *cd = NULL; struct TALER_CoinSpendPublicKeyP coin_pub; const struct TALER_EXCHANGE_DenomPublicKey *dk; @@ -331,8 +330,6 @@ handle_reserves_open_finished (void *cls, GNUNET_JSON_spec_end () }; - keys = TALER_EXCHANGE_get_keys (roh->exchange); - GNUNET_assert (NULL != keys); if (GNUNET_OK != GNUNET_JSON_parse (j, spec, @@ -362,7 +359,7 @@ handle_reserves_open_finished (void *cls, rs.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; break; } - dk = TALER_EXCHANGE_get_denomination_key_by_hash (keys, + dk = TALER_EXCHANGE_get_denomination_key_by_hash (roh->keys, &cd->h_denom_pub); if (NULL == dk) { @@ -372,7 +369,7 @@ handle_reserves_open_finished (void *cls, break; } if (GNUNET_OK != - TALER_EXCHANGE_check_coin_conflict_ (keys, + TALER_EXCHANGE_check_coin_conflict_ (roh->keys, j, dk, &coin_pub, @@ -427,7 +424,9 @@ handle_reserves_open_finished (void *cls, struct TALER_EXCHANGE_ReservesOpenHandle * TALER_EXCHANGE_reserves_open ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, const struct TALER_Amount *reserve_contribution, unsigned int coin_payments_length, @@ -438,20 +437,11 @@ TALER_EXCHANGE_reserves_open ( void *cb_cls) { struct TALER_EXCHANGE_ReservesOpenHandle *roh; - struct GNUNET_CURL_Context *ctx; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; - const struct TALER_EXCHANGE_Keys *keys; json_t *cpa; - if (GNUNET_YES != - TEAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } roh = GNUNET_new (struct TALER_EXCHANGE_ReservesOpenHandle); - roh->exchange = exchange; roh->cb = cb; roh->cb_cls = cb_cls; roh->ts = GNUNET_TIME_timestamp_get (); @@ -469,11 +459,12 @@ TALER_EXCHANGE_reserves_open ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/reserves/%s/open", + "reserves/%s/open", pub_str); } - roh->url = TEAH_path_to_url (exchange, - arg_str); + roh->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == roh->url) { GNUNET_free (roh); @@ -487,15 +478,6 @@ TALER_EXCHANGE_reserves_open ( GNUNET_free (roh); return NULL; } - keys = TALER_EXCHANGE_get_keys (exchange); - if (NULL == keys) - { - GNUNET_break (0); - curl_easy_cleanup (eh); - GNUNET_free (roh->url); - GNUNET_free (roh); - return NULL; - } TALER_wallet_reserve_open_sign (reserve_contribution, roh->ts, expiration_time, @@ -578,7 +560,7 @@ TALER_EXCHANGE_reserves_open ( } json_decref (open_obj); } - ctx = TEAH_handle_to_context (exchange); + roh->keys = TALER_EXCHANGE_keys_incref (keys); roh->job = GNUNET_CURL_job_add2 (ctx, eh, roh->post_ctx.headers, @@ -600,6 +582,7 @@ TALER_EXCHANGE_reserves_open_cancel ( TALER_curl_easy_post_finished (&roh->post_ctx); GNUNET_free (roh->coins); GNUNET_free (roh->url); + TALER_EXCHANGE_keys_decref (roh->keys); GNUNET_free (roh); } diff --git a/src/lib/exchange_api_reserves_status.c b/src/lib/exchange_api_reserves_status.c index 57fb04276..9f98b7f8c 100644 --- a/src/lib/exchange_api_reserves_status.c +++ b/src/lib/exchange_api_reserves_status.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 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 @@ -39,9 +39,9 @@ struct TALER_EXCHANGE_ReservesStatusHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -119,7 +119,7 @@ handle_reserves_status_ok (struct TALER_EXCHANGE_ReservesStatusHandle *rsh, rhistory = GNUNET_new_array (len, struct TALER_EXCHANGE_ReserveHistoryEntry); if (GNUNET_OK != - TALER_EXCHANGE_parse_reserve_history (rsh->exchange, + TALER_EXCHANGE_parse_reserve_history (rsh->keys, history, &rsh->reserve_pub, rs.details.ok.balance.currency, @@ -233,27 +233,21 @@ handle_reserves_status_finished (void *cls, struct TALER_EXCHANGE_ReservesStatusHandle * TALER_EXCHANGE_reserves_status ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, TALER_EXCHANGE_ReservesStatusCallback cb, void *cb_cls) { struct TALER_EXCHANGE_ReservesStatusHandle *rsh; - struct GNUNET_CURL_Context *ctx; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; struct TALER_ReserveSignatureP reserve_sig; struct GNUNET_TIME_Timestamp ts = GNUNET_TIME_timestamp_get (); - if (GNUNET_YES != - TEAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } rsh = GNUNET_new (struct TALER_EXCHANGE_ReservesStatusHandle); - rsh->exchange = exchange; rsh->cb = cb; rsh->cb_cls = cb_cls; GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv, @@ -270,11 +264,12 @@ TALER_EXCHANGE_reserves_status ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/reserves/%s/status", + "reserves/%s/status", pub_str); } - rsh->url = TEAH_path_to_url (exchange, - arg_str); + rsh->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == rsh->url) { GNUNET_free (rsh); @@ -312,7 +307,7 @@ TALER_EXCHANGE_reserves_status ( } json_decref (status_obj); } - ctx = TEAH_handle_to_context (exchange); + rsh->keys = TALER_EXCHANGE_keys_incref (keys); rsh->job = GNUNET_CURL_job_add2 (ctx, eh, rsh->post_ctx.headers, @@ -333,6 +328,7 @@ TALER_EXCHANGE_reserves_status_cancel ( } TALER_curl_easy_post_finished (&rsh->post_ctx); GNUNET_free (rsh->url); + TALER_EXCHANGE_keys_decref (rsh->keys); GNUNET_free (rsh); } diff --git a/src/lib/exchange_api_transfers_get.c b/src/lib/exchange_api_transfers_get.c index 3a5a64fd5..14cf51ff9 100644 --- a/src/lib/exchange_api_transfers_get.c +++ b/src/lib/exchange_api_transfers_get.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 @@ -38,9 +38,9 @@ struct TALER_EXCHANGE_TransfersGetHandle { /** - * The connection to exchange this request handle will use + * The keys of the exchange this request handle will use */ - struct TALER_EXCHANGE_Handle *exchange; + struct TALER_EXCHANGE_Keys *keys; /** * The url for this request. @@ -130,7 +130,7 @@ check_transfers_get_response_ok ( } if (GNUNET_OK != TALER_EXCHANGE_test_signing_key ( - TALER_EXCHANGE_get_keys (wdh->exchange), + wdh->keys, &td->exchange_pub)) { GNUNET_break_op (0); @@ -320,25 +320,18 @@ handle_transfers_get_finished (void *cls, struct TALER_EXCHANGE_TransfersGetHandle * TALER_EXCHANGE_transfers_get ( - struct TALER_EXCHANGE_Handle *exchange, + struct GNUNET_CURL_Context *ctx, + const char *url, + struct TALER_EXCHANGE_Keys *keys, const struct TALER_WireTransferIdentifierRawP *wtid, TALER_EXCHANGE_TransfersGetCallback cb, void *cb_cls) { struct TALER_EXCHANGE_TransfersGetHandle *wdh; - struct GNUNET_CURL_Context *ctx; CURL *eh; char arg_str[sizeof (struct TALER_WireTransferIdentifierRawP) * 2 + 32]; - if (GNUNET_YES != - TEAH_handle_is_ready (exchange)) - { - GNUNET_break (0); - return NULL; - } - wdh = GNUNET_new (struct TALER_EXCHANGE_TransfersGetHandle); - wdh->exchange = exchange; wdh->cb = cb; wdh->cb_cls = cb_cls; @@ -354,11 +347,12 @@ TALER_EXCHANGE_transfers_get ( *end = '\0'; GNUNET_snprintf (arg_str, sizeof (arg_str), - "/transfers/%s", + "transfers/%s", wtid_str); } - wdh->url = TEAH_path_to_url (wdh->exchange, - arg_str); + wdh->url = TALER_url_join (url, + arg_str, + NULL); if (NULL == wdh->url) { GNUNET_free (wdh); @@ -372,7 +366,7 @@ TALER_EXCHANGE_transfers_get ( GNUNET_free (wdh); return NULL; } - ctx = TEAH_handle_to_context (exchange); + wdh->keys = TALER_EXCHANGE_keys_incref (keys); wdh->job = GNUNET_CURL_job_add_with_ct_json (ctx, eh, &handle_transfers_get_finished, @@ -397,6 +391,7 @@ TALER_EXCHANGE_transfers_get_cancel ( wdh->job = NULL; } GNUNET_free (wdh->url); + TALER_EXCHANGE_keys_decref (wdh->keys); GNUNET_free (wdh); } diff --git a/src/lib/exchange_api_withdraw2.c b/src/lib/exchange_api_withdraw2.c index bf2bd0237..daac429c7 100644 --- a/src/lib/exchange_api_withdraw2.c +++ b/src/lib/exchange_api_withdraw2.c @@ -192,7 +192,8 @@ reserve_withdraw_payment_required ( } if (GNUNET_OK != - TALER_EXCHANGE_parse_reserve_history (wh->exchange, + TALER_EXCHANGE_parse_reserve_history (TALER_EXCHANGE_get_keys ( + wh->exchange), history, &wh->reserve_pub, balance.currency, |