From a48db85013a942d71ecdf98740a469468eb9882f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 15 Oct 2021 23:34:23 +0200 Subject: add KYC logic for /deposit handling (DB part incomplete) --- src/exchangedb/plugin_exchangedb_postgres.c | 56 +++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'src/exchangedb/plugin_exchangedb_postgres.c') diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index eda6468ba..dfd7432e3 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -359,6 +359,17 @@ prepare_statements (struct PostgresClosure *pg) " WHERE reserve_pub=$1" " LIMIT 1;", 1), +#if FIXME_DD23 + /* Used in #postgres_get_kyc_status() */ + GNUNET_PQ_make_prepare ("get_kyc_status", + "SELECT" + ",kyc_ok" + ",wire_target_serial_id AS payment_target_uuid" + " FROM wire_targets" + " WHERE payto_uri=$1" + " LIMIT 1;", + 1), +#endif /* Used in #reserves_get() */ GNUNET_PQ_make_prepare ("reserves_get", "SELECT" @@ -3516,6 +3527,50 @@ postgres_reserves_get (void *cls, } +/** + * Get the KYC status for a bank account. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param payto_uri payto:// URI that identifies the bank account + * @param[out] kyc set to the KYC status of the reserve + * @return transaction status + */ +static enum GNUNET_DB_QueryStatus +postgres_get_kyc_status (void *cls, + const char *payto_uri, + struct TALER_EXCHANGEDB_KycStatus *kyc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_end + }; + uint8_t ok8; + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("payment_target_uuid", + &kyc->payment_target_uuid), + GNUNET_PQ_result_spec_auto_from_type ("kyc_ok", + &ok8), + GNUNET_PQ_result_spec_end + }; + enum GNUNET_DB_QueryStatus qs; + +#if FIXME_DD23 + qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "get_kyc_status", + params, + rs); +#else + qs = 1; + ok8 = 0; + kyc->payment_target_uuid = 0; +#endif + kyc->type = TALER_EXCHANGEDB_KYC_DEPOSIT; + kyc->ok = (0 != ok8); + return qs; +} + + /** * Get the summary of a reserve. * @@ -11071,6 +11126,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) plugin->iterate_auditor_denominations = &postgres_iterate_auditor_denominations; plugin->reserves_get = &postgres_reserves_get; + plugin->get_kyc_status = &postgres_get_kyc_status; plugin->reserves_in_insert = &postgres_reserves_in_insert; plugin->get_latest_reserve_in_reference = &postgres_get_latest_reserve_in_reference; -- cgit v1.2.3