exchange

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

commit b8888d336d4332e0a6b9e1c1399b016f078b1df4
parent 3a8ad480175c48af6fc8f9a1e22cc1a51a06b2f2
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun,  5 Jan 2025 23:21:56 +0100

init json for account freeze

Diffstat:
Msrc/exchange/taler-exchange-sanctionscheck.c | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 74 insertions(+), 2 deletions(-)

diff --git a/src/exchange/taler-exchange-sanctionscheck.c b/src/exchange/taler-exchange-sanctionscheck.c @@ -309,6 +309,76 @@ account_cb (void *cls, /** + * Initialize JSON rules for freezing an account. + * + * @return true on success + */ +static bool +init_freeze (void) +{ + char *currency; + struct TALER_Amount zero; + json_t *rules; + json_t *verboten; + + if (GNUNET_OK != + TALER_config_get_currency (cfg, + "exchange", + &currency)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "currency"); + return false; + } + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (currency, + &zero)); + verboten = json_array (); + GNUNET_assert (NULL != verboten); + GNUNET_assert (0 == + json_array_append_new (verboten, + json_string ("verboten"))); + rules = json_array (); + GNUNET_assert (NULL != rules); + for (enum TALER_KYCLOGIC_KycTriggerEvent et = + TALER_KYCLOGIC_KYC_TRIGGER_WITHDRAW; + et <= TALER_KYCLOGIC_KYC_TRIGGER_REFUND; + et++) + { + json_t *rule; + + rule = GNUNET_JSON_PACK ( + TALER_JSON_pack_kycte ("operation_type", + et), + TALER_JSON_pack_amount ("threshold", + &zero), + GNUNET_JSON_pack_time_rel ("timeframe", + GNUNET_TIME_UNIT_YEARS), + GNUNET_JSON_pack_array_incref ("measures", + verboten), + GNUNET_JSON_pack_uint64 ("display_priority", + 1), + GNUNET_JSON_pack_bool ("exposed", + false), + GNUNET_JSON_pack_bool ("is_and_combinator", + false)); + GNUNET_assert (0 == + json_array_append_new (rules, + rule)); + } + json_decref (verboten); + freeze_rules = + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_timestamp ("expiration_time", + GNUNET_TIME_UNIT_FOREVER_TS), + GNUNET_JSON_pack_array_steal ("rules", + rules)); + return true; +} + + +/** * First task. * * @param cls closure, NULL @@ -328,7 +398,8 @@ run (void *cls, (void) args; (void) cfgfile; cfg = c; - + if (! init_freeze ()) + return; { char *attr_enc_key_str; @@ -416,7 +487,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - freeze_rules = NULL; /* FIXME-#9053: set to JSON rules that freeze the account */ ret = GNUNET_PROGRAM_run ( TALER_EXCHANGE_project_data (), argc, argv, @@ -425,6 +495,8 @@ main (int argc, "process that checks all existing customer accounts against a sanctions list"), options, &run, NULL); + json_decref (freeze_rules); + freeze_rules = NULL; if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret)