commit 1c72ccf6bdfeddb1444cc97c80ed2603cb402327
parent 0b8554ee97d017ace1a4bf6bdf37c434dcf6ef65
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 4 May 2025 11:40:13 +0200
filter zero-requirements by wallet/account as well
Diffstat:
3 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_kyc-info.c b/src/exchange/taler-exchange-httpd_kyc-info.c
@@ -553,7 +553,8 @@ current_rules_cb (
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
{
jmeasures
- = TALER_KYCLOGIC_zero_measures (kyp->lrs);
+ = TALER_KYCLOGIC_zero_measures (kyp->lrs,
+ kyp->is_wallet);
if (NULL == jmeasures)
{
qs = TEH_plugin->commit (TEH_plugin->cls);
diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h
@@ -345,12 +345,15 @@ TALER_KYCLOGIC_get_aml_program_fallback (const char *prog_name);
* has performed any operation.
*
* @param lrs rule set to investigate, NULL for default
+ * @param is_wallet true to return measures for wallets,
+ * false to return measures for accounts
* @return LegitimizationMeasures, NULL if there are no
* zero measures
*/
json_t *
TALER_KYCLOGIC_zero_measures (
- const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs);
+ const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs,
+ bool is_wallet);
/**
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
@@ -380,6 +380,45 @@ TALER_KYCLOGIC_rules_get_successor (
/**
+ * Check if @a trigger applies to our context.
+ *
+ * @param trigger the trigger to evaluate
+ * @param is_wallet true if we are talking about a wallet,
+ * false if we are talking about an account
+ * @return true if @a trigger applies in this context
+ */
+static bool
+trigger_applies (enum TALER_KYCLOGIC_KycTriggerEvent trigger,
+ bool is_wallet)
+{
+ switch (trigger)
+ {
+ case TALER_KYCLOGIC_KYC_TRIGGER_NONE:
+ GNUNET_break (0);
+ break;
+ case TALER_KYCLOGIC_KYC_TRIGGER_WITHDRAW:
+ return ! is_wallet;
+ case TALER_KYCLOGIC_KYC_TRIGGER_DEPOSIT:
+ return ! is_wallet;
+ case TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE:
+ return is_wallet;
+ case TALER_KYCLOGIC_KYC_TRIGGER_WALLET_BALANCE:
+ return is_wallet;
+ case TALER_KYCLOGIC_KYC_TRIGGER_RESERVE_CLOSE:
+ return ! is_wallet;
+ case TALER_KYCLOGIC_KYC_TRIGGER_AGGREGATE:
+ return ! is_wallet;
+ case TALER_KYCLOGIC_KYC_TRIGGER_TRANSACTION:
+ return true;
+ case TALER_KYCLOGIC_KYC_TRIGGER_REFUND:
+ return true;
+ }
+ GNUNET_break (0);
+ return true;
+}
+
+
+/**
* Lookup a KYC check by @a check_name
*
* @param check_name name to search for
@@ -1157,7 +1196,8 @@ TALER_KYCLOGIC_rule_to_measures (
json_t *
TALER_KYCLOGIC_zero_measures (
- const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs)
+ const struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs,
+ bool is_wallet)
{
json_t *zero_measures;
const struct TALER_KYCLOGIC_KycRule *rules;
@@ -1176,6 +1216,9 @@ TALER_KYCLOGIC_zero_measures (
continue;
if (rule->verboten)
continue; /* see: hard_limits */
+ if (! trigger_applies (rule->trigger,
+ is_wallet))
+ continue;
if (! TALER_amount_is_zero (&rule->threshold))
continue;
for (unsigned int j = 0; j<rule->num_measures; j++)