aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-02-19 10:21:29 +0100
committerChristian Grothoff <christian@grothoff.org>2023-02-19 10:21:29 +0100
commit06e2e8022c01f2a2866eb79ed38552ef5ac2a6b2 (patch)
treebec032926469f5506d9051a9b1efa10066921ab7 /src/exchangedb
parentaa5e7d2ad5e712434f32ab41b63d53bb897c6105 (diff)
downloadexchange-06e2e8022c01f2a2866eb79ed38552ef5ac2a6b2.tar.xz
return KYC requirement row when AML imposed KYC requirements on withdraw; return KYC choices in new /config endpoint
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/0003-aml_status.sql1
-rw-r--r--src/exchangedb/exchange_do_insert_aml_decision.sql7
-rw-r--r--src/exchangedb/pg_select_aml_threshold.c6
-rw-r--r--src/exchangedb/pg_select_aml_threshold.h2
4 files changed, 14 insertions, 2 deletions
diff --git a/src/exchangedb/0003-aml_status.sql b/src/exchangedb/0003-aml_status.sql
index c0683c0d8..ee61cc391 100644
--- a/src/exchangedb/0003-aml_status.sql
+++ b/src/exchangedb/0003-aml_status.sql
@@ -30,6 +30,7 @@ BEGIN
',threshold_val INT8 NOT NULL DEFAULT(0)'
',threshold_frac INT4 NOT NULL DEFAULT(0)'
',status INT4 NOT NULL DEFAULT(0)'
+ ',kyc_requirement INT8 NOT NULL DEFAULT(0)'
') %s ;'
,table_name
,'PARTITION BY HASH (h_payto)'
diff --git a/src/exchangedb/exchange_do_insert_aml_decision.sql b/src/exchangedb/exchange_do_insert_aml_decision.sql
index 00f803752..f257675a8 100644
--- a/src/exchangedb/exchange_do_insert_aml_decision.sql
+++ b/src/exchangedb/exchange_do_insert_aml_decision.sql
@@ -62,6 +62,7 @@ THEN
SET threshold_val=in_new_threshold_val
,threshold_frac=in_new_threshold_frac
,status=in_new_status
+ ,kyc_requirement=in_requirement_row
WHERE h_payto=in_h_payto;
ASSERT FOUND, 'cannot have AML decision history but no AML status';
ELSE
@@ -70,12 +71,14 @@ ELSE
(h_payto
,threshold_val
,threshold_frac
- ,status)
+ ,status
+ ,kyc_requirement)
VALUES
(in_h_payto
,in_new_threshold_val
,in_new_threshold_frac
- ,in_new_status);
+ ,in_new_status
+ ,in_requirement_row);
END IF;
diff --git a/src/exchangedb/pg_select_aml_threshold.c b/src/exchangedb/pg_select_aml_threshold.c
index e67a57a39..7a79b70c1 100644
--- a/src/exchangedb/pg_select_aml_threshold.c
+++ b/src/exchangedb/pg_select_aml_threshold.c
@@ -31,6 +31,7 @@ TEH_PG_select_aml_threshold (
void *cls,
const struct TALER_PaytoHashP *h_payto,
enum TALER_AmlDecisionState *decision,
+ struct TALER_EXCHANGEDB_KycStatus *kyc,
struct TALER_Amount *threshold)
{
struct PostgresClosure *pg = cls;
@@ -44,6 +45,8 @@ TEH_PG_select_aml_threshold (
threshold),
GNUNET_PQ_result_spec_uint32 ("status",
&status32),
+ GNUNET_PQ_result_spec_uint64 ("kyc_requirement",
+ &kyc->requirement_row),
GNUNET_PQ_result_spec_end
};
enum GNUNET_DB_QueryStatus qs;
@@ -53,6 +56,7 @@ TEH_PG_select_aml_threshold (
"SELECT"
" threshold_val"
",threshold_frac"
+ ",kyc_requirement"
" FROM aml_status"
" WHERE h_payto=$1;");
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
@@ -60,5 +64,7 @@ TEH_PG_select_aml_threshold (
params,
rs);
*decision = (enum TALER_AmlDecisionState) status32;
+ kyc->ok = (TALER_AML_FROZEN != *decision)
+ || (0 != kyc->requirement_row);
return qs;
}
diff --git a/src/exchangedb/pg_select_aml_threshold.h b/src/exchangedb/pg_select_aml_threshold.h
index 618eb1c75..8f0e3bcfc 100644
--- a/src/exchangedb/pg_select_aml_threshold.h
+++ b/src/exchangedb/pg_select_aml_threshold.h
@@ -32,6 +32,7 @@
* @param cls closure
* @param h_payto account for which the AML threshold is stored
* @param[out] decision set to current AML decision
+ * @param[out] kyc set to KYC requirements imposed by AML, if any
* @param[out] threshold set to the existing threshold
* @return database transaction status, 0 if no threshold was set
*/
@@ -40,6 +41,7 @@ TEH_PG_select_aml_threshold (
void *cls,
const struct TALER_PaytoHashP *h_payto,
enum TALER_AmlDecisionState *decision,
+ struct TALER_EXCHANGEDB_KycStatus *kyc,
struct TALER_Amount *threshold);