summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_reserves_open.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/exchange_api_reserves_open.c')
-rw-r--r--src/lib/exchange_api_reserves_open.c72
1 files changed, 16 insertions, 56 deletions
diff --git a/src/lib/exchange_api_reserves_open.c b/src/lib/exchange_api_reserves_open.c
index 2b7ef0d90..36e435685 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,18 +321,13 @@ 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;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("coin_pub",
- &coin_pub),
+ &rs.details.conflict.coin_pub),
GNUNET_JSON_spec_end ()
};
- keys = TALER_EXCHANGE_get_keys (roh->exchange);
- GNUNET_assert (NULL != keys);
if (GNUNET_OK !=
GNUNET_JSON_parse (j,
spec,
@@ -348,7 +343,7 @@ handle_reserves_open_finished (void *cls,
{
const struct CoinData *cdi = &roh->coins[i];
- if (0 == GNUNET_memcmp (&coin_pub,
+ if (0 == GNUNET_memcmp (&rs.details.conflict.coin_pub,
&cdi->coin_pub))
{
cd = cdi;
@@ -362,28 +357,6 @@ handle_reserves_open_finished (void *cls,
rs.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
break;
}
- dk = TALER_EXCHANGE_get_denomination_key_by_hash (keys,
- &cd->h_denom_pub);
- if (NULL == dk)
- {
- GNUNET_break_op (0);
- rs.hr.http_status = 0;
- rs.hr.ec = TALER_EC_GENERIC_CLIENT_INTERNAL_ERROR;
- break;
- }
- if (GNUNET_OK !=
- TALER_EXCHANGE_check_coin_conflict_ (keys,
- j,
- dk,
- &coin_pub,
- &cd->coin_sig,
- &cd->contribution))
- {
- GNUNET_break_op (0);
- rs.hr.http_status = 0;
- rs.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
- break;
- }
rs.hr.ec = TALER_JSON_get_error_code (j);
rs.hr.hint = TALER_JSON_get_error_hint (j);
break;
@@ -427,31 +400,25 @@ 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,
- const struct TALER_EXCHANGE_PurseDeposit *coin_payments,
+ const struct TALER_EXCHANGE_PurseDeposit coin_payments[
+ static coin_payments_length],
struct GNUNET_TIME_Timestamp expiration_time,
uint32_t min_purses,
TALER_EXCHANGE_ReservesOpenCallback cb,
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 +436,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 +455,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 +537,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 +559,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);
}