diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-02-26 22:24:22 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-02-26 22:24:22 +0100 |
commit | 582ce77d933d72cf7892337a3baf0015e39b2bb3 (patch) | |
tree | 42fbf330c672f57324eb69038a8f55dde86211ce | |
parent | fb9324338d9580b520b3713bf973bfcd9c49b569 (diff) |
updating libtalerexchange to new REST API (#6067)
-rw-r--r-- | src/lib/exchange_api_deposit.c | 24 | ||||
-rw-r--r-- | src/lib/exchange_api_recoup.c | 24 | ||||
-rw-r--r-- | src/lib/exchange_api_refresh.c | 42 | ||||
-rw-r--r-- | src/lib/exchange_api_refresh_link.c | 34 | ||||
-rw-r--r-- | src/lib/exchange_api_refund.c | 24 | ||||
-rw-r--r-- | src/lib/exchange_api_reserve.c | 57 | ||||
-rw-r--r-- | src/lib/exchange_api_track_transaction.c | 95 | ||||
-rw-r--r-- | src/lib/exchange_api_track_transfer.c | 29 |
8 files changed, 229 insertions, 100 deletions
diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c index 20a87c331..06eeb6a2f 100644 --- a/src/lib/exchange_api_deposit.c +++ b/src/lib/exchange_api_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015, 2018, 2019 Taler Systems SA + Copyright (C) 2014-2020 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 @@ -513,7 +513,23 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_HashCode h_wire; struct GNUNET_HashCode denom_pub_hash; struct TALER_Amount amount_without_fee; + char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32]; + { + char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; + char *end; + + end = GNUNET_STRINGS_data_to_string (coin_pub, + sizeof (struct + TALER_CoinSpendPublicKeyP), + pub_str, + sizeof (pub_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/coins/%s/deposit", + pub_str); + } (void) GNUNET_TIME_round_abs (&wire_deadline); (void) GNUNET_TIME_round_abs (&refund_deadline); GNUNET_assert (refund_deadline.abs_value_us <= wire_deadline.abs_value_us); @@ -557,7 +573,7 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, deposit_obj = json_pack ("{s:o, s:O," /* f/wire */ " s:o, s:o," /* h_wire, h_contract_terms */ - " s:o, s:o," /* coin_pub, denom_pub */ + " s:o," /* denom_pub */ " s:o, s:o," /* ub_sig, timestamp */ " s:o," /* merchant_pub */ " s:o, s:o," /* refund_deadline, wire_deadline */ @@ -567,7 +583,6 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, "h_wire", GNUNET_JSON_from_data_auto (&h_wire), "h_contract_terms", GNUNET_JSON_from_data_auto ( h_contract_terms), - "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), "denom_pub_hash", GNUNET_JSON_from_data_auto ( &denom_pub_hash), "ub_sig", GNUNET_JSON_from_rsa_signature ( @@ -592,7 +607,8 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, dh->exchange = exchange; dh->cb = cb; dh->cb_cls = cb_cls; - dh->url = TEAH_path_to_url (exchange, "/deposit"); + dh->url = TEAH_path_to_url (exchange, + arg_str); dh->depconf.purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS)); dh->depconf.purpose.purpose = htonl ( diff --git a/src/lib/exchange_api_recoup.c b/src/lib/exchange_api_recoup.c index 1a332ad32..a31d5b40a 100644 --- a/src/lib/exchange_api_recoup.c +++ b/src/lib/exchange_api_recoup.c @@ -328,6 +328,7 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_HashCode h_denom_pub; json_t *recoup_obj; CURL *eh; + char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32]; GNUNET_assert (GNUNET_YES == TEAH_handle_is_ready (exchange)); @@ -345,14 +346,12 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, &coin_sig.eddsa_signature)); recoup_obj = json_pack ("{s:o, s:o," /* denom pub/sig */ - " s:o, s:o," /* coin pub/sig */ + " s:o," /* sig */ " s:o, s:o}", /* coin_bks */ "denom_pub_hash", GNUNET_JSON_from_data_auto ( &h_denom_pub), "denom_sig", GNUNET_JSON_from_rsa_signature ( denom_sig->rsa_signature), - "coin_pub", GNUNET_JSON_from_data_auto ( - &pr.coin_pub), "coin_sig", GNUNET_JSON_from_data_auto (&coin_sig), "coin_blind_key_secret", GNUNET_JSON_from_data_auto ( &ps->blinding_key), @@ -364,6 +363,22 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, return NULL; } + { + char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; + char *end; + + end = GNUNET_STRINGS_data_to_string (&pr.coin_pub, + sizeof (struct + TALER_CoinSpendPublicKeyP), + pub_str, + sizeof (pub_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/coins/%s/recoup", + pub_str); + } + ph = GNUNET_new (struct TALER_EXCHANGE_RecoupHandle); ph->coin_pub = pr.coin_pub; ph->exchange = exchange; @@ -371,7 +386,8 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, ph->pk.key.rsa_public_key = NULL; /* zero out, as lifetime cannot be warranted */ ph->cb = recoup_cb; ph->cb_cls = recoup_cb_cls; - ph->url = TEAH_path_to_url (exchange, "/recoup"); + ph->url = TEAH_path_to_url (exchange, + arg_str); ph->was_refreshed = was_refreshed; eh = TEL_curl_easy_get (ph->url); if (GNUNET_OK != diff --git a/src/lib/exchange_api_refresh.c b/src/lib/exchange_api_refresh.c index e097ee3f8..7a1304c19 100644 --- a/src/lib/exchange_api_refresh.c +++ b/src/lib/exchange_api_refresh.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015, 2016, 2017, 2019 Taler Systems SA + Copyright (C) 2015-2020 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 @@ -1165,6 +1165,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, struct TALER_CoinSpendSignatureP confirm_sig; struct TALER_RefreshMeltCoinAffirmationPS melt; struct GNUNET_HashCode h_denom_pub; + char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32]; GNUNET_assert (GNUNET_YES == TEAH_handle_is_ready (exchange)); @@ -1175,7 +1176,6 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, GNUNET_break (0); return NULL; } - melt.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); melt.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); @@ -1212,6 +1212,22 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, free_melt_data (md); return NULL; } + { + char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; + char *end; + + end = GNUNET_STRINGS_data_to_string (&melt.coin_pub, + sizeof (struct + TALER_CoinSpendPublicKeyP), + pub_str, + sizeof (pub_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/coins/%s/melt", + pub_str); + } + key_state = TALER_EXCHANGE_get_keys (exchange); dki = TALER_EXCHANGE_get_denomination_key (key_state, &md->melted_coin.pub_key); @@ -1226,7 +1242,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, rmh->melt_cb_cls = melt_cb_cls; rmh->md = md; rmh->url = TEAH_path_to_url (exchange, - "/refresh/melt"); + arg_str); eh = TEL_curl_easy_get (rmh->url); if (GNUNET_OK != TALER_curl_easy_post (&rmh->ctx, @@ -1555,6 +1571,7 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_CURL_Context *ctx; struct MeltData *md; struct TALER_TransferPublicKeyP transfer_pub; + char arg_str[sizeof (struct TALER_RefreshCommitmentP) * 2 + 32]; if (noreveal_index >= TALER_CNC_KAPPA) { @@ -1661,9 +1678,7 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, } /* build main JSON request */ - reveal_obj = json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o}", - "rc", - GNUNET_JSON_from_data_auto (&md->rc), + reveal_obj = json_pack ("{s:o, s:o, s:o, s:o, s:o}", "transfer_pub", GNUNET_JSON_from_data_auto (&transfer_pub), "transfer_privs", @@ -1680,6 +1695,21 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, return NULL; } + { + char pub_str[sizeof (struct TALER_RefreshCommitmentP) * 2]; + char *end; + + end = GNUNET_STRINGS_data_to_string (&md->rc, + sizeof (struct + TALER_RefreshCommitmentP), + pub_str, + sizeof (pub_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/refreshes/%s/reveal", + pub_str); + } /* finally, we can actually issue the request */ rrh = GNUNET_new (struct TALER_EXCHANGE_RefreshRevealHandle); rrh->exchange = exchange; diff --git a/src/lib/exchange_api_refresh_link.c b/src/lib/exchange_api_refresh_link.c index 6a747d1b6..4b4b38ba1 100644 --- a/src/lib/exchange_api_refresh_link.c +++ b/src/lib/exchange_api_refresh_link.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015, 2016, 2019 Taler Systems SA + Copyright (C) 2015-2020 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 @@ -423,8 +423,7 @@ TALER_EXCHANGE_refresh_link (struct TALER_EXCHANGE_Handle *exchange, CURL *eh; struct GNUNET_CURL_Context *ctx; struct TALER_CoinSpendPublicKeyP coin_pub; - char *pub_str; - char *arg_str; + char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32]; if (GNUNET_YES != TEAH_handle_is_ready (exchange)) @@ -435,23 +434,28 @@ TALER_EXCHANGE_refresh_link (struct TALER_EXCHANGE_Handle *exchange, GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, &coin_pub.eddsa_pub); - pub_str = GNUNET_STRINGS_data_to_string_alloc (&coin_pub, - sizeof (struct - TALER_CoinSpendPublicKeyP)); - GNUNET_asprintf (&arg_str, - "/refresh/link?coin_pub=%s", - pub_str); - GNUNET_free (pub_str); - + { + char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; + char *end; + + end = GNUNET_STRINGS_data_to_string (&coin_pub, + sizeof (struct + TALER_CoinSpendPublicKeyP), + pub_str, + sizeof (pub_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/coins/%s/link", + pub_str); + } rlh = GNUNET_new (struct TALER_EXCHANGE_RefreshLinkHandle); rlh->exchange = exchange; rlh->link_cb = link_cb; rlh->link_cb_cls = link_cb_cls; rlh->coin_priv = *coin_priv; - rlh->url = TEAH_path_to_url (exchange, arg_str); - GNUNET_free (arg_str); - - + rlh->url = TEAH_path_to_url (exchange, + arg_str); eh = TEL_curl_easy_get (rlh->url); ctx = TEAH_handle_to_context (exchange); rlh->job = GNUNET_CURL_job_add (ctx, diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index ef9a43596..8f2c0c4dc 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015, 2016 Taler Systems SA + Copyright (C) 2014-2020 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 @@ -333,16 +333,31 @@ TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_CURL_Context *ctx; json_t *refund_obj; CURL *eh; + char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32]; + { + char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; + char *end; + + end = GNUNET_STRINGS_data_to_string (coin_pub, + sizeof (struct + TALER_CoinSpendPublicKeyP), + pub_str, + sizeof (pub_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/coins/%s/refund", + pub_str); + } refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ - " s:o, s:o," /* h_contract_terms, coin_pub */ + " s:o," /* h_contract_terms */ " s:I," /* rtransaction id */ " s:o, s:o}", /* merchant_pub, merchant_sig */ "refund_amount", TALER_JSON_from_amount (amount), "refund_fee", TALER_JSON_from_amount (refund_fee), "h_contract_terms", GNUNET_JSON_from_data_auto ( h_contract_terms), - "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), "rtransaction_id", (json_int_t) rtransaction_id, "merchant_pub", GNUNET_JSON_from_data_auto ( merchant_pub), @@ -359,7 +374,8 @@ TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, rh->exchange = exchange; rh->cb = cb; rh->cb_cls = cb_cls; - rh->url = TEAH_path_to_url (exchange, "/refund"); + rh->url = TEAH_path_to_url (exchange, + arg_str); rh->depconf.purpose.size = htonl (sizeof (struct TALER_RefundConfirmationPS)); rh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND); rh->depconf.h_contract_terms = *h_contract_terms; diff --git a/src/lib/exchange_api_reserve.c b/src/lib/exchange_api_reserve.c index 710cd5880..7fa3f308a 100644 --- a/src/lib/exchange_api_reserve.c +++ b/src/lib/exchange_api_reserve.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 Taler Systems SA + Copyright (C) 2014-2020 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 @@ -659,8 +659,7 @@ TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, struct TALER_EXCHANGE_ReserveStatusHandle *rsh; struct GNUNET_CURL_Context *ctx; CURL *eh; - char *pub_str; - char *arg_str; + char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 16]; if (GNUNET_YES != TEAH_handle_is_ready (exchange)) @@ -668,13 +667,21 @@ TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, GNUNET_break (0); return NULL; } - pub_str = GNUNET_STRINGS_data_to_string_alloc (reserve_pub, - sizeof (struct - TALER_ReservePublicKeyP)); - GNUNET_asprintf (&arg_str, - "/reserve/status?reserve_pub=%s", - pub_str); - GNUNET_free (pub_str); + { + char pub_str[sizeof (struct TALER_ReservePublicKeyP) * 2]; + char *end; + + end = GNUNET_STRINGS_data_to_string (reserve_pub, + sizeof (struct + TALER_ReservePublicKeyP), + pub_str, + sizeof (pub_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/reserves/%s", + pub_str); + } rsh = GNUNET_new (struct TALER_EXCHANGE_ReserveStatusHandle); rsh->exchange = exchange; rsh->cb = cb; @@ -682,8 +689,6 @@ TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, rsh->reserve_pub = *reserve_pub; rsh->url = TEAH_path_to_url (exchange, arg_str); - GNUNET_free (arg_str); - eh = TEL_curl_easy_get (rsh->url); ctx = TEAH_handle_to_context (exchange); rsh->job = GNUNET_CURL_job_add (ctx, @@ -1063,26 +1068,40 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange, json_t *withdraw_obj; CURL *eh; struct GNUNET_HashCode h_denom_pub; + char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; + { + char pub_str[sizeof (struct TALER_ReservePublicKeyP) * 2]; + char *end; + + end = GNUNET_STRINGS_data_to_string (reserve_pub, + sizeof (struct + TALER_ReservePublicKeyP), + pub_str, + sizeof (pub_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/reserves/%s/withdraw", + pub_str); + } wsh = GNUNET_new (struct TALER_EXCHANGE_ReserveWithdrawHandle); wsh->exchange = exchange; wsh->cb = res_cb; wsh->cb_cls = res_cb_cls; wsh->pk = *pk; - wsh->pk.key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup ( - pk->key.rsa_public_key); + wsh->pk.key.rsa_public_key + = GNUNET_CRYPTO_rsa_public_key_dup (pk->key.rsa_public_key); wsh->reserve_pub = *reserve_pub; wsh->c_hash = pd->c_hash; 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 */ + " s:o}",/* reserve_pub and reserve_sig */ "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), "reserve_sig", GNUNET_JSON_from_data_auto ( reserve_sig)); if (NULL == withdraw_obj) @@ -1095,9 +1114,9 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Attempting to withdraw from reserve %s\n", TALER_B2S (reserve_pub)); - wsh->ps = *ps; - wsh->url = TEAH_path_to_url (exchange, "/reserve/withdraw"); + wsh->url = TEAH_path_to_url (exchange, + arg_str); eh = TEL_curl_easy_get (wsh->url); if (GNUNET_OK != TALER_curl_easy_post (&wsh->ctx, diff --git a/src/lib/exchange_api_track_transaction.c b/src/lib/exchange_api_track_transaction.c index adf9373b2..503ceea5b 100644 --- a/src/lib/exchange_api_track_transaction.c +++ b/src/lib/exchange_api_track_transaction.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015, 2016 Taler Systems SA + Copyright (C) 2014-2020 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 @@ -280,8 +280,12 @@ TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange, struct TALER_MerchantSignatureP merchant_sig; struct TALER_EXCHANGE_TrackTransactionHandle *dwh; struct GNUNET_CURL_Context *ctx; - json_t *deposit_wtid_obj; CURL *eh; + char arg_str[(sizeof (struct TALER_CoinSpendPublicKeyP) + + sizeof (struct GNUNET_HashCode) + + sizeof (struct TALER_MerchantPublicKeyP) + + sizeof (struct GNUNET_HashCode) + + sizeof (struct TALER_MerchantSignatureP)) * 2 + 48]; if (GNUNET_YES != TEAH_handle_is_ready (exchange)) @@ -301,29 +305,61 @@ TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange, GNUNET_CRYPTO_eddsa_sign (&merchant_priv->eddsa_priv, &dtp.purpose, &merchant_sig.eddsa_sig)); - deposit_wtid_obj = json_pack ("{s:o, s:o," /* h_wire, h_contract_terms */ - " s:o," /* coin_pub */ - " s:o, s:o}", /* merchant_pub, merchant_sig */ - "h_wire", GNUNET_JSON_from_data_auto (h_wire), - "h_contract_terms", GNUNET_JSON_from_data_auto ( - h_contract_terms), - "coin_pub", GNUNET_JSON_from_data_auto ( - coin_pub), - "merchant_pub", GNUNET_JSON_from_data_auto ( - &dtp.merchant), - "merchant_sig", GNUNET_JSON_from_data_auto ( - &merchant_sig)); - if (NULL == deposit_wtid_obj) { - GNUNET_break (0); - return NULL; + char cpub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; + char mpub_str[sizeof (struct TALER_MerchantPublicKeyP) * 2]; + char msig_str[sizeof (struct TALER_MerchantSignatureP) * 2]; + char chash_str[sizeof (struct GNUNET_HashCode) * 2]; + char whash_str[sizeof (struct GNUNET_HashCode) * 2]; + char *end; + + end = GNUNET_STRINGS_data_to_string (h_wire, + sizeof (struct + GNUNET_HashCode), + whash_str, + sizeof (whash_str)); + *end = '\0'; + end = GNUNET_STRINGS_data_to_string (&dtp.merchant, + sizeof (struct + TALER_MerchantPublicKeyP), + mpub_str, + sizeof (mpub_str)); + *end = '\0'; + end = GNUNET_STRINGS_data_to_string (h_contract_terms, + sizeof (struct + GNUNET_HashCode), + chash_str, + sizeof (chash_str)); + *end = '\0'; + end = GNUNET_STRINGS_data_to_string (coin_pub, + sizeof (struct + TALER_CoinSpendPublicKeyP), + cpub_str, + sizeof (cpub_str)); + *end = '\0'; + end = GNUNET_STRINGS_data_to_string (&merchant_sig, + sizeof (struct + TALER_MerchantSignatureP), + msig_str, + sizeof (msig_str)); + *end = '\0'; + + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/deposits/%s/%s/%s/%s?merchant_sig=%s", + whash_str, + mpub_str, + chash_str, + cpub_str, + msig_str); } dwh = GNUNET_new (struct TALER_EXCHANGE_TrackTransactionHandle); dwh->exchange = exchange; dwh->cb = cb; dwh->cb_cls = cb_cls; - dwh->url = TEAH_path_to_url (exchange, "/track/transaction"); + dwh->url = TEAH_path_to_url (exchange, + arg_str); dwh->depconf.purpose.size = htonl (sizeof (struct TALER_ConfirmWirePS)); dwh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE); dwh->depconf.h_wire = *h_wire; @@ -331,25 +367,12 @@ TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange, dwh->depconf.coin_pub = *coin_pub; eh = TEL_curl_easy_get (dwh->url); - if (GNUNET_OK != - TALER_curl_easy_post (&dwh->ctx, - eh, - deposit_wtid_obj)) - { - GNUNET_break (0); - curl_easy_cleanup (eh); - json_decref (deposit_wtid_obj); - GNUNET_free (dwh->url); - GNUNET_free (dwh); - return NULL; - } - json_decref (deposit_wtid_obj); ctx = TEAH_handle_to_context (exchange); - dwh->job = GNUNET_CURL_job_add2 (ctx, - eh, - dwh->ctx.headers, - &handle_deposit_wtid_finished, - dwh); + dwh->job = GNUNET_CURL_job_add (ctx, + eh, + GNUNET_NO, + &handle_deposit_wtid_finished, + dwh); return dwh; } diff --git a/src/lib/exchange_api_track_transfer.c b/src/lib/exchange_api_track_transfer.c index ba8948fe2..2fdfdde16 100644 --- a/src/lib/exchange_api_track_transfer.c +++ b/src/lib/exchange_api_track_transfer.c @@ -334,9 +334,8 @@ TALER_EXCHANGE_track_transfer (struct TALER_EXCHANGE_Handle *exchange, { struct TALER_EXCHANGE_TrackTransferHandle *wdh; struct GNUNET_CURL_Context *ctx; - char *buf; - char *path; CURL *eh; + char arg_str[sizeof (struct TALER_WireTransferIdentifierRawP) * 2 + 32]; if (GNUNET_YES != TEAH_handle_is_ready (exchange)) @@ -350,17 +349,23 @@ TALER_EXCHANGE_track_transfer (struct TALER_EXCHANGE_Handle *exchange, wdh->cb = cb; wdh->cb_cls = cb_cls; - buf = GNUNET_STRINGS_data_to_string_alloc (wtid, - sizeof (struct - TALER_WireTransferIdentifierRawP)); - GNUNET_asprintf (&path, - "/track/transfer?wtid=%s", - buf); - wdh->url = TEAH_path_to_url (wdh->exchange, - path); - GNUNET_free (buf); - GNUNET_free (path); + { + char wtid_str[sizeof (struct TALER_WireTransferIdentifierRawP) * 2]; + char *end; + end = GNUNET_STRINGS_data_to_string (wtid, + sizeof (struct + TALER_WireTransferIdentifierRawP), + wtid_str, + sizeof (wtid_str)); + *end = '\0'; + GNUNET_snprintf (arg_str, + sizeof (arg_str), + "/transfers/%s", + wtid_str); + } + wdh->url = TEAH_path_to_url (wdh->exchange, + arg_str); eh = TEL_curl_easy_get (wdh->url); ctx = TEAH_handle_to_context (exchange); wdh->job = GNUNET_CURL_job_add (ctx, |