exchange

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

commit 3bb7be6cb8a25984ee6bff2f991690b6a6a08220
parent 5d25c0479b59f406d9c92ddd577b5b230dce033d
Author: Florian Dold <dold@taler.net>
Date:   Mon, 27 Jul 2026 20:43:38 +0200

exchange: preserve account rules when a sanction hit only investigates

Diffstat:
Msrc/exchangedb/insert_sanction_list_hit.sql | 35+++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/exchangedb/insert_sanction_list_hit.sql b/src/exchangedb/insert_sanction_list_hit.sql @@ -30,8 +30,39 @@ AS $$ DECLARE my_i INT4; ini_event TEXT; + my_rules JSONB; + my_expiration INT8; BEGIN +my_rules = in_new_rules; +my_expiration = in_expiration_time; + +IF in_new_rules IS NULL +THEN + -- A NULL here means "flag this account, but do not change its rules". + -- Storing the NULL would instead mean "no custom rules", silently + -- reverting the account to the exchange defaults and revoking KYC the + -- customer already passed. So carry the rule set that currently applies + -- (the one exchange_do_get_kyc_rules would pick) forward, together with + -- its expiration. + SELECT jnew_rules + ,expiration_time + INTO my_rules + ,my_expiration + FROM legitimization_outcomes + WHERE h_payto=in_h_normalized_payto + AND is_active + ORDER BY expiration_time DESC + ,outcome_serial_id DESC + LIMIT 1; + IF NOT FOUND OR my_rules IS NULL + THEN + -- Nothing to preserve: the account is already on the default rules. + my_rules = NULL; + my_expiration = in_expiration_time; + END IF; +END IF; + -- Disable all previous legitimization outcomes. UPDATE legitimization_outcomes SET is_active=FALSE @@ -48,10 +79,10 @@ INSERT INTO legitimization_outcomes VALUES (in_h_normalized_payto ,in_decision_time - ,in_expiration_time + ,my_expiration ,in_properties ,in_to_investigate - ,in_new_rules + ,my_rules ) RETURNING outcome_serial_id