aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/exchange_do_age_withdraw.sql
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-07-24 20:23:42 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-07-24 20:29:38 +0200
commit3e29bdfb8bfda133b7c25a36160a3533e836e0b8 (patch)
tree5d2271678e7b0e3175c340c8a033e3950050a11f /src/exchangedb/exchange_do_age_withdraw.sql
parente9f7ad3742bc16e1f0afa2162564c6faa4f3036f (diff)
downloadexchange-3e29bdfb8bfda133b7c25a36160a3533e836e0b8.tar.xz
[age-withdraw] first tests pass
age-withdraw successfully tested (no reveal yet): 1. reserve filled with amount large enough to trigger kyc 2. kyc oauth2 test daemon sets birthday to 2015-00-00 3. usual withdraw fails with CONFLICT and AGE_RESTRICTION_REQUIRED 4. age-withdraw with loo large of an maximum age fails 5. age-withdraw with appropriate maximum age succeeds
Diffstat (limited to 'src/exchangedb/exchange_do_age_withdraw.sql')
-rw-r--r--src/exchangedb/exchange_do_age_withdraw.sql34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/exchangedb/exchange_do_age_withdraw.sql b/src/exchangedb/exchange_do_age_withdraw.sql
index d6ae118ae..2230d4bff 100644
--- a/src/exchangedb/exchange_do_age_withdraw.sql
+++ b/src/exchangedb/exchange_do_age_withdraw.sql
@@ -32,6 +32,7 @@ CREATE OR REPLACE FUNCTION exchange_do_age_withdraw(
OUT balance_ok BOOLEAN,
OUT age_ok BOOLEAN,
OUT required_age INT2, -- in years ϵ [0,1..)
+ OUT reserve_birthday INT4,
OUT conflict BOOLEAN)
LANGUAGE plpgsql
AS $$
@@ -39,7 +40,6 @@ DECLARE
reserve_gc INT8;
reserve_val INT8;
reserve_frac INT4;
- reserve_birthday INT4;
not_before date;
earliest_date date;
BEGIN
@@ -64,23 +64,20 @@ SELECT
IF NOT FOUND
THEN
- -- reserve unknown
reserve_found=FALSE;
- balance_ok=FALSE;
- age_ok=FALSE;
- required_age=0;
+ age_ok = FALSE;
+ required_age=-1;
conflict=FALSE;
+ balance_ok=FALSE;
RETURN;
END IF;
+reserve_found = TRUE;
+conflict=FALSE; -- not really yet determined
-- Check age requirements
-IF ((maximum_age_committed = 0) OR (reserve_birthday = 0))
+IF (reserve_birthday <> 0)
THEN
- -- No commitment to a non-zero age was provided or the reserve is marked as
- -- having no age restriction. We can simply pass.
- age_ok = OK;
-ELSE
not_before=date '1970-01-01' + reserve_birthday;
earliest_date = current_date - make_interval(maximum_age_committed);
--
@@ -95,14 +92,18 @@ ELSE
--
IF (earliest_date < not_before)
THEN
- reserve_found = TRUE;
- balance_ok = FALSE;
+ required_age = extract(year from age(current_date, not_before));
age_ok = FALSE;
- required_age = extract(year from age(not_before, current_date)) + 1;
+ balance_ok=TRUE; -- NOT REALLY
RETURN;
END IF;
END IF;
+age_ok = TRUE;
+required_age=0;
+
+
+
-- Check reserve balance is sufficient.
IF (reserve_val > amount_val)
THEN
@@ -125,6 +126,8 @@ ELSE
END IF;
END IF;
+balance_ok=TRUE;
+
-- Calculate new expiration dates.
min_reserve_gc=GREATEST(min_reserve_gc,reserve_gc);
@@ -136,9 +139,6 @@ UPDATE reserves SET
WHERE
reserves.reserve_pub=rpub;
-reserve_found=TRUE;
-balance_ok=TRUE;
-
-- Write the commitment into the age-withdraw table
INSERT INTO exchange.age_withdraw
(h_commitment
@@ -146,7 +146,7 @@ INSERT INTO exchange.age_withdraw
,reserve_pub
,reserve_sig
,noreveal_index
- ,denomination_serials
+ ,denom_serials
,h_blind_evs
,denom_sigs)
VALUES