aboutsummaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_batch-withdraw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange/taler-exchange-httpd_batch-withdraw.c')
-rw-r--r--src/exchange/taler-exchange-httpd_batch-withdraw.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c b/src/exchange/taler-exchange-httpd_batch-withdraw.c
index 9d7d64cb..270ee0ca 100644
--- a/src/exchange/taler-exchange-httpd_batch-withdraw.c
+++ b/src/exchange/taler-exchange-httpd_batch-withdraw.c
@@ -26,12 +26,14 @@
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <jansson.h>
+#include "taler-exchange-httpd.h"
#include "taler_json_lib.h"
#include "taler_kyclogic_lib.h"
#include "taler_mhd_lib.h"
#include "taler-exchange-httpd_batch-withdraw.h"
#include "taler-exchange-httpd_responses.h"
#include "taler-exchange-httpd_keys.h"
+#include "taler_util.h"
/**
@@ -306,8 +308,10 @@ batch_withdraw_transaction (void *cls,
struct BatchWithdrawContext *wc = cls;
uint64_t ruuid;
enum GNUNET_DB_QueryStatus qs;
- bool balance_ok = false;
bool found = false;
+ bool balance_ok = false;
+ bool age_ok = false;
+ uint16_t allowed_maximum_age = 0;
char *kyc_required;
struct TALER_PaytoHashP reserve_h_payto;
@@ -466,12 +470,16 @@ batch_withdraw_transaction (void *cls,
return qs;
}
wc->kyc.ok = true;
+
qs = TEH_plugin->do_batch_withdraw (TEH_plugin->cls,
wc->now,
wc->reserve_pub,
&wc->batch_total,
+ TEH_age_restriction_enabled,
&found,
&balance_ok,
+ &age_ok,
+ &allowed_maximum_age,
&ruuid);
if (0 > qs)
{
@@ -493,6 +501,22 @@ batch_withdraw_transaction (void *cls,
NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+
+ if (! age_ok)
+ {
+ /* We respond with the lowest age in the corresponding age group
+ * of the required age */
+ uint16_t lowest_age = TALER_get_lowest_age (
+ &TEH_age_restriction_config.mask,
+ allowed_maximum_age);
+
+ TEH_plugin->rollback (TEH_plugin->cls);
+ *mhd_ret = TEH_RESPONSE_reply_reserve_age_restriction_required (
+ connection,
+ lowest_age);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+
if (! balance_ok)
{
TEH_plugin->rollback (TEH_plugin->cls);
@@ -717,10 +741,12 @@ parse_planchets (const struct TEH_RequestContext *rc,
struct PlanchetContext *pc = &wc->planchets[i];
struct TEH_DenominationKey *dk;
- dk = TEH_keys_denomination_by_hash2 (ksh,
- &pc->collectable.denom_pub_hash,
- NULL,
- NULL);
+ dk = TEH_keys_denomination_by_hash_from_state (
+ ksh,
+ &pc->collectable.denom_pub_hash,
+ NULL,
+ NULL);
+
if (NULL == dk)
{
if (! check_request_idempotent (wc,