summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_management_set_wire_fee.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/exchange_api_management_set_wire_fee.c')
-rw-r--r--src/lib/exchange_api_management_set_wire_fee.c84
1 files changed, 49 insertions, 35 deletions
diff --git a/src/lib/exchange_api_management_set_wire_fee.c b/src/lib/exchange_api_management_set_wire_fee.c
index 075dbbbba..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
@@ -22,6 +22,7 @@
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
+#include "exchange_api_curl_defaults.h"
#include "taler_exchange_service.h"
#include "taler_signatures.h"
#include "taler_curl_lib.h"
@@ -78,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;
@@ -89,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);
@@ -126,12 +142,11 @@ TALER_EXCHANGE_management_set_wire_fees (
struct GNUNET_CURL_Context *ctx,
const char *exchange_base_url,
const char *wire_method,
- struct GNUNET_TIME_Absolute validity_start,
- struct GNUNET_TIME_Absolute validity_end,
- const struct TALER_Amount *wire_fee,
- const struct TALER_Amount *closing_fee,
+ struct GNUNET_TIME_Timestamp validity_start,
+ struct GNUNET_TIME_Timestamp validity_end,
+ 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;
@@ -157,34 +172,33 @@ TALER_EXCHANGE_management_set_wire_fees (
wire_method),
GNUNET_JSON_pack_data_auto ("master_sig",
master_sig),
- GNUNET_JSON_pack_time_abs ("fee_start",
- validity_start),
- GNUNET_JSON_pack_time_abs ("fee_end",
- validity_end),
+ GNUNET_JSON_pack_timestamp ("fee_start",
+ validity_start),
+ 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));
- eh = curl_easy_init ();
- GNUNET_assert (NULL != eh);
- if (GNUNET_OK !=
- TALER_curl_easy_post (&swfh->post_ctx,
- eh,
- body))
+ &fees->wire));
+ eh = TALER_EXCHANGE_curl_easy_get_ (swfh->url);
+ 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);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Requesting URL '%s'\n",
swfh->url);
- GNUNET_assert (CURLE_OK == curl_easy_setopt (eh,
- CURLOPT_URL,
- swfh->url));
swfh->job = GNUNET_CURL_job_add2 (ctx,
eh,
swfh->post_ctx.headers,