aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-08-05 22:39:20 +0200
committerChristian Grothoff <christian@grothoff.org>2024-08-05 22:39:20 +0200
commitd2babb0ff1118c39ccf153523ad8ccb0f4f45d1b (patch)
tree51bcf7ede6b9d361c41b172f171d69754726fb0f
parentd2eaf3bf7c9d6a0d86c92f2205d4a8b7969a1848 (diff)
-minor code cleanup
m---------contrib/wallet-core0
m---------doc/prebuilt0
-rw-r--r--src/exchange/taler-exchange-httpd_common_kyc.c111
-rw-r--r--src/exchange/taler-exchange-httpd_common_kyc.h31
-rw-r--r--src/exchange/taler-exchange-httpd_withdraw.c108
-rw-r--r--src/exchange/taler-exchange-httpd_withdraw.h30
-rw-r--r--src/include/taler_kyclogic_lib.h2
-rw-r--r--src/kyclogic/kyclogic_api.c3
8 files changed, 144 insertions, 141 deletions
diff --git a/contrib/wallet-core b/contrib/wallet-core
-Subproject 87fec1cc645cc66b8a65b2264067f473e44b37d
+Subproject 5934e007f637bd9834a811e67c0a030d7a59f2c
diff --git a/doc/prebuilt b/doc/prebuilt
-Subproject ab2e09b5a3711ab04f1f77f79158cc006cab319
+Subproject c1a885ac1f9d9b2fdef19a976bed01dab4f7d85
diff --git a/src/exchange/taler-exchange-httpd_common_kyc.c b/src/exchange/taler-exchange-httpd_common_kyc.c
index c8107940c..aea27f261 100644
--- a/src/exchange/taler-exchange-httpd_common_kyc.c
+++ b/src/exchange/taler-exchange-httpd_common_kyc.c
@@ -797,7 +797,7 @@ TEH_kyc_fallback (
struct TALER_KYCLOGIC_KycCheckContext kcc;
if (GNUNET_OK !=
- TALER_KYCLOGIC_get_default_measure (
+ TALER_KYCLOGIC_get_original_measure (
fallback_measure,
&kcc))
{
@@ -813,6 +813,7 @@ TEH_kyc_fallback (
fb->cb_cls = cb_cls;
if (NULL == kcc.check)
{
+ /* check was set to 'SKIP', run program immediately */
fb->aprh
= TALER_KYCLOGIC_run_aml_program2 (kcc.prog_name,
attributes,
@@ -900,3 +901,111 @@ TEH_kyc_failed (
}
return true;
}
+
+
+enum GNUNET_DB_QueryStatus
+TEH_legitimization_check (
+ struct TALER_EXCHANGEDB_KycStatus *kyc,
+ struct MHD_Connection *connection,
+ MHD_RESULT *mhd_ret,
+ enum TALER_KYCLOGIC_KycTriggerEvent et,
+ const char *payto_uri,
+ const struct TALER_PaytoHashP *h_payto,
+ const union TALER_AccountPublicKeyP *account_pub,
+ TALER_KYCLOGIC_KycAmountIterator ai,
+ void *ai_cls)
+{
+ struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs = NULL;
+ const struct TALER_KYCLOGIC_KycRule *requirement;
+ enum GNUNET_DB_QueryStatus qs;
+
+ {
+ json_t *jrules;
+
+ qs = TEH_plugin->get_kyc_rules (TEH_plugin->cls,
+ h_payto,
+ &jrules);
+ if (qs < 0)
+ {
+ if (GNUNET_DB_STATUS_HARD_ERROR == qs)
+ {
+ GNUNET_break (0);
+ *mhd_ret = TALER_MHD_reply_with_ec (connection,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "get_kyc_rules");
+ }
+ return qs;
+ }
+ if (qs > 0)
+ {
+ lrs = TALER_KYCLOGIC_rules_parse (jrules);
+ GNUNET_break (NULL != lrs);
+ /* Fall back to default rules on parse error! */
+ json_decref (jrules);
+ }
+ }
+
+ qs = TALER_KYCLOGIC_kyc_test_required (
+ et,
+ lrs,
+ ai,
+ ai_cls,
+ &requirement);
+ if (qs < 0)
+ {
+ TALER_KYCLOGIC_rules_free (lrs);
+ if (GNUNET_DB_STATUS_HARD_ERROR == qs)
+ {
+ GNUNET_break (0);
+ *mhd_ret = TALER_MHD_reply_with_ec (
+ connection,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "kyc_test_required");
+ }
+ return qs;
+ }
+
+ if (NULL == requirement)
+ {
+ TALER_KYCLOGIC_rules_free (lrs);
+ kyc->ok = true;
+ return qs;
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "KYC requirement is %s\n",
+ TALER_KYCLOGIC_rule2s (requirement));
+ kyc->ok = false;
+ {
+ json_t *jmeasures;
+
+ jmeasures = TALER_KYCLOGIC_rule_to_measures (requirement);
+ qs = TEH_plugin->trigger_kyc_rule_for_account (
+ TEH_plugin->cls,
+ payto_uri,
+ h_payto,
+ account_pub,
+ jmeasures,
+ TALER_KYCLOGIC_rule2priority (requirement),
+ &kyc->requirement_row);
+ json_decref (jmeasures);
+ }
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ GNUNET_break (0);
+ *mhd_ret = TALER_MHD_reply_with_ec (
+ connection,
+ TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+ "trigger_kyc_rule_for_account");
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+ if (GNUNET_DB_STATUS_HARD_ERROR == qs)
+ {
+ GNUNET_break (0);
+ *mhd_ret = TALER_MHD_reply_with_ec (connection,
+ TALER_EC_GENERIC_DB_STORE_FAILED,
+ "trigger_kyc_rule_for_account");
+ }
+ TALER_KYCLOGIC_rules_free (lrs);
+ return qs;
+}
diff --git a/src/exchange/taler-exchange-httpd_common_kyc.h b/src/exchange/taler-exchange-httpd_common_kyc.h
index 133930717..b866e867e 100644
--- a/src/exchange/taler-exchange-httpd_common_kyc.h
+++ b/src/exchange/taler-exchange-httpd_common_kyc.h
@@ -183,4 +183,35 @@ TEH_kyc_failed (
const char *error_message,
enum TALER_ErrorCode ec);
+
+/**
+ * Do legitimization check.
+ *
+ * @param[out] kyc set to kyc status
+ * @param[in,out] connection used to return hard errors
+ * @param[out] mhd_ret set if errors were returned
+ * (only on hard error)
+ * @param et type of event we are checking
+ * @param payto_uri account we are checking for
+ * @param h_payto hash of @a payto_uri
+ * @param account_pub public key to enable for the
+ * KYC authorization, NULL if not known
+ * @param ai callback to get amounts involved historically
+ * @param ai_cls closure for @a ai
+ * @return transaction status, error will have been
+ * queued if transaction status is set to hard error
+ */
+enum GNUNET_DB_QueryStatus
+TEH_legitimization_check (
+ struct TALER_EXCHANGEDB_KycStatus *kyc,
+ struct MHD_Connection *connection,
+ MHD_RESULT *mhd_ret,
+ enum TALER_KYCLOGIC_KycTriggerEvent et,
+ const char *payto_uri,
+ const struct TALER_PaytoHashP *h_payto,
+ const union TALER_AccountPublicKeyP *account_pub,
+ TALER_KYCLOGIC_KycAmountIterator ai,
+ void *ai_cls);
+
+
#endif
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c
index 94bd76ef1..320d02171 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -30,118 +30,12 @@
#include "taler_json_lib.h"
#include "taler_kyclogic_lib.h"
#include "taler_mhd_lib.h"
+#include "taler-exchange-httpd_common_kyc.h"
#include "taler-exchange-httpd_withdraw.h"
#include "taler-exchange-httpd_responses.h"
#include "taler_util.h"
-enum GNUNET_DB_QueryStatus
-TEH_legitimization_check (
- struct TALER_EXCHANGEDB_KycStatus *kyc,
- struct MHD_Connection *connection,
- MHD_RESULT *mhd_ret,
- enum TALER_KYCLOGIC_KycTriggerEvent et,
- const char *payto_uri,
- const struct TALER_PaytoHashP *h_payto,
- const union TALER_AccountPublicKeyP *account_pub,
- TALER_KYCLOGIC_KycAmountIterator ai,
- void *ai_cls)
-{
- struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs = NULL;
- const struct TALER_KYCLOGIC_KycRule *requirement;
- enum GNUNET_DB_QueryStatus qs;
-
- {
- json_t *jrules;
-
- qs = TEH_plugin->get_kyc_rules (TEH_plugin->cls,
- h_payto,
- &jrules);
- if (qs < 0)
- {
- if (GNUNET_DB_STATUS_HARD_ERROR == qs)
- {
- GNUNET_break (0);
- *mhd_ret = TALER_MHD_reply_with_ec (connection,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "get_kyc_rules");
- }
- return qs;
- }
- if (qs > 0)
- {
- lrs = TALER_KYCLOGIC_rules_parse (jrules);
- GNUNET_break (NULL != lrs);
- /* Fall back to default rules on parse error! */
- json_decref (jrules);
- }
- }
-
- qs = TALER_KYCLOGIC_kyc_test_required (
- et,
- lrs,
- ai,
- ai_cls,
- &requirement);
- if (qs < 0)
- {
- TALER_KYCLOGIC_rules_free (lrs);
- if (GNUNET_DB_STATUS_HARD_ERROR == qs)
- {
- GNUNET_break (0);
- *mhd_ret = TALER_MHD_reply_with_ec (connection,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "kyc_test_required");
- }
- return qs;
- }
-
- if (NULL == requirement)
- {
- TALER_KYCLOGIC_rules_free (lrs);
- kyc->ok = true;
- return qs;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "KYC requirement is %s\n",
- TALER_KYCLOGIC_rule2s (requirement));
- kyc->ok = false;
- {
- json_t *jmeasures;
-
- jmeasures = TALER_KYCLOGIC_rule_to_measures (requirement);
- qs = TEH_plugin->trigger_kyc_rule_for_account (
- TEH_plugin->cls,
- payto_uri,
- h_payto,
- account_pub,
- jmeasures,
- TALER_KYCLOGIC_rule2priority (requirement),
- &kyc->requirement_row);
- json_decref (jmeasures);
- }
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
- {
- GNUNET_break (0);
- *mhd_ret = TALER_MHD_reply_with_ec (
- connection,
- TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
- "trigger_kyc_rule_for_account");
- return GNUNET_DB_STATUS_HARD_ERROR;
- }
- if (GNUNET_DB_STATUS_HARD_ERROR == qs)
- {
- GNUNET_break (0);
- *mhd_ret = TALER_MHD_reply_with_ec (connection,
- TALER_EC_GENERIC_DB_STORE_FAILED,
- "trigger_kyc_rule_for_account");
- }
- TALER_KYCLOGIC_rules_free (lrs);
- return qs;
-}
-
-
/**
* Closure for #withdraw_amount_cb().
*/
diff --git a/src/exchange/taler-exchange-httpd_withdraw.h b/src/exchange/taler-exchange-httpd_withdraw.h
index a01ac625a..45ac6340f 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.h
+++ b/src/exchange/taler-exchange-httpd_withdraw.h
@@ -26,36 +26,6 @@
/**
- * Do legitimization check.
- *
- * @param[out] kyc set to kyc status
- * @param[in,out] connection used to return hard errors
- * @param[out] mhd_ret set if errors were returned
- * (only on hard error)
- * @param et type of event we are checking
- * @param payto_uri account we are checking for
- * @param h_payto hash of @a payto_uri
- * @param account_pub public key to enable for the
- * KYC authorization, NULL if not known
- * @param ai callback to get amounts involved historically
- * @param ai_cls closure for @a ai
- * @return transaction status, error will have been
- * queued if transaction status is set to hard error
- */
-enum GNUNET_DB_QueryStatus
-TEH_legitimization_check (
- struct TALER_EXCHANGEDB_KycStatus *kyc,
- struct MHD_Connection *connection,
- MHD_RESULT *mhd_ret,
- enum TALER_KYCLOGIC_KycTriggerEvent et,
- const char *payto_uri,
- const struct TALER_PaytoHashP *h_payto,
- const union TALER_AccountPublicKeyP *account_pub,
- TALER_KYCLOGIC_KycAmountIterator ai,
- void *ai_cls);
-
-
-/**
* Do legitimization check for withdrawing @a withdraw_total
* from @a reserve_pub at time @a now.
*
diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h
index e99a3f2a9..c04553ea5 100644
--- a/src/include/taler_kyclogic_lib.h
+++ b/src/include/taler_kyclogic_lib.h
@@ -583,7 +583,7 @@ TALER_KYCLOGIC_provider_to_logic (
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
-TALER_KYCLOGIC_get_default_measure (
+TALER_KYCLOGIC_get_original_measure (
const char *measure_name,
struct TALER_KYCLOGIC_KycCheckContext *kcc);
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
index fad66e914..d29a6ac34 100644
--- a/src/kyclogic/kyclogic_api.c
+++ b/src/kyclogic/kyclogic_api.c
@@ -2052,7 +2052,6 @@ add_measure (const struct GNUNET_CONFIGURATION_Handle *cfg,
&check_name))
{
check_name = GNUNET_strdup ("SKIP");
- goto fail;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -2420,7 +2419,7 @@ TALER_KYCLOGIC_provider_to_logic (
enum GNUNET_GenericReturnValue
-TALER_KYCLOGIC_get_default_measure (
+TALER_KYCLOGIC_get_original_measure (
const char *measure_name,
struct TALER_KYCLOGIC_KycCheckContext *kcc)
{