diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2022-03-21 03:59:31 +0100 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2022-03-21 03:59:31 +0100 |
commit | c7e2d206bab7f06375be2154b323ad429d13a9e7 (patch) | |
tree | 969cc459e34e9cc88074269e272fd27be38f01f5 /src/exchange/taler-exchange-httpd_reserves_history.c | |
parent | 1f86b02ffa60e3817f6a7d70a654f02759e793f3 (diff) |
add logic to check timestamp, revise history balance calculation logic in client
Diffstat (limited to 'src/exchange/taler-exchange-httpd_reserves_history.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_reserves_history.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/exchange/taler-exchange-httpd_reserves_history.c b/src/exchange/taler-exchange-httpd_reserves_history.c index 4115988f..96902d01 100644 --- a/src/exchange/taler-exchange-httpd_reserves_history.c +++ b/src/exchange/taler-exchange-httpd_reserves_history.c @@ -32,6 +32,14 @@ /** + * How far do we allow a client's time to be off when + * checking the request timestamp? + */ +#define TIMESTAMP_TOLERANCE \ + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) + + +/** * Closure for #reserve_history_transaction. */ struct ReserveHistoryContext @@ -121,8 +129,7 @@ reserve_history_transaction (void *cls, struct ReserveHistoryContext *rsc = cls; enum GNUNET_DB_QueryStatus qs; - // FIXME: first deduct rsc->gf->fees.history from balance! - // FIXME: pass rsc.gf->history_expiration? + // FIXME: first deduct rsc->gf->fees.history from reserve balance (and persist the signature justifying this) qs = TEH_plugin->get_reserve_history (TEH_plugin->cls, rsc->reserve_pub, &rsc->balance, @@ -175,13 +182,21 @@ TEH_handler_reserves_history (struct TEH_RequestContext *rc, } } now = GNUNET_TIME_timestamp_get (); - /* FIXME: check that 'timestamp' is close to 'now' */ - + if (! GNUNET_TIME_absolute_approx_eq (now.abs_time, + rsc.timestamp.abs_time, + TIMESTAMP_TOLERANCE)) + { + GNUNET_break_op (0); + return TALER_MHD_reply_with_error (rc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_EXCHANGE_GENERIC_CLOCK_SKEW, + NULL); + } rsc.gf = TEH_keys_global_fee_by_time (TEH_keys_get_state (), rsc.timestamp); if (NULL == rsc.gf) { - GNUNET_break_op (0); + GNUNET_break (0); return TALER_MHD_reply_with_error (rc->connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION, |