exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit ae9b97a4392cda62ebdb86b87c388d2b4dcdf54f
parent 2211fcb2dd1362891d41949ac0ddaa3444248002
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue,  3 Jun 2025 20:45:51 +0200

implement protocol v28: expose default rules to AML officer; fixes #9890

Diffstat:
Msrc/exchange/taler-exchange-httpd_aml-measures-get.c | 6+++++-
Msrc/exchange/taler-exchange-httpd_config.h | 2+-
Msrc/include/taler_kyclogic_lib.h | 4+++-
Msrc/kyclogic/Makefile.am | 2+-
Msrc/kyclogic/kyclogic_api.c | 56+++++++++++++++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 65 insertions(+), 5 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_aml-measures-get.c b/src/exchange/taler-exchange-httpd_aml-measures-get.c @@ -40,12 +40,14 @@ TEH_handler_aml_measures_get ( static json_t *roots; static json_t *programs; static json_t *checks; + static json_t *default_rules; if (NULL == roots) { TALER_KYCLOGIC_get_measure_configuration (&roots, &programs, - &checks); + &checks, + &default_rules); } if (NULL != args[0]) { @@ -59,6 +61,8 @@ TEH_handler_aml_measures_get ( return TALER_MHD_REPLY_JSON_PACK ( rc->connection, MHD_HTTP_OK, + GNUNET_JSON_pack_array_incref ("default_rules", + default_rules), GNUNET_JSON_pack_object_incref ("roots", roots), GNUNET_JSON_pack_object_incref ("programs", diff --git a/src/exchange/taler-exchange-httpd_config.h b/src/exchange/taler-exchange-httpd_config.h @@ -41,7 +41,7 @@ * * Returned via both /config and /keys endpoints. */ -#define EXCHANGE_PROTOCOL_VERSION "27:0:5" +#define EXCHANGE_PROTOCOL_VERSION "28:0:6" /** diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h @@ -721,12 +721,14 @@ TALER_KYCLOGIC_kyc_get_details ( * @param[out] proots set to the root measures * @param[out] pprograms set to available AML programs * @param[out] pchecks set to available KYC checks + * @param[out] pdefault_rules set to array of default KycRules */ void TALER_KYCLOGIC_get_measure_configuration ( json_t **proots, json_t **pprograms, - json_t **pchecks); + json_t **pchecks, + json_t **pdefault_rules); /** diff --git a/src/kyclogic/Makefile.am b/src/kyclogic/Makefile.am @@ -63,7 +63,7 @@ libtalerkyclogic_la_LIBADD = \ -ljansson \ $(XLIB) libtalerkyclogic_la_LDFLAGS = \ - -version-info 1:1:0 \ + -version-info 2:0:0 \ -no-undefined diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c @@ -3797,13 +3797,16 @@ void TALER_KYCLOGIC_get_measure_configuration ( json_t **proots, json_t **pprograms, - json_t **pchecks) + json_t **pchecks, + json_t **pdefault_rules) { json_t *roots; json_t *programs; json_t *checks; + json_t *drules; roots = json_object (); + GNUNET_assert (NULL != roots); for (unsigned int i = 0; i<default_rules.num_custom_measures; i++) { const struct TALER_KYCLOGIC_Measure *m @@ -3825,6 +3828,7 @@ TALER_KYCLOGIC_get_measure_configuration ( } programs = json_object (); + GNUNET_assert (NULL != programs); for (unsigned int i = 0; i<num_aml_programs; i++) { const struct TALER_KYCLOGIC_AmlProgram *ap @@ -3868,6 +3872,7 @@ TALER_KYCLOGIC_get_measure_configuration ( } checks = json_object (); + GNUNET_assert (NULL != checks); for (unsigned int i = 0; i<num_kyc_checks; i++) { const struct TALER_KYCLOGIC_KycCheck *ck @@ -3914,10 +3919,59 @@ TALER_KYCLOGIC_get_measure_configuration ( ck->check_name, jc)); } + drules = json_array (); + GNUNET_assert (NULL != drules); + { + const struct TALER_KYCLOGIC_KycRule *rules + = default_rules.kyc_rules; + unsigned int num_rules + = default_rules.num_kyc_rules; + + for (unsigned int i = 0; i<num_rules; i++) + { + const struct TALER_KYCLOGIC_KycRule *rule = &rules[i]; + json_t *measures; + json_t *limit; + + measures = json_array (); + GNUNET_assert (NULL != measures); + for (unsigned int j = 0; j<rule->num_measures; j++) + GNUNET_assert ( + 0 == + json_array_append_new (measures, + json_string ( + rule->next_measures[j]))); + limit = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("rule_name", + rule->rule_name)), + TALER_JSON_pack_kycte ("operation_type", + rule->trigger), + TALER_JSON_pack_amount ("threshold", + &rule->threshold), + GNUNET_JSON_pack_time_rel ("timeframe", + rule->timeframe), + GNUNET_JSON_pack_array_steal ("measures", + measures), + GNUNET_JSON_pack_uint64 ("display_priority", + rule->display_priority), + GNUNET_JSON_pack_bool ("soft_limit", + ! rule->verboten), + GNUNET_JSON_pack_bool ("exposed", + rule->exposed), + GNUNET_JSON_pack_bool ("is_and_combinator", + rule->is_and_combinator) + ); + GNUNET_assert (0 == + json_array_append_new (drules, + limit)); + } + } *proots = roots; *pprograms = programs; *pchecks = checks; + *pdefault_rules = drules; }