summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_purses_deposit.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-04-27 13:09:41 +0200
committerChristian Grothoff <christian@grothoff.org>2022-04-27 13:09:41 +0200
commitd623cab1a351040cca8729540327f948eb3027aa (patch)
tree2c73e0b394926aa1ab328b05c49269227b941fe1 /src/exchange/taler-exchange-httpd_purses_deposit.c
parent1396afc13664e11fe869c1cfa2ad690df7856c21 (diff)
downloadexchange-d623cab1a351040cca8729540327f948eb3027aa.tar.gz
exchange-d623cab1a351040cca8729540327f948eb3027aa.tar.bz2
exchange-d623cab1a351040cca8729540327f948eb3027aa.zip
-work on p2p payments
Diffstat (limited to 'src/exchange/taler-exchange-httpd_purses_deposit.c')
-rw-r--r--src/exchange/taler-exchange-httpd_purses_deposit.c50
1 files changed, 44 insertions, 6 deletions
diff --git a/src/exchange/taler-exchange-httpd_purses_deposit.c b/src/exchange/taler-exchange-httpd_purses_deposit.c
index 08a7d63b1..e2a5d34f4 100644
--- a/src/exchange/taler-exchange-httpd_purses_deposit.c
+++ b/src/exchange/taler-exchange-httpd_purses_deposit.c
@@ -329,7 +329,7 @@ parse_coin (struct MHD_Connection *connection,
if (GNUNET_OK !=
TALER_wallet_purse_deposit_verify (TEH_base_url,
pcc->purse_pub,
- &pcc->amount,
+ &coin->amount,
&coin->cpi.coin_pub,
&coin->coin_sig))
{
@@ -549,11 +549,49 @@ TEH_handler_purses_deposit (
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"deposits");
}
- /* FIXME: fetch basic purse properties
- (min age, purse_expiration, amount, merge_pub,
- h_contract_terms) from
- DB. Generate 404 or 410 (Gone) replies if
- applicable. */
+
+ {
+ enum GNUNET_DB_QueryStatus qs;
+ struct GNUNET_TIME_Timestamp merge_timestamp;
+
+ qs = TEH_plugin->select_purse (
+ TEH_plugin->cls,
+ pcc.purse_pub,
+ &pcc.purse_expiration,
+ &pcc.amount,
+ &pcc.deposit_total,
+ &pcc.h_contract_terms,
+ &merge_timestamp);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "select purse");
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "select purse");
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_EXCHANGE_GENERIC_PURSE_UNKNOWN,
+ NULL);
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ break; /* handled below */
+ }
+ if (GNUNET_TIME_absolute_is_past (pcc.purse_expiration.abs_time))
+ {
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_GONE,
+ TALER_EC_EXCHANGE_GENERIC_PURSE_EXPIRED,
+ NULL);
+ }
+ }
/* parse deposits */
pcc.coins = GNUNET_new_array (pcc.num_coins,