summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_reserve.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/exchange_api_reserve.c')
-rw-r--r--src/lib/exchange_api_reserve.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/lib/exchange_api_reserve.c b/src/lib/exchange_api_reserve.c
index 4aa5794fa..ae0bd01d0 100644
--- a/src/lib/exchange_api_reserve.c
+++ b/src/lib/exchange_api_reserve.c
@@ -187,8 +187,8 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
struct GNUNET_JSON_Specification withdraw_spec[] = {
GNUNET_JSON_spec_fixed_auto ("reserve_sig",
&sig),
- TALER_JSON_spec_amount_nbo ("withdraw_fee",
- &withdraw_purpose.withdraw_fee),
+ TALER_JSON_spec_amount_nbo ("withdraw_fee",
+ &withdraw_purpose.withdraw_fee),
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
&withdraw_purpose.h_denomination_pub),
GNUNET_JSON_spec_fixed_auto ("h_coin_envelope",
@@ -677,9 +677,10 @@ struct TALER_EXCHANGE_ReserveWithdrawHandle
char *url;
/**
- * JSON encoding of the request to POST.
+ * Context for #TEH_curl_easy_post(). Keeps the data that must
+ * persist for Curl to make the upload.
*/
- char *json_enc;
+ struct TEAH_PostContext ctx;
/**
* Handle for the request.
@@ -1001,6 +1002,7 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange,
struct GNUNET_CURL_Context *ctx;
json_t *withdraw_obj;
CURL *eh;
+ struct GNUNET_HashCode h_denom_pub;
wsh = GNUNET_new (struct TALER_EXCHANGE_ReserveWithdrawHandle);
wsh->exchange = exchange;
@@ -1009,9 +1011,11 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange,
wsh->pk = pk;
wsh->reserve_pub = *reserve_pub;
wsh->c_hash = pd->c_hash;
- withdraw_obj = json_pack ("{s:o, s:o," /* denom_pub and coin_ev */
+ GNUNET_CRYPTO_rsa_public_key_hash (pk->key.rsa_public_key,
+ &h_denom_pub);
+ withdraw_obj = json_pack ("{s:o, s:o," /* denom_pub_hash and coin_ev */
" s:o, s:o}",/* reserve_pub and reserve_sig */
- "denom_pub", GNUNET_JSON_from_rsa_public_key (pk->key.rsa_public_key),
+ "denom_pub_hash", GNUNET_JSON_from_data_auto (&h_denom_pub),
"coin_ev", GNUNET_JSON_from_data (pd->coin_ev,
pd->coin_ev_size),
"reserve_pub", GNUNET_JSON_from_data_auto (reserve_pub),
@@ -1019,25 +1023,26 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange,
if (NULL == withdraw_obj)
{
GNUNET_break (0);
+ GNUNET_free (wsh);
return NULL;
}
wsh->ps = *ps;
wsh->url = TEAH_path_to_url (exchange, "/reserve/withdraw");
-
eh = TEL_curl_easy_get (wsh->url);
- GNUNET_assert (NULL != (wsh->json_enc =
- json_dumps (withdraw_obj,
- JSON_COMPACT)));
+ if (GNUNET_OK !=
+ TEAH_curl_easy_post (&wsh->ctx,
+ eh,
+ withdraw_obj))
+ {
+ GNUNET_break (0);
+ curl_easy_cleanup (eh);
+ json_decref (withdraw_obj);
+ GNUNET_free (wsh->url);
+ GNUNET_free (wsh);
+ return NULL;
+ }
json_decref (withdraw_obj);
- GNUNET_assert (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_POSTFIELDS,
- wsh->json_enc));
- GNUNET_assert (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_POSTFIELDSIZE,
- strlen (wsh->json_enc)));
ctx = TEAH_handle_to_context (exchange);
wsh->job = GNUNET_CURL_job_add (ctx,
eh,
@@ -1196,7 +1201,7 @@ TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHan
sign->job = NULL;
}
GNUNET_free (sign->url);
- GNUNET_free (sign->json_enc);
+ TEAH_curl_easy_post_finished (&sign->ctx);
GNUNET_free (sign);
}