diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-06-25 19:10:35 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-06-25 19:10:35 +0200 |
commit | 53fa3aeb17b60ed130d9095f977660efb223a297 (patch) | |
tree | 5afac0aa94b1e49b8121260c19fe872c130f6ff1 /src/backend | |
parent | 0d8aeec575f6e12bb06a5eedeabf70436058595a (diff) | |
download | merchant-53fa3aeb17b60ed130d9095f977660efb223a297.tar.gz merchant-53fa3aeb17b60ed130d9095f977660efb223a297.tar.bz2 merchant-53fa3aeb17b60ed130d9095f977660efb223a297.zip |
adapt to latest exchange API changes
Diffstat (limited to 'src/backend')
5 files changed, 79 insertions, 122 deletions
diff --git a/src/backend/taler-merchant-exchange.c b/src/backend/taler-merchant-exchange.c index a0b53cf8..d8755ee7 100644 --- a/src/backend/taler-merchant-exchange.c +++ b/src/backend/taler-merchant-exchange.c @@ -940,10 +940,13 @@ exchange_request (void *cls) w->task = NULL; GNUNET_assert (e->ready); - w->wdh = TALER_EXCHANGE_transfers_get (e->conn, - &w->wtid, - &wire_transfer_cb, - w); + w->wdh = TALER_EXCHANGE_transfers_get ( + ctx, + e->exchange_url, + TALER_EXCHANGE_get_keys (e->conn), + &w->wtid, + &wire_transfer_cb, + w); if (NULL == w->wdh) { GNUNET_break (0); diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c index 5361496d..f5d76436 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c @@ -176,7 +176,7 @@ struct AbortContext * the exchange used for this transaction; NULL if no operation is * pending. */ - struct TMH_EXCHANGES_FindOperation *fo; + struct TMH_EXCHANGES_Find2Operation *fo; /** * URL of the exchange used for the last @e fo. @@ -438,7 +438,7 @@ abort_context_cleanup (void *cls) GNUNET_free (ac->rd); if (NULL != ac->fo) { - TMH_EXCHANGES_find_exchange_cancel (ac->fo); + TMH_EXCHANGES_keys4exchange_cancel (ac->fo); ac->fo = NULL; } if (NULL != ac->response) @@ -496,22 +496,17 @@ refund_cb (void *cls, * Function called with the result of our exchange lookup. * * @param cls the `struct AbortContext` - * @param hr HTTP response details - * @param exchange_handle NULL if exchange was not found to be acceptable - * @param ih internal handle to the exchange + * @param keys keys of the exchange */ static void process_abort_with_exchange (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - struct TALER_EXCHANGE_Handle *exchange_handle, - struct TMH_Exchange *ih) + struct TALER_EXCHANGE_Keys *keys) { struct AbortContext *ac = cls; - (void) ih; ac->fo = NULL; GNUNET_assert (GNUNET_YES == ac->suspended); - if (NULL == hr) + if (NULL == keys) { resume_abort_with_response ( ac, @@ -521,19 +516,6 @@ process_abort_with_exchange (void *cls, NULL)); return; } - if (NULL == exchange_handle) - { - /* The request failed somehow */ - GNUNET_break_op (0); - resume_abort_with_response ( - ac, - MHD_HTTP_BAD_GATEWAY, - TALER_MHD_MAKE_JSON_PACK ( - TALER_JSON_pack_ec ( - TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE), - TMH_pack_exchange_reply (hr))); - return; - } /* Initiate refund operation for all coins of the current exchange (!) */ GNUNET_assert (0 == ac->pending_at_ce); @@ -549,14 +531,17 @@ process_abort_with_exchange (void *cls, continue; rdi->processed = true; ac->pending--; - rdi->rh = TALER_EXCHANGE_refund (exchange_handle, - &rdi->amount_with_fee, - &ac->h_contract_terms, - &rdi->coin_pub, - 0, /* rtransaction_id */ - &ac->hc->instance->merchant_priv, - &refund_cb, - rdi); + rdi->rh = TALER_EXCHANGE_refund ( + merchant_curl_ctx, + ac->current_exchange, + keys, + &rdi->amount_with_fee, + &ac->h_contract_terms, + &rdi->coin_pub, + 0, /* rtransaction_id */ + &ac->hc->instance->merchant_priv, + &refund_cb, + rdi); if (NULL == rdi->rh) { GNUNET_break_op (0); @@ -598,8 +583,7 @@ find_next_exchange (struct AbortContext *ac) if (! rdi->processed) { ac->current_exchange = rdi->exchange_url; - ac->fo = TMH_EXCHANGES_find_exchange (ac->current_exchange, - false, + ac->fo = TMH_EXCHANGES_keys4exchange (ac->current_exchange, &process_abort_with_exchange, ac); if (NULL == ac->fo) @@ -944,7 +928,7 @@ handle_abort_timeout (void *cls) "Resuming abort with error after timeout\n"); if (NULL != ac->fo) { - TMH_EXCHANGES_find_exchange_cancel (ac->fo); + TMH_EXCHANGES_keys4exchange_cancel (ac->fo); ac->fo = NULL; } resume_abort_with_error (ac, diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c index 28ba72df..3a051a3c 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -454,7 +454,7 @@ struct KycContext /** * Looking for the exchange. */ - struct TMH_EXCHANGES_FindOperation *fo; + struct TMH_EXCHANGES_Find2Operation *fo; /** * Exchange this is about. @@ -530,7 +530,7 @@ destroy_kc (struct KycContext *kc) { if (NULL != kc->fo) { - TMH_EXCHANGES_find_exchange_cancel (kc->fo); + TMH_EXCHANGES_keys4exchange_cancel (kc->fo); kc->fo = NULL; } if (NULL != kc->dg) @@ -779,34 +779,32 @@ deposit_get_callback ( * Function called with the result of our exchange lookup. * * @param cls the `struct KycContext` - * @param hr HTTP response details - * @param exchange_handle NULL if exchange was not found to be acceptable - * @param ih internal handle to the exchange + * @param keys NULL if exchange was not found to be acceptable */ static void process_kyc_with_exchange ( void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - struct TALER_EXCHANGE_Handle *exchange_handle, - struct TMH_Exchange *ih) + struct TALER_EXCHANGE_Keys *keys) { struct KycContext *kc = cls; - (void) ih; kc->fo = NULL; - if (NULL == exchange_handle) + if (NULL == keys) { destroy_kc (kc); return; } - kc->dg = TALER_EXCHANGE_deposits_get (exchange_handle, - &kc->mi->merchant_priv, - &kc->wm->h_wire, - &kc->h_contract_terms, - &kc->coin_pub, - GNUNET_TIME_UNIT_ZERO, - &deposit_get_callback, - kc); + kc->dg = TALER_EXCHANGE_deposits_get ( + merchant_curl_ctx, + kc->exchange_url, + keys, + &kc->mi->merchant_priv, + &kc->wm->h_wire, + &kc->h_contract_terms, + &kc->coin_pub, + GNUNET_TIME_UNIT_ZERO, + &deposit_get_callback, + kc); if (NULL == kc->dg) { GNUNET_break (0); @@ -919,8 +917,7 @@ check_kyc (struct PayContext *pc, GNUNET_CONTAINER_DLL_insert (kc_head, kc_tail, kc); - kc->fo = TMH_EXCHANGES_find_exchange (kc->exchange_url, - false, + kc->fo = TMH_EXCHANGES_keys4exchange (kc->exchange_url, &process_kyc_with_exchange, kc); if (NULL == kc->fo) diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c index ba562f9e..a20f6b12 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c @@ -51,7 +51,7 @@ struct CoinRefund /** * Request to connect to the target exchange. */ - struct TMH_EXCHANGES_FindOperation *fo; + struct TMH_EXCHANGES_Find2Operation *fo; /** * Handle for the refund operation with the exchange. @@ -278,7 +278,7 @@ refund_cleanup (void *ctx) GNUNET_free (cr->exchange_url); if (NULL != cr->fo) { - TMH_EXCHANGES_find_exchange_cancel (cr->fo); + TMH_EXCHANGES_keys4exchange_cancel (cr->fo); cr->fo = NULL; } if (NULL != cr->rh) @@ -433,47 +433,39 @@ refund_cb (void *cls, /** - * Function called with the result of a #TMH_EXCHANGES_find_exchange() + * Function called with the result of a + * #TMH_EXCHANGES_keys4exchange() * operation. * * @param cls a `struct CoinRefund *` - * @param hr HTTP response details - * @param eh handle to the exchange context - * @param ih internal handle to the exchange + * @param keys keys of exchange, NULL on error */ static void exchange_found_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - struct TALER_EXCHANGE_Handle *eh, - struct TMH_Exchange *ih) + struct TALER_EXCHANGE_Keys *keys) { struct CoinRefund *cr = cls; struct PostRefundData *prd = cr->prd; - (void) ih; cr->fo = NULL; - if (NULL == hr) + if (NULL == keys) { prd->http_status = MHD_HTTP_GATEWAY_TIMEOUT; prd->ec = TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT; check_resume_prd (prd); return; } - if (NULL == eh) - { - prd->http_status = MHD_HTTP_BAD_GATEWAY; - prd->ec = TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE; - check_resume_prd (prd); - return; - } - cr->rh = TALER_EXCHANGE_refund (eh, - &cr->refund_amount, - &prd->h_contract_terms, - &cr->coin_pub, - cr->rtransaction_id, - &prd->hc->instance->merchant_priv, - &refund_cb, - cr); + cr->rh = TALER_EXCHANGE_refund ( + merchant_curl_ctx, + cr->exchange_url, + keys, + &cr->refund_amount, + &prd->h_contract_terms, + &cr->coin_pub, + cr->rtransaction_id, + &prd->hc->instance->merchant_priv, + &refund_cb, + cr); } @@ -657,7 +649,7 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, { if (NULL != cr->fo) { - TMH_EXCHANGES_find_exchange_cancel (cr->fo); + TMH_EXCHANGES_keys4exchange_cancel (cr->fo); cr->fo = NULL; } if (NULL != cr->rh) @@ -714,8 +706,7 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, if (NULL == cr->exchange_reply) { /* We need to talk to the exchange */ - cr->fo = TMH_EXCHANGES_find_exchange (cr->exchange_url, - false, + cr->fo = TMH_EXCHANGES_keys4exchange (cr->exchange_url, &exchange_found_cb, cr); } diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c index 27d98949..788c7bf1 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -73,7 +73,7 @@ struct TransferQuery /** * Handle for ongoing exchange operation. */ - struct TMH_EXCHANGES_FindOperation *fo; + struct TMH_EXCHANGES_Find2Operation *fo; /** * Overall request this TQ belongs with. @@ -340,7 +340,7 @@ gorc_resume (struct GetOrderRequestContext *gorc, { if (NULL != tq->fo) { - TMH_EXCHANGES_find_exchange_cancel (tq->fo); + TMH_EXCHANGES_keys4exchange_cancel (tq->fo); tq->fo = NULL; } if (NULL != tq->dgh) @@ -590,22 +590,17 @@ deposit_get_cb (void *cls, * operation. * * @param cls closure with a `struct GetOrderRequestContext *` - * @param hr HTTP response details - * @param eh handle to the exchange context - * @param ih internal handle for the exchange + * @param keys keys of the exchange */ static void exchange_found_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr, - struct TALER_EXCHANGE_Handle *eh, - struct TMH_Exchange *ih) + struct TALER_EXCHANGE_Keys *keys) { struct TransferQuery *tq = cls; struct GetOrderRequestContext *gorc = tq->gorc; - (void) ih; tq->fo = NULL; - if (NULL == hr) + if (NULL == keys) { /* failed */ GNUNET_CONTAINER_DLL_remove (gorc->tq_head, @@ -618,29 +613,17 @@ exchange_found_cb (void *cls, TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT); return; } - if (NULL == eh) - { - /* failed */ - GNUNET_CONTAINER_DLL_remove (gorc->tq_head, - gorc->tq_tail, - tq); - GNUNET_free (tq->exchange_url); - GNUNET_free (tq); - gorc->exchange_hc = hr->http_status; - gorc->exchange_ec = hr->ec; - gorc_resume (gorc, - MHD_HTTP_BAD_GATEWAY, - TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE); - return; - } - tq->dgh = TALER_EXCHANGE_deposits_get (eh, - &gorc->hc->instance->merchant_priv, - &tq->h_wire, - &gorc->h_contract_terms, - &tq->coin_pub, - GNUNET_TIME_UNIT_ZERO, - &deposit_get_cb, - tq); + tq->dgh = TALER_EXCHANGE_deposits_get ( + merchant_curl_ctx, + tq->exchange_url, + keys, + &gorc->hc->instance->merchant_priv, + &tq->h_wire, + &gorc->h_contract_terms, + &tq->coin_pub, + GNUNET_TIME_UNIT_ZERO, + &deposit_get_cb, + tq); if (NULL == tq->dgh) { GNUNET_CONTAINER_DLL_remove (gorc->tq_head, @@ -694,8 +677,7 @@ deposit_cb (void *cls, tq->h_wire = *h_wire; tq->amount_with_fee = *amount_with_fee; tq->deposit_fee = *deposit_fee; - tq->fo = TMH_EXCHANGES_find_exchange (exchange_url, - false, + tq->fo = TMH_EXCHANGES_keys4exchange (exchange_url, &exchange_found_cb, tq); if (NULL == tq->fo) |