diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-10-14 14:45:10 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-10-14 14:45:10 +0200 |
commit | 7d62fa065bba408860a79fe121a62ef8f515159c (patch) | |
tree | e03053b30346fb0c6e90ccef7f57c5d63ef8d174 /src/exchange | |
parent | 1b119edd6225567419add05e0a92170ebfa457df (diff) | |
download | exchange-7d62fa065bba408860a79fe121a62ef8f515159c.tar.gz exchange-7d62fa065bba408860a79fe121a62ef8f515159c.tar.bz2 exchange-7d62fa065bba408860a79fe121a62ef8f515159c.zip |
start with KYC support in DB
Diffstat (limited to 'src/exchange')
-rw-r--r-- | src/exchange/taler-exchange-httpd.c | 48 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd.h | 14 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_withdraw.c | 13 |
3 files changed, 73 insertions, 2 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index b7845f5aa..9f0abb0e3 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -1076,6 +1076,48 @@ handle_mhd_request (void *cls, /** + * Load general KYC configuration parameters for the exchange server into the + * #TEH_kyc_config variable. + * + * @return #GNUNET_OK on success + */ +static enum GNUNET_GenericReturnValue +parse_kyc_settings (void) +{ + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_time (TEH_cfg, + "exchange", + "KYC_WITHDRAW_PERIOD", + &TEH_kyc_config.withdraw_period)) + { + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KYC_WITHDRAW_PERIOD", + "valid relative time expected"); + return GNUNET_SYSERR; + } + if (GNUNET_TIME_relative_is_zero (TEH_kyc_config.withdraw_period)) + return GNUNET_OK; + if (GNUNET_OK != + TALER_config_get_amount (TEH_cfg, + "exchange", + "KYC_WITHDRAW_LIMIT", + &TEH_kyc_config.withdraw_limit)) + return GNUNET_SYSERR; + if (0 != strcasecmp (TEH_kyc_config.withdraw_limit.currency, + TEH_currency)) + { + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KYC_WITHDRAW_LIMIT", + "currency mismatch"); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + + +/** * Load OAuth2.0 configuration parameters for the exchange server into the * #TEH_kyc_config variable. * @@ -1265,6 +1307,12 @@ exchange_serve_process_config (void) } GNUNET_free (master_public_key_str); } + if (TEH_KYC_NONE != TEH_kyc_config.mode) + { + if (GNUNET_OK != + parse_kyc_settings ()) + return GNUNET_SYSERR; + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Launching exchange with public key `%s'...\n", GNUNET_p2s (&TEH_master_public_key.eddsa_pub)); diff --git a/src/exchange/taler-exchange-httpd.h b/src/exchange/taler-exchange-httpd.h index bf41d227d..7c95c9dc0 100644 --- a/src/exchange/taler-exchange-httpd.h +++ b/src/exchange/taler-exchange-httpd.h @@ -57,6 +57,20 @@ struct TEH_KycOptions enum TEH_KycMode mode; /** + * Maximum amount that can be withdrawn in @e withdraw_period without + * needing KYC. + * Only valid if @e mode is not #TEH_KYC_NONE and + * if @e withdraw_period is non-zero. + */ + struct TALER_Amount withdraw_limit; + + /** + * Time period over which @e withdraw_limit applies. + * Only valid if @e mode is not #TEH_KYC_NONE. + */ + struct GNUNET_TIME_Relative withdraw_period; + + /** * Details depending on @e mode. */ union diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index d9cba045c..ca5618af6 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2019 Taler Systems SA + Copyright (C) 2014-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -165,6 +165,7 @@ withdraw_transaction (void *cls, struct TALER_EXCHANGEDB_Reserve r; enum GNUNET_DB_QueryStatus qs; struct TALER_DenominationSignature denom_sig; + struct TALER_EXCHANGEDB_KycStatus kyc; #if OPTIMISTIC_SIGN /* store away optimistic signature to protect @@ -209,7 +210,8 @@ withdraw_transaction (void *cls, "Trying to withdraw from reserve: %s\n", TALER_B2S (&r.pub)); qs = TEH_plugin->reserves_get (TEH_plugin->cls, - &r); + &r, + &kyc); if (0 > qs) { if (GNUNET_DB_STATUS_HARD_ERROR == qs) @@ -268,6 +270,13 @@ withdraw_transaction (void *cls, return GNUNET_DB_STATUS_HARD_ERROR; } + if ( (! kyc.ok) && + (TEH_KYC_NONE != TEH_kyc_config.mode) ) + { + // FIXME: check if we are above the limit + // for KYC, and if so, deny the transaction! + } + /* Balance is good, sign the coin! */ #if ! OPTIMISTIC_SIGN if (NULL == wc->collectable.sig.rsa_signature) |