aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-05-23 11:15:05 +0200
committerChristian Grothoff <christian@grothoff.org>2022-05-23 11:15:05 +0200
commitf1a58b0fd857b78f634b10b1a50759b380a5adee (patch)
treec625e8e84fd84238e880a7ac79c30ada6ae866a1 /src/lib
parentb3844e4923df39b41b8a8d46df173b1432c92364 (diff)
-towards reserve history testing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/exchange_api_purse_merge.c31
-rw-r--r--src/lib/exchange_api_reserves_history.c39
2 files changed, 45 insertions, 25 deletions
diff --git a/src/lib/exchange_api_purse_merge.c b/src/lib/exchange_api_purse_merge.c
index a32b44d48..0812fdadf 100644
--- a/src/lib/exchange_api_purse_merge.c
+++ b/src/lib/exchange_api_purse_merge.c
@@ -104,6 +104,12 @@ struct TALER_EXCHANGE_AccountMergeHandle
* Our merge key.
*/
struct TALER_PurseMergePrivateKeyP merge_priv;
+
+ /**
+ * Reserve signature affirming the merge.
+ */
+ struct TALER_ReserveSignatureP reserve_sig;
+
};
@@ -168,7 +174,8 @@ handle_purse_merge_finished (void *cls,
const json_t *j = response;
struct TALER_EXCHANGE_AccountMergeResponse dr = {
.hr.reply = j,
- .hr.http_status = (unsigned int) response_code
+ .hr.http_status = (unsigned int) response_code,
+ .reserve_sig = &pch->reserve_sig
};
pch->job = NULL;
@@ -180,17 +187,14 @@ handle_purse_merge_finished (void *cls,
case MHD_HTTP_OK:
{
const struct TALER_EXCHANGE_Keys *key_state;
- struct GNUNET_TIME_Timestamp etime;
struct TALER_Amount total_deposited;
- struct TALER_ExchangeSignatureP exchange_sig;
- struct TALER_ExchangePublicKeyP exchange_pub;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("exchange_sig",
- &exchange_sig),
+ &dr.details.success.exchange_sig),
GNUNET_JSON_spec_fixed_auto ("exchange_pub",
- &exchange_pub),
+ &dr.details.success.exchange_pub),
GNUNET_JSON_spec_timestamp ("exchange_timestamp",
- &etime),
+ &dr.details.success.etime),
TALER_JSON_spec_amount ("merge_amount",
pch->purse_value_after_fees.currency,
&total_deposited),
@@ -210,7 +214,7 @@ handle_purse_merge_finished (void *cls,
key_state = TALER_EXCHANGE_get_keys (pch->exchange);
if (GNUNET_OK !=
TALER_EXCHANGE_test_signing_key (key_state,
- &exchange_pub))
+ &dr.details.success.exchange_pub))
{
GNUNET_break_op (0);
dr.hr.http_status = 0;
@@ -219,15 +223,15 @@ handle_purse_merge_finished (void *cls,
}
if (GNUNET_OK !=
TALER_exchange_online_purse_merged_verify (
- etime,
+ dr.details.success.etime,
pch->purse_expiration,
&pch->purse_value_after_fees,
&pch->purse_pub,
&pch->h_contract_terms,
&pch->reserve_pub,
pch->provider_url,
- &exchange_pub,
- &exchange_sig))
+ &dr.details.success.exchange_pub,
+ &dr.details.success.exchange_sig))
{
GNUNET_break_op (0);
dr.hr.http_status = 0;
@@ -367,7 +371,6 @@ TALER_EXCHANGE_account_merge (
json_t *merge_obj;
CURL *eh;
struct TALER_PurseMergeSignatureP merge_sig;
- struct TALER_ReserveSignatureP reserve_sig;
char arg_str[sizeof (pch->purse_pub) * 2 + 32];
char *reserve_url;
@@ -442,7 +445,7 @@ TALER_EXCHANGE_account_merge (
min_age,
TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE,
reserve_priv,
- &reserve_sig);
+ &pch->reserve_sig);
}
merge_obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("payto_uri",
@@ -450,7 +453,7 @@ TALER_EXCHANGE_account_merge (
GNUNET_JSON_pack_data_auto ("merge_sig",
&merge_sig),
GNUNET_JSON_pack_data_auto ("reserve_sig",
- &reserve_sig),
+ &pch->reserve_sig),
GNUNET_JSON_pack_timestamp ("merge_timestamp",
merge_timestamp));
GNUNET_assert (NULL != merge_obj);
diff --git a/src/lib/exchange_api_reserves_history.c b/src/lib/exchange_api_reserves_history.c
index d9c42d691..2925b0253 100644
--- a/src/lib/exchange_api_reserves_history.c
+++ b/src/lib/exchange_api_reserves_history.c
@@ -65,14 +65,24 @@ struct TALER_EXCHANGE_ReservesHistoryHandle
TALER_EXCHANGE_ReservesHistoryCallback cb;
/**
+ * Closure for @a cb.
+ */
+ void *cb_cls;
+
+ /**
* Public key of the reserve we are querying.
*/
struct TALER_ReservePublicKeyP reserve_pub;
/**
- * Closure for @a cb.
+ * Our signature.
*/
- void *cb_cls;
+ struct TALER_ReserveSignatureP reserve_sig;
+
+ /**
+ * When did we make the request.
+ */
+ struct GNUNET_TIME_Timestamp ts;
};
@@ -93,7 +103,9 @@ handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,
unsigned int len;
struct TALER_EXCHANGE_ReserveHistory rs = {
.hr.reply = j,
- .hr.http_status = MHD_HTTP_OK
+ .hr.http_status = MHD_HTTP_OK,
+ .ts = rsh->ts,
+ .reserve_sig = &rsh->reserve_sig
};
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount_any ("balance",
@@ -247,9 +259,8 @@ TALER_EXCHANGE_reserves_history (
struct GNUNET_CURL_Context *ctx;
CURL *eh;
char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32];
- struct TALER_ReserveSignatureP reserve_sig;
- struct GNUNET_TIME_Timestamp ts
- = GNUNET_TIME_timestamp_get ();
+ const struct TALER_EXCHANGE_Keys *keys;
+ const struct TALER_EXCHANGE_GlobalFee *gf;
if (GNUNET_YES !=
TEAH_handle_is_ready (exchange))
@@ -261,6 +272,7 @@ TALER_EXCHANGE_reserves_history (
rsh->exchange = exchange;
rsh->cb = cb;
rsh->cb_cls = cb_cls;
+ rsh->ts = GNUNET_TIME_timestamp_get ();
GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
&rsh->reserve_pub.eddsa_pub);
{
@@ -293,16 +305,21 @@ TALER_EXCHANGE_reserves_history (
GNUNET_free (rsh);
return NULL;
}
- TALER_wallet_reserve_history_sign (ts,
- NULL, /* FIXME: fee! */
+ keys = TALER_EXCHANGE_get_keys (exchange);
+ GNUNET_assert (NULL != keys);
+ gf = TALER_EXCHANGE_get_global_fee (keys,
+ rsh->ts);
+ GNUNET_assert (NULL != gf);
+ TALER_wallet_reserve_history_sign (rsh->ts,
+ &gf->fees.history,
reserve_priv,
- &reserve_sig);
+ &rsh->reserve_sig);
{
json_t *history_obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_timestamp ("request_timestamp",
- ts),
+ rsh->ts),
GNUNET_JSON_pack_data_auto ("reserve_sig",
- &reserve_sig));
+ &rsh->reserve_sig));
if (GNUNET_OK !=
TALER_curl_easy_post (&rsh->post_ctx,