updating libtalerexchange to new REST API (#6067)

This commit is contained in:
Christian Grothoff 2020-02-26 22:24:22 +01:00
parent fb9324338d
commit 582ce77d93
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
8 changed files with 228 additions and 99 deletions

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 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 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 h_wire;
struct GNUNET_HashCode denom_pub_hash; struct GNUNET_HashCode denom_pub_hash;
struct TALER_Amount amount_without_fee; 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 (&wire_deadline);
(void) GNUNET_TIME_round_abs (&refund_deadline); (void) GNUNET_TIME_round_abs (&refund_deadline);
GNUNET_assert (refund_deadline.abs_value_us <= wire_deadline.abs_value_us); 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 */ deposit_obj = json_pack ("{s:o, s:O," /* f/wire */
" s:o, s:o," /* h_wire, h_contract_terms */ " 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, s:o," /* ub_sig, timestamp */
" s:o," /* merchant_pub */ " s:o," /* merchant_pub */
" s:o, s:o," /* refund_deadline, wire_deadline */ " 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_wire", GNUNET_JSON_from_data_auto (&h_wire),
"h_contract_terms", GNUNET_JSON_from_data_auto ( "h_contract_terms", GNUNET_JSON_from_data_auto (
h_contract_terms), h_contract_terms),
"coin_pub", GNUNET_JSON_from_data_auto (coin_pub),
"denom_pub_hash", GNUNET_JSON_from_data_auto ( "denom_pub_hash", GNUNET_JSON_from_data_auto (
&denom_pub_hash), &denom_pub_hash),
"ub_sig", GNUNET_JSON_from_rsa_signature ( "ub_sig", GNUNET_JSON_from_rsa_signature (
@ -592,7 +607,8 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,
dh->exchange = exchange; dh->exchange = exchange;
dh->cb = cb; dh->cb = cb;
dh->cb_cls = cb_cls; 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 dh->depconf.purpose.size = htonl (sizeof (struct
TALER_DepositConfirmationPS)); TALER_DepositConfirmationPS));
dh->depconf.purpose.purpose = htonl ( dh->depconf.purpose.purpose = htonl (

View File

@ -328,6 +328,7 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange,
struct GNUNET_HashCode h_denom_pub; struct GNUNET_HashCode h_denom_pub;
json_t *recoup_obj; json_t *recoup_obj;
CURL *eh; CURL *eh;
char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32];
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
TEAH_handle_is_ready (exchange)); TEAH_handle_is_ready (exchange));
@ -345,14 +346,12 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange,
&coin_sig.eddsa_signature)); &coin_sig.eddsa_signature));
recoup_obj = json_pack ("{s:o, s:o," /* denom pub/sig */ 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 */ " s:o, s:o}", /* coin_bks */
"denom_pub_hash", GNUNET_JSON_from_data_auto ( "denom_pub_hash", GNUNET_JSON_from_data_auto (
&h_denom_pub), &h_denom_pub),
"denom_sig", GNUNET_JSON_from_rsa_signature ( "denom_sig", GNUNET_JSON_from_rsa_signature (
denom_sig->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_sig", GNUNET_JSON_from_data_auto (&coin_sig),
"coin_blind_key_secret", GNUNET_JSON_from_data_auto ( "coin_blind_key_secret", GNUNET_JSON_from_data_auto (
&ps->blinding_key), &ps->blinding_key),
@ -364,6 +363,22 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange,
return NULL; 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 = GNUNET_new (struct TALER_EXCHANGE_RecoupHandle);
ph->coin_pub = pr.coin_pub; ph->coin_pub = pr.coin_pub;
ph->exchange = exchange; 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->pk.key.rsa_public_key = NULL; /* zero out, as lifetime cannot be warranted */
ph->cb = recoup_cb; ph->cb = recoup_cb;
ph->cb_cls = recoup_cb_cls; 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; ph->was_refreshed = was_refreshed;
eh = TEL_curl_easy_get (ph->url); eh = TEL_curl_easy_get (ph->url);
if (GNUNET_OK != if (GNUNET_OK !=

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 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 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_CoinSpendSignatureP confirm_sig;
struct TALER_RefreshMeltCoinAffirmationPS melt; struct TALER_RefreshMeltCoinAffirmationPS melt;
struct GNUNET_HashCode h_denom_pub; struct GNUNET_HashCode h_denom_pub;
char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32];
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
TEAH_handle_is_ready (exchange)); TEAH_handle_is_ready (exchange));
@ -1175,7 +1176,6 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_break (0); GNUNET_break (0);
return NULL; return NULL;
} }
melt.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); melt.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT);
melt.purpose.size = htonl (sizeof (struct melt.purpose.size = htonl (sizeof (struct
TALER_RefreshMeltCoinAffirmationPS)); TALER_RefreshMeltCoinAffirmationPS));
@ -1212,6 +1212,22 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
free_melt_data (md); free_melt_data (md);
return NULL; 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); key_state = TALER_EXCHANGE_get_keys (exchange);
dki = TALER_EXCHANGE_get_denomination_key (key_state, dki = TALER_EXCHANGE_get_denomination_key (key_state,
&md->melted_coin.pub_key); &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->melt_cb_cls = melt_cb_cls;
rmh->md = md; rmh->md = md;
rmh->url = TEAH_path_to_url (exchange, rmh->url = TEAH_path_to_url (exchange,
"/refresh/melt"); arg_str);
eh = TEL_curl_easy_get (rmh->url); eh = TEL_curl_easy_get (rmh->url);
if (GNUNET_OK != if (GNUNET_OK !=
TALER_curl_easy_post (&rmh->ctx, 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 GNUNET_CURL_Context *ctx;
struct MeltData *md; struct MeltData *md;
struct TALER_TransferPublicKeyP transfer_pub; struct TALER_TransferPublicKeyP transfer_pub;
char arg_str[sizeof (struct TALER_RefreshCommitmentP) * 2 + 32];
if (noreveal_index >= TALER_CNC_KAPPA) if (noreveal_index >= TALER_CNC_KAPPA)
{ {
@ -1661,9 +1678,7 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange,
} }
/* build main JSON request */ /* build main JSON request */
reveal_obj = json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o}", reveal_obj = json_pack ("{s:o, s:o, s:o, s:o, s:o}",
"rc",
GNUNET_JSON_from_data_auto (&md->rc),
"transfer_pub", "transfer_pub",
GNUNET_JSON_from_data_auto (&transfer_pub), GNUNET_JSON_from_data_auto (&transfer_pub),
"transfer_privs", "transfer_privs",
@ -1680,6 +1695,21 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange,
return NULL; 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 */ /* finally, we can actually issue the request */
rrh = GNUNET_new (struct TALER_EXCHANGE_RefreshRevealHandle); rrh = GNUNET_new (struct TALER_EXCHANGE_RefreshRevealHandle);
rrh->exchange = exchange; rrh->exchange = exchange;

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 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 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; CURL *eh;
struct GNUNET_CURL_Context *ctx; struct GNUNET_CURL_Context *ctx;
struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_CoinSpendPublicKeyP coin_pub;
char *pub_str; char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32];
char *arg_str;
if (GNUNET_YES != if (GNUNET_YES !=
TEAH_handle_is_ready (exchange)) 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, GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
&coin_pub.eddsa_pub); &coin_pub.eddsa_pub);
pub_str = GNUNET_STRINGS_data_to_string_alloc (&coin_pub, {
sizeof (struct char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2];
TALER_CoinSpendPublicKeyP)); char *end;
GNUNET_asprintf (&arg_str,
"/refresh/link?coin_pub=%s",
pub_str);
GNUNET_free (pub_str);
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 = GNUNET_new (struct TALER_EXCHANGE_RefreshLinkHandle);
rlh->exchange = exchange; rlh->exchange = exchange;
rlh->link_cb = link_cb; rlh->link_cb = link_cb;
rlh->link_cb_cls = link_cb_cls; rlh->link_cb_cls = link_cb_cls;
rlh->coin_priv = *coin_priv; rlh->coin_priv = *coin_priv;
rlh->url = TEAH_path_to_url (exchange, arg_str); rlh->url = TEAH_path_to_url (exchange,
GNUNET_free (arg_str); arg_str);
eh = TEL_curl_easy_get (rlh->url); eh = TEL_curl_easy_get (rlh->url);
ctx = TEAH_handle_to_context (exchange); ctx = TEAH_handle_to_context (exchange);
rlh->job = GNUNET_CURL_job_add (ctx, rlh->job = GNUNET_CURL_job_add (ctx,

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 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 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; struct GNUNET_CURL_Context *ctx;
json_t *refund_obj; json_t *refund_obj;
CURL *eh; 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 */ 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:I," /* rtransaction id */
" s:o, s:o}", /* merchant_pub, merchant_sig */ " s:o, s:o}", /* merchant_pub, merchant_sig */
"refund_amount", TALER_JSON_from_amount (amount), "refund_amount", TALER_JSON_from_amount (amount),
"refund_fee", TALER_JSON_from_amount (refund_fee), "refund_fee", TALER_JSON_from_amount (refund_fee),
"h_contract_terms", GNUNET_JSON_from_data_auto ( "h_contract_terms", GNUNET_JSON_from_data_auto (
h_contract_terms), h_contract_terms),
"coin_pub", GNUNET_JSON_from_data_auto (coin_pub),
"rtransaction_id", (json_int_t) rtransaction_id, "rtransaction_id", (json_int_t) rtransaction_id,
"merchant_pub", GNUNET_JSON_from_data_auto ( "merchant_pub", GNUNET_JSON_from_data_auto (
merchant_pub), merchant_pub),
@ -359,7 +374,8 @@ TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
rh->exchange = exchange; rh->exchange = exchange;
rh->cb = cb; rh->cb = cb;
rh->cb_cls = cb_cls; 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.size = htonl (sizeof (struct TALER_RefundConfirmationPS));
rh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND); rh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND);
rh->depconf.h_contract_terms = *h_contract_terms; rh->depconf.h_contract_terms = *h_contract_terms;

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 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 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 TALER_EXCHANGE_ReserveStatusHandle *rsh;
struct GNUNET_CURL_Context *ctx; struct GNUNET_CURL_Context *ctx;
CURL *eh; CURL *eh;
char *pub_str; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 16];
char *arg_str;
if (GNUNET_YES != if (GNUNET_YES !=
TEAH_handle_is_ready (exchange)) TEAH_handle_is_ready (exchange))
@ -668,13 +667,21 @@ TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_break (0); GNUNET_break (0);
return NULL; return NULL;
} }
pub_str = GNUNET_STRINGS_data_to_string_alloc (reserve_pub, {
char pub_str[sizeof (struct TALER_ReservePublicKeyP) * 2];
char *end;
end = GNUNET_STRINGS_data_to_string (reserve_pub,
sizeof (struct sizeof (struct
TALER_ReservePublicKeyP)); TALER_ReservePublicKeyP),
GNUNET_asprintf (&arg_str, pub_str,
"/reserve/status?reserve_pub=%s", sizeof (pub_str));
*end = '\0';
GNUNET_snprintf (arg_str,
sizeof (arg_str),
"/reserves/%s",
pub_str); pub_str);
GNUNET_free (pub_str); }
rsh = GNUNET_new (struct TALER_EXCHANGE_ReserveStatusHandle); rsh = GNUNET_new (struct TALER_EXCHANGE_ReserveStatusHandle);
rsh->exchange = exchange; rsh->exchange = exchange;
rsh->cb = cb; rsh->cb = cb;
@ -682,8 +689,6 @@ TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange,
rsh->reserve_pub = *reserve_pub; rsh->reserve_pub = *reserve_pub;
rsh->url = TEAH_path_to_url (exchange, rsh->url = TEAH_path_to_url (exchange,
arg_str); arg_str);
GNUNET_free (arg_str);
eh = TEL_curl_easy_get (rsh->url); eh = TEL_curl_easy_get (rsh->url);
ctx = TEAH_handle_to_context (exchange); ctx = TEAH_handle_to_context (exchange);
rsh->job = GNUNET_CURL_job_add (ctx, rsh->job = GNUNET_CURL_job_add (ctx,
@ -1063,26 +1068,40 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange,
json_t *withdraw_obj; json_t *withdraw_obj;
CURL *eh; CURL *eh;
struct GNUNET_HashCode h_denom_pub; 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 = GNUNET_new (struct TALER_EXCHANGE_ReserveWithdrawHandle);
wsh->exchange = exchange; wsh->exchange = exchange;
wsh->cb = res_cb; wsh->cb = res_cb;
wsh->cb_cls = res_cb_cls; wsh->cb_cls = res_cb_cls;
wsh->pk = *pk; wsh->pk = *pk;
wsh->pk.key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup ( wsh->pk.key.rsa_public_key
pk->key.rsa_public_key); = GNUNET_CRYPTO_rsa_public_key_dup (pk->key.rsa_public_key);
wsh->reserve_pub = *reserve_pub; wsh->reserve_pub = *reserve_pub;
wsh->c_hash = pd->c_hash; wsh->c_hash = pd->c_hash;
GNUNET_CRYPTO_rsa_public_key_hash (pk->key.rsa_public_key, GNUNET_CRYPTO_rsa_public_key_hash (pk->key.rsa_public_key,
&h_denom_pub); &h_denom_pub);
withdraw_obj = json_pack ("{s:o, s:o," /* denom_pub_hash and coin_ev */ 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 ( "denom_pub_hash", GNUNET_JSON_from_data_auto (
&h_denom_pub), &h_denom_pub),
"coin_ev", GNUNET_JSON_from_data (pd->coin_ev, "coin_ev", GNUNET_JSON_from_data (pd->coin_ev,
pd->coin_ev_size), pd->coin_ev_size),
"reserve_pub", GNUNET_JSON_from_data_auto (
reserve_pub),
"reserve_sig", GNUNET_JSON_from_data_auto ( "reserve_sig", GNUNET_JSON_from_data_auto (
reserve_sig)); reserve_sig));
if (NULL == withdraw_obj) if (NULL == withdraw_obj)
@ -1095,9 +1114,9 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Attempting to withdraw from reserve %s\n", "Attempting to withdraw from reserve %s\n",
TALER_B2S (reserve_pub)); TALER_B2S (reserve_pub));
wsh->ps = *ps; 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); eh = TEL_curl_easy_get (wsh->url);
if (GNUNET_OK != if (GNUNET_OK !=
TALER_curl_easy_post (&wsh->ctx, TALER_curl_easy_post (&wsh->ctx,

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 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 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_MerchantSignatureP merchant_sig;
struct TALER_EXCHANGE_TrackTransactionHandle *dwh; struct TALER_EXCHANGE_TrackTransactionHandle *dwh;
struct GNUNET_CURL_Context *ctx; struct GNUNET_CURL_Context *ctx;
json_t *deposit_wtid_obj;
CURL *eh; 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 != if (GNUNET_YES !=
TEAH_handle_is_ready (exchange)) 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, GNUNET_CRYPTO_eddsa_sign (&merchant_priv->eddsa_priv,
&dtp.purpose, &dtp.purpose,
&merchant_sig.eddsa_sig)); &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); char cpub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2];
return NULL; 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 = GNUNET_new (struct TALER_EXCHANGE_TrackTransactionHandle);
dwh->exchange = exchange; dwh->exchange = exchange;
dwh->cb = cb; dwh->cb = cb;
dwh->cb_cls = cb_cls; 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.size = htonl (sizeof (struct TALER_ConfirmWirePS));
dwh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE); dwh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE);
dwh->depconf.h_wire = *h_wire; dwh->depconf.h_wire = *h_wire;
@ -331,23 +367,10 @@ TALER_EXCHANGE_track_transaction (struct TALER_EXCHANGE_Handle *exchange,
dwh->depconf.coin_pub = *coin_pub; dwh->depconf.coin_pub = *coin_pub;
eh = TEL_curl_easy_get (dwh->url); 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); ctx = TEAH_handle_to_context (exchange);
dwh->job = GNUNET_CURL_job_add2 (ctx, dwh->job = GNUNET_CURL_job_add (ctx,
eh, eh,
dwh->ctx.headers, GNUNET_NO,
&handle_deposit_wtid_finished, &handle_deposit_wtid_finished,
dwh); dwh);
return dwh; return dwh;

