aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-09-11 22:51:12 +0200
committerChristian Grothoff <christian@grothoff.org>2024-09-11 22:51:12 +0200
commitb3c5db363adea7434bc87737f930f053e03d868e (patch)
treeb8a72758b2db91128320cd9115a8894e0325ba67 /src/exchangedb
parent6a7717aff159eb7734f4962b375ccee5c8b246d9 (diff)
fix incorrect setting of bad_kyc_auth
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql b/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql
index 4ddf57952..414ac51ff 100644
--- a/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql
+++ b/src/exchangedb/exchange_do_trigger_kyc_rule_for_account.sql
@@ -33,10 +33,12 @@ DECLARE
my_rec RECORD;
my_access_token BYTEA;
my_account_pub BYTEA;
+ my_reserve_pub BYTEA;
BEGIN
-- Note: in_payto_uri is allowed to be NULL *if*
-- in_h_payto is already in wire_targets
+
SELECT
access_token
,target_pub
@@ -68,6 +70,24 @@ ELSE
out_bad_kyc_auth=TRUE;
END IF;
+IF out_bad_kyc_auth
+THEN
+ -- Check most recent reserve_in wire transfer, we also
+ -- allow that reserve public key for authentication!
+ SELECT reserve_pub
+ INTO my_reserve_pub
+ FROM reserves_in
+ WHERE wire_source_h_payto=in_h_payto
+ ORDER BY execution_date DESC
+ LIMIT 1;
+ IF FOUND
+ THEN
+ IF in_merchant_pub = my_reserve_pub
+ THEN
+ out_bad_kyc_auth = FALSE;
+ END IF;
+ END IF;
+END IF;
-- First check if a perfectly equivalent legi measure
-- already exists, to avoid creating tons of duplicates.
UPDATE legitimization_measures