diff options
Diffstat (limited to 'src/lib/exchange_api_management_set_wire_fee.c')
-rw-r--r-- | src/lib/exchange_api_management_set_wire_fee.c | 66 |
1 files changed, 41 insertions, 25 deletions
diff --git a/src/lib/exchange_api_management_set_wire_fee.c b/src/lib/exchange_api_management_set_wire_fee.c index 807c6723a..aaeae21f4 100644 --- a/src/lib/exchange_api_management_set_wire_fee.c +++ b/src/lib/exchange_api_management_set_wire_fee.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020-2021 Taler Systems SA + Copyright (C) 2020-2022 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 @@ -79,9 +79,9 @@ handle_set_wire_fee_finished (void *cls, { struct TALER_EXCHANGE_ManagementSetWireFeeHandle *swfh = cls; const json_t *json = response; - struct TALER_EXCHANGE_HttpResponse hr = { - .http_status = (unsigned int) response_code, - .reply = json + struct TALER_EXCHANGE_ManagementSetWireFeeResponse swr = { + .hr.http_status = (unsigned int) response_code, + .hr.reply = json }; swfh->job = NULL; @@ -90,32 +90,47 @@ handle_set_wire_fee_finished (void *cls, case MHD_HTTP_NO_CONTENT: break; case MHD_HTTP_FORBIDDEN: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + swr.hr.ec = TALER_JSON_get_error_code (json); + swr.hr.hint = TALER_JSON_get_error_hint (json); + break; + case MHD_HTTP_NOT_FOUND: + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Server did not find handler at `%s'. Did you configure the correct exchange base URL?\n", + swfh->url); + if (NULL != json) + { + swr.hr.ec = TALER_JSON_get_error_code (json); + swr.hr.hint = TALER_JSON_get_error_hint (json); + } + else + { + swr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + swr.hr.hint = TALER_ErrorCode_get_hint (swr.hr.ec); + } break; case MHD_HTTP_CONFLICT: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + swr.hr.ec = TALER_JSON_get_error_code (json); + swr.hr.hint = TALER_JSON_get_error_hint (json); break; case MHD_HTTP_PRECONDITION_FAILED: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + swr.hr.ec = TALER_JSON_get_error_code (json); + swr.hr.hint = TALER_JSON_get_error_hint (json); break; default: /* unexpected response code */ GNUNET_break_op (0); - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + swr.hr.ec = TALER_JSON_get_error_code (json); + swr.hr.hint = TALER_JSON_get_error_hint (json); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u/%d for exchange management set wire fee\n", (unsigned int) response_code, - (int) hr.ec); + (int) swr.hr.ec); break; } if (NULL != swfh->cb) { swfh->cb (swfh->cb_cls, - &hr); + &swr); swfh->cb = NULL; } TALER_EXCHANGE_management_set_wire_fees_cancel (swfh); @@ -129,10 +144,9 @@ TALER_EXCHANGE_management_set_wire_fees ( const char *wire_method, struct GNUNET_TIME_Timestamp validity_start, struct GNUNET_TIME_Timestamp validity_end, - const struct TALER_Amount *wire_fee, - const struct TALER_Amount *closing_fee, + const struct TALER_WireFeeSet *fees, const struct TALER_MasterSignatureP *master_sig, - TALER_EXCHANGE_ManagementWireEnableCallback cb, + TALER_EXCHANGE_ManagementSetWireFeeCallback cb, void *cb_cls) { struct TALER_EXCHANGE_ManagementSetWireFeeHandle *swfh; @@ -163,20 +177,22 @@ TALER_EXCHANGE_management_set_wire_fees ( GNUNET_JSON_pack_timestamp ("fee_end", validity_end), TALER_JSON_pack_amount ("closing_fee", - closing_fee), + &fees->closing), TALER_JSON_pack_amount ("wire_fee", - wire_fee)); + &fees->wire)); eh = TALER_EXCHANGE_curl_easy_get_ (swfh->url); - GNUNET_assert (NULL != eh); - if (GNUNET_OK != - TALER_curl_easy_post (&swfh->post_ctx, - eh, - body)) + if ( (NULL == eh) || + (GNUNET_OK != + TALER_curl_easy_post (&swfh->post_ctx, + eh, + body)) ) { GNUNET_break (0); + if (NULL != eh) + curl_easy_cleanup (eh); json_decref (body); GNUNET_free (swfh->url); - GNUNET_free (eh); + GNUNET_free (swfh); return NULL; } json_decref (body); |