View File

@ -334,9 +334,8 @@ TALER_EXCHANGE_track_transfer (struct TALER_EXCHANGE_Handle *exchange,
{ {
struct TALER_EXCHANGE_TrackTransferHandle *wdh; struct TALER_EXCHANGE_TrackTransferHandle *wdh;
struct GNUNET_CURL_Context *ctx; struct GNUNET_CURL_Context *ctx;
char *buf;
char *path;
CURL *eh; CURL *eh;
char arg_str[sizeof (struct TALER_WireTransferIdentifierRawP) * 2 + 32];
if (GNUNET_YES != if (GNUNET_YES !=
TEAH_handle_is_ready (exchange)) TEAH_handle_is_ready (exchange))
@ -350,17 +349,23 @@ TALER_EXCHANGE_track_transfer (struct TALER_EXCHANGE_Handle *exchange,
wdh->cb = cb; wdh->cb = cb;
wdh->cb_cls = cb_cls; wdh->cb_cls = cb_cls;
buf = GNUNET_STRINGS_data_to_string_alloc (wtid, {
sizeof (struct char wtid_str[sizeof (struct TALER_WireTransferIdentifierRawP) * 2];
TALER_WireTransferIdentifierRawP)); char *end;
GNUNET_asprintf (&path,
"/track/transfer?wtid=%s",
buf);
wdh->url = TEAH_path_to_url (wdh->exchange,
path);
GNUNET_free (buf);
GNUNET_free (path);
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); eh = TEL_curl_easy_get (wdh->url);
ctx = TEAH_handle_to_context (exchange); ctx = TEAH_handle_to_context (exchange);
wdh->job = GNUNET_CURL_job_add (ctx, wdh->job = GNUNET_CURL_job_add (ctx,