From aa5e7d2ad5e712434f32ab41b63d53bb897c6105 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 17 Feb 2023 18:24:20 +0100 Subject: more towards actually allowing AML decisions to trigger KYC --- src/exchangedb/0003-aml_history.sql | 7 +++++++ src/exchangedb/exchange_do_insert_aml_decision.sql | 5 ++++- src/exchangedb/pg_insert_aml_decision.c | 4 +++- src/exchangedb/pg_insert_aml_decision.h | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/exchangedb') diff --git a/src/exchangedb/0003-aml_history.sql b/src/exchangedb/0003-aml_history.sql index b411a6fb1..e57a2313f 100644 --- a/src/exchangedb/0003-aml_history.sql +++ b/src/exchangedb/0003-aml_history.sql @@ -33,6 +33,7 @@ BEGIN ',decision_time INT8 NOT NULL DEFAULT(0)' ',justification VARCHAR NOT NULL' ',kyc_requirements VARCHAR' + ',kyc_req_row INT8 NOT NULL DEFAULT(0)' ',decider_pub BYTEA CHECK (LENGTH(decider_pub)=32)' ',decider_sig BYTEA CHECK (LENGTH(decider_sig)=64)' ') %s ;' @@ -87,6 +88,12 @@ BEGIN ,table_name ,partition_suffix ); + PERFORM comment_partitioned_column( + 'Row in the KYC table for this KYC requirement, 0 for none.' + ,'kyc_req_row' + ,table_name + ,partition_suffix + ); PERFORM comment_partitioned_column( 'Signature key of the staff member affirming the AML decision; of type AML_DECISION' ,'decider_sig' diff --git a/src/exchangedb/exchange_do_insert_aml_decision.sql b/src/exchangedb/exchange_do_insert_aml_decision.sql index 8e22c57f8..00f803752 100644 --- a/src/exchangedb/exchange_do_insert_aml_decision.sql +++ b/src/exchangedb/exchange_do_insert_aml_decision.sql @@ -25,6 +25,7 @@ CREATE OR REPLACE FUNCTION exchange_do_insert_aml_decision( IN in_decider_sig BYTEA, IN in_notify_s VARCHAR, IN in_kyc_requirements VARCHAR, + IN in_requirement_row INT8, OUT out_invalid_officer BOOLEAN, OUT out_last_date INT8) LANGUAGE plpgsql @@ -86,6 +87,7 @@ INSERT INTO exchange.aml_history ,decision_time ,justification ,kyc_requirements + ,kyc_req_row ,decider_pub ,decider_sig ) VALUES @@ -96,6 +98,7 @@ INSERT INTO exchange.aml_history ,in_decision_time ,in_justification ,in_kyc_requirements + ,in_requirement_row ,in_decider_pub ,in_decider_sig); @@ -119,5 +122,5 @@ END IF; END $$; -COMMENT ON FUNCTION exchange_do_insert_aml_decision(BYTEA, INT8, INT4, INT4, INT8, VARCHAR, BYTEA, BYTEA, VARCHAR, VARCHAR) +COMMENT ON FUNCTION exchange_do_insert_aml_decision(BYTEA, INT8, INT4, INT4, INT8, VARCHAR, BYTEA, BYTEA, VARCHAR, VARCHAR, INT8) IS 'Checks whether the AML officer is eligible to make AML decisions and if so inserts the decision into the table'; diff --git a/src/exchangedb/pg_insert_aml_decision.c b/src/exchangedb/pg_insert_aml_decision.c index 5a1b71235..62645c2a2 100644 --- a/src/exchangedb/pg_insert_aml_decision.c +++ b/src/exchangedb/pg_insert_aml_decision.c @@ -36,6 +36,7 @@ TEH_PG_insert_aml_decision ( struct GNUNET_TIME_Timestamp decision_time, const char *justification, const json_t *kyc_requirements, + uint64_t requirements_row, const struct TALER_AmlOfficerPublicKeyP *decider_pub, const struct TALER_AmlOfficerSignatureP *decider_sig, bool *invalid_officer, @@ -64,6 +65,7 @@ TEH_PG_insert_aml_decision ( NULL != kyc_requirements ? GNUNET_PQ_query_param_string (kyc_s) : GNUNET_PQ_query_param_null (), + GNUNET_PQ_query_param_uint64 (&requirements_row), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -81,7 +83,7 @@ TEH_PG_insert_aml_decision ( " out_invalid_officer" ",out_last_date" " FROM exchange_do_insert_aml_decision" - "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);"); + "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);"); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "do_insert_aml_decision", params, diff --git a/src/exchangedb/pg_insert_aml_decision.h b/src/exchangedb/pg_insert_aml_decision.h index 4d4ca6e54..073a2f50a 100644 --- a/src/exchangedb/pg_insert_aml_decision.h +++ b/src/exchangedb/pg_insert_aml_decision.h @@ -37,6 +37,7 @@ * @param decision_time when was the decision made * @param justification human-readable text justifying the decision * @param kyc_requirements JSON array with KYC requirements + * @param requirements_row row in the KYC table for this process, 0 for none * @param decider_pub public key of the staff member * @param decider_sig signature of the staff member * @param[out] invalid_officer set to TRUE if @a decider_pub is not allowed to make decisions right now @@ -53,6 +54,7 @@ TEH_PG_insert_aml_decision ( struct GNUNET_TIME_Timestamp decision_time, const char *justification, const json_t *kyc_requirements, + uint64_t requirements_row, const struct TALER_AmlOfficerPublicKeyP *decider_pub, const struct TALER_AmlOfficerSignatureP *decider_sig, bool *invalid_officer, -- cgit v1.2.3