commit 53d3b742e90dbd275b2d08e96613d12ac4280b77
parent 76dc05a85867ab5a49b57c5152014dc3224a1ed9
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 22 Dec 2024 15:03:21 +0100
work on tops AML helpers
Diffstat:
4 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
@@ -632,6 +632,7 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs)
struct TALER_KYCLOGIC_KycRule *rule
= &lrs->kyc_rules[off];
const json_t *jmeasures;
+ const char *rn = NULL;
struct GNUNET_JSON_Specification ispec[] = {
TALER_JSON_spec_kycte ("operation_type",
&rule->trigger),
@@ -649,6 +650,10 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs)
&rule->exposed),
NULL),
GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("rule_name",
+ &rn),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_bool ("is_and_combinator",
&rule->is_and_combinator),
NULL),
@@ -669,6 +674,8 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs)
(int) rule->trigger,
TALER_amount2s (&rule->threshold));
rule->lrs = lrs;
+ if (NULL != rn)
+ rule->rule_name = GNUNET_strdup (rn);
rule->num_measures = json_array_size (jmeasures);
rule->next_measures
= GNUNET_new_array (rule->num_measures,
diff --git a/src/kyclogic/taler-exchange-helper-measure-tops-kyx-check b/src/kyclogic/taler-exchange-helper-measure-tops-kyx-check
@@ -65,7 +65,7 @@ do
exit 0
;;
v)
- echo "$0 v0.0.0"
+ echo "$0 v0.0.1"
exit 0
;;
V)
@@ -95,6 +95,8 @@ CURRENT_RULES=$(echo "$INPUTS" | jq '.current_rules // null')
# Get context values.
EXPIRATION_TIME=$(echo "$INPUTS" | jq '.context.expiration_time // .current_rules.expiration_time // null')
+FORM="error"
+
case "$LEGAL_ENTITY"
in
"NATURAL")
@@ -118,31 +120,39 @@ in
esac
# Check high-level case
-if [ "$FORM" == "none" ]
-then
- # Proceed to AML stage, preserve rules
- # FIXME: check if we have to change anything in the rules to prevent
- # the user from getting the basic KYC form *again*!
- echo "$INPUTS" | taler-exchange-helper-measure-preserve-but-investigate
- exit $?
-fi
+case "$FORM"
+in
+ "error")
+ # This should not happen, immediately trigger investigation and show error to the user.
+ echo "ERROR: Unexpected legal entity '${LEGAL_ENTITY}'" 1>&2
+ NEW_RULES=$(echo "$CURRENT_RULES" | jq '(.rules[] | select (.rule_name==\"kyc-rule-deposit-limit-zero\").measures=["form-info-internal-error"])')
+ INVESTIGATE="true"
+ ;;
+ "none")
+ # Immediately trigger investigation.
+ # FIXME: or rather: address validation!
+ NEW_RULES=$(echo "$CURRENT_RULES" | jq '(.rules[] | select (.rule_name==\"kyc-rule-deposit-limit-zero\").measures=["form-info-investigation"])')
+ INVESTIGATE="true"
+ ;;
+ *)
+ # Proceed to FORM.
+ echo "Selected VQF form ${FORM}." 1&>2
-# Proceed to FORM.
-echo "Selected VQF form ${FORM}." 1&>2
-# FIXME: force user to fill in $FORM
-# FIXME: instead of this insanity, match against rule_name!
-# NEW_RULES=$(echo "$CURRENT_RULES" | jq 'walk(if (type == "object" and ( ( (.operation_type == "withdraw") and (.threshold == "${EXCHANGE_AML_PROGRAM_TOPS_SMS_WITHDRAW_THRESHOLD") ) or ( (.operation_type == "merge") and (.threshold == "${EXCHANGE_AML_PROGRAM_TOPS_SMS_MERGE_THRESHOLD" ) ) ) ) then del(.) else . end)')
-echo "Not implemented"
-exit 1 # not implemented
+ # Force user to fill in $FORM
+ NEW_RULES=$(echo "$CURRENT_RULES" | jq "(.rules[] | select (.rule_name==\"kyc-rule-deposit-limit-zero\").measures=[\"form-${FORM}\"])")
+ INVESTIGATE="false"
+ ;;
+esac
# Finally, output the new rules.
# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
# for the required output format.
jq \
+ --jsonarg inv "$INVESTIGATE" \
--jsonarg et "$EXPIRATION_TIME" \
--jsonarg sm "$SUCCESSOR_MEASURE" \
--jsonarg cm "$CUSTOM_MEASURES" \
--jsonarg nr "$NEW_RULES" \
- '{"new_rules":$nr+{"expiration_time":$et,"successor_measure":$sm,"custom_measures":($nr.custom_measures+$cm)}}|del(..|nulls)'
+ '{"to_investigate":$inv,"new_rules":$nr+{"expiration_time":$et,"successor_measure":$sm,"custom_measures":($nr.custom_measures+$cm)}}|del(..|nulls)'
exit 0
diff --git a/src/kyclogic/taler-exchange-helper-measure-tops-postal-check b/src/kyclogic/taler-exchange-helper-measure-tops-postal-check
@@ -70,7 +70,7 @@ do
exit 0
;;
v)
- echo "$0 v0.0.0"
+ echo "$0 v0.0.1"
exit 0
;;
V)
@@ -112,7 +112,8 @@ if $(echo "$COUNTRY" | grep -E -e ${EXCHANGE_AML_PROGRAM_TOPS_POSTAL_CHECK_COUNT
then
# Valid country
# Remove limitation from current rules.
- NEW_RULES=$(echo "$CURRENT_RULES" | jq 'walk(if (type == "object" and ( ( (.operation_type == "withdraw") and (.threshold == "${EXCHANGE_AML_PROGRAM_TOPS_POSTAL_WITHDRAW_THRESHOLD") ) or ( (.operation_type == "merge") and (.threshold == "${EXCHANGE_AML_PROGRAM_TOPS_POSTAL_MERGE_THRESHOLD" ) ) ) ) then del(.) else . end)')
+ NEW_RULES=$(echo "$CURRENT_RULES" | jq 'del(.rules[] | select ((.rule_name=="kyc-rule-p2p-domestic-identification-requirement") || (.rule_name=="kyc-rule-withdraw-limit-low") ))')
+
else
# Invalid country
echo "Country ${COUNTRY} invalid." 1&>2
diff --git a/src/kyclogic/taler-exchange-helper-measure-tops-sms-check b/src/kyclogic/taler-exchange-helper-measure-tops-sms-check
@@ -68,7 +68,7 @@ do
exit 0
;;
v)
- echo "$0 v0.0.0"
+ echo "$0 v0.0.1"
exit 0
;;
V)
@@ -108,7 +108,9 @@ if $(echo "$PHONE_NUMBER" | grep -E -e ${EXCHANGE_AML_PROGRAM_TOPS_SMS_CHECK_REG
then
# Valid phone number
# Remove limitation from current rules.
- NEW_RULES=$(echo "$CURRENT_RULES" | jq 'walk(if (type == "object" and ( ( (.operation_type == "withdraw") and (.threshold == "${EXCHANGE_AML_PROGRAM_TOPS_SMS_WITHDRAW_THRESHOLD") ) or ( (.operation_type == "merge") and (.threshold == "${EXCHANGE_AML_PROGRAM_TOPS_SMS_MERGE_THRESHOLD" ) ) ) ) then del(.) else . end)')
+ # Remove limitation from current rules.
+ NEW_RULES=$(echo "$CURRENT_RULES" | jq 'del(.rules[] | select ((.rule_name=="kyc-rule-p2p-domestic-identification-requirement") || (.rule_name=="kyc-rule-withdraw-limit-low") ))')
+
else
# Invalid phone number
echo "Phone number ${PHONE_NUMBER} invalid." 1&>2