From 141d4b154a9d6f57ba82edda1cd003be8adb1dd5 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 7 May 2020 20:22:02 +0200 Subject: towards changing timestamp in deposit confirmation (tests failing) --- src/lib/auditor_api_deposit_confirmation.c | 17 +++++++++-------- src/lib/exchange_api_common.c | 2 +- src/lib/exchange_api_deposit.c | 9 ++++++--- src/lib/exchange_api_refund.c | 7 +++++-- 4 files changed, 21 insertions(+), 14 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auditor_api_deposit_confirmation.c b/src/lib/auditor_api_deposit_confirmation.c index cddfe8b14..1856a89f4 100644 --- a/src/lib/auditor_api_deposit_confirmation.c +++ b/src/lib/auditor_api_deposit_confirmation.c @@ -148,7 +148,7 @@ handle_deposit_confirmation_finished (void *cls, * * @param h_wire hash of merchant wire details * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the auditor) - * @param timestamp timestamp when the contract was finalized, must not be too far in the future + * @param exchange_timestamp timestamp when the deposit was received by the wallet * @param refund_deadline date until which the merchant can issue a refund to the customer via the auditor (can be zero if refunds are not allowed); must not be after the @a wire_deadline * @param amount_without_fee the amount confirmed to be wired by the exchange to the merchant * @param coin_pub coin’s public key @@ -165,7 +165,7 @@ handle_deposit_confirmation_finished (void *cls, static int verify_signatures (const struct GNUNET_HashCode *h_wire, const struct GNUNET_HashCode *h_contract_terms, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Absolute exchange_timestamp, struct GNUNET_TIME_Absolute refund_deadline, const struct TALER_Amount *amount_without_fee, const struct TALER_CoinSpendPublicKeyP *coin_pub, @@ -184,7 +184,7 @@ verify_signatures (const struct GNUNET_HashCode *h_wire, .purpose.size = htonl (sizeof (dc)), .h_contract_terms = *h_contract_terms, .h_wire = *h_wire, - .timestamp = GNUNET_TIME_absolute_hton (timestamp), + .exchange_timestamp = GNUNET_TIME_absolute_hton (exchange_timestamp), .refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline), .coin_pub = *coin_pub, .merchant = *merchant_pub @@ -256,7 +256,7 @@ verify_signatures (const struct GNUNET_HashCode *h_wire, * @param auditor the auditor handle; the auditor must be ready to operate * @param h_wire hash of merchant wire details * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the auditor) - * @param timestamp timestamp when the contract was finalized, must not be too far in the future + * @param exchange_timestamp timestamp when deposit was received by the exchange * @param refund_deadline date until which the merchant can issue a refund to the customer via the auditor (can be zero if refunds are not allowed); must not be after the @a wire_deadline * @param amount_without_fee the amount confirmed to be wired by the exchange to the merchant * @param coin_pub coin’s public key @@ -278,7 +278,7 @@ TALER_AUDITOR_deposit_confirmation ( struct TALER_AUDITOR_Handle *auditor, const struct GNUNET_HashCode *h_wire, const struct GNUNET_HashCode *h_contract_terms, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Absolute exchange_timestamp, struct GNUNET_TIME_Absolute refund_deadline, const struct TALER_Amount *amount_without_fee, const struct TALER_CoinSpendPublicKeyP *coin_pub, @@ -298,7 +298,7 @@ TALER_AUDITOR_deposit_confirmation ( json_t *deposit_confirmation_obj; CURL *eh; - (void) GNUNET_TIME_round_abs (×tamp); + (void) GNUNET_TIME_round_abs (&exchange_timestamp); (void) GNUNET_TIME_round_abs (&refund_deadline); (void) GNUNET_TIME_round_abs (&ep_start); (void) GNUNET_TIME_round_abs (&ep_expire); @@ -308,7 +308,7 @@ TALER_AUDITOR_deposit_confirmation ( if (GNUNET_OK != verify_signatures (h_wire, h_contract_terms, - timestamp, + exchange_timestamp, refund_deadline, amount_without_fee, coin_pub, @@ -336,7 +336,8 @@ TALER_AUDITOR_deposit_confirmation ( "h_wire", GNUNET_JSON_from_data_auto (h_wire), "h_contract_terms", GNUNET_JSON_from_data_auto ( h_contract_terms), - "timestamp", GNUNET_JSON_from_time_abs (timestamp), + "exchange_timestamp", GNUNET_JSON_from_time_abs ( + exchange_timestamp), "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline), "amount_without_fee", TALER_JSON_from_amount ( amount_without_fee), diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index dc44291d0..bf8eb5376 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -524,7 +524,7 @@ TALER_EXCHANGE_verify_coin_history ( GNUNET_JSON_spec_fixed_auto ("h_wire", &dr.h_wire), GNUNET_JSON_spec_absolute_time_nbo ("timestamp", - &dr.timestamp), + &dr.wallet_timestamp), GNUNET_JSON_spec_absolute_time_nbo ("refund_deadline", &dr.refund_deadline), TALER_JSON_spec_amount_nbo ("deposit_fee", diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c index a5cf6c36a..276053658 100644 --- a/src/lib/exchange_api_deposit.c +++ b/src/lib/exchange_api_deposit.c @@ -160,7 +160,7 @@ auditor_cb (void *cls, ah, &dh->depconf.h_wire, &dh->depconf.h_contract_terms, - GNUNET_TIME_absolute_ntoh (dh->depconf.timestamp), + GNUNET_TIME_absolute_ntoh (dh->depconf.exchange_timestamp), GNUNET_TIME_absolute_ntoh (dh->depconf.refund_deadline), &amount_without_fee, &dh->depconf.coin_pub, @@ -198,6 +198,8 @@ verify_deposit_signature_ok (struct TALER_EXCHANGE_DepositHandle *dh, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("exchange_sig", exchange_sig), GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub), + GNUNET_JSON_spec_absolute_time_nbo ("exchange_timestamp", + &dh->depconf.exchange_timestamp), GNUNET_JSON_spec_end () }; @@ -386,6 +388,7 @@ handle_deposit_finished (void *cls, } dh->cb (dh->cb_cls, &hr, + GNUNET_TIME_absolute_ntoh (dh->depconf.exchange_timestamp), es, ep); TALER_EXCHANGE_deposit_cancel (dh); @@ -429,7 +432,7 @@ verify_signatures (const struct TALER_EXCHANGE_DenomPublicKey *dki, .purpose.size = htonl (sizeof (dr)), .h_contract_terms = *h_contract_terms, .h_wire = *h_wire, - .timestamp = GNUNET_TIME_absolute_hton (timestamp), + .wallet_timestamp = GNUNET_TIME_absolute_hton (timestamp), .refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline), .merchant = *merchant_pub, .coin_pub = *coin_pub @@ -658,7 +661,7 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT); dh->depconf.h_contract_terms = *h_contract_terms; dh->depconf.h_wire = h_wire; - dh->depconf.timestamp = GNUNET_TIME_absolute_hton (timestamp); + /* dh->depconf.exchange_timestamp; -- initialized later from exchange reply! */ dh->depconf.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline); TALER_amount_hton (&dh->depconf.amount_without_fee, &amount_without_fee); diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index b1ea176bf..6f91389f1 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -148,7 +148,8 @@ handle_refund_finished (void *cls, struct TALER_ExchangeSignatureP exchange_sig; struct TALER_ExchangePublicKeyP *ep = NULL; struct TALER_ExchangeSignatureP *es = NULL; - struct TALER_Amount *rf = NULL; + struct TALER_Amount ra; + const struct TALER_Amount *rf = NULL; const json_t *j = response; struct TALER_EXCHANGE_HttpResponse hr = { .reply = j, @@ -176,7 +177,9 @@ handle_refund_finished (void *cls, { ep = &exchange_pub; es = &exchange_sig; - rf = &rh->depconf.refund_fee; + TALER_amount_ntoh (&ra, + &rh->depconf.refund_fee); + rf = &ra; } break; case MHD_HTTP_BAD_REQUEST: -- cgit v1.2.3