commit 02f3a10b5773b262b4bc61dfada485e7b3b7b5c7
parent 5ed75a31aee2d1b799df713244205c75e923d286
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 7 Oct 2024 15:58:07 +0200
more logging, handle cur aliasing in TALER_amount_set_zero()
Diffstat:
3 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_common_kyc.c b/src/exchange/taler-exchange-httpd_common_kyc.c
@@ -1707,11 +1707,18 @@ legitimization_check_run (
/* parse and free jrules (if we had any) */
if (NULL != jrules)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "KYC: have custom KYC rules for this account!\n");
lrs = TALER_KYCLOGIC_rules_parse (jrules);
GNUNET_break (NULL != lrs);
/* Fall back to default rules on parse error! */
json_decref (jrules);
}
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "KYC: default KYC rules apply to this account!\n");
+ }
}
if (NULL != lrs)
@@ -1755,6 +1762,7 @@ legitimization_check_run (
&lch->lcr.next_threshold);
if (qs < 0)
{
+ GNUNET_break (0);
TALER_KYCLOGIC_rules_free (lrs);
legi_fail (lch,
TALER_EC_GENERIC_DB_FETCH_FAILED,
@@ -1764,12 +1772,16 @@ legitimization_check_run (
}
if (lch->lcr.bad_kyc_auth)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "KYC auth required\n");
fail_kyc_auth (lch);
return;
}
if (NULL == requirement)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "KYC check passed\n");
lch->lcr.kyc.ok = true;
lch->lcr.expiration_date
= TALER_KYCLOGIC_rules_get_expiration (lrs);
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
@@ -599,6 +599,11 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs)
GNUNET_break_op (0);
goto cleanup;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Parsed KYC rule %u for %d with threshold %s\n",
+ (unsigned int) off,
+ (int) rule->trigger,
+ TALER_amount2s (&rule->threshold));
rule->lrs = lrs;
rule->num_measures = json_array_size (jmeasures);
rule->next_measures
@@ -2042,8 +2047,10 @@ add_rule (const struct GNUNET_CONFIGURATION_Handle *cfg,
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Adding KYC rule %s\n",
- section);
+ "Adding KYC rule %s for trigger %d with threshold %s\n",
+ section,
+ (int) ot,
+ TALER_amount2s (&threshold));
{
struct TALER_KYCLOGIC_KycRule kt = {
.lrs = &default_rules,
@@ -2947,7 +2954,14 @@ TALER_KYCLOGIC_kyc_test_required (
= &lrs->kyc_rules[i];
if (event != rule->trigger)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Rule %u is for a different trigger (%d/%d)\n",
+ i,
+ (int) event,
+ (int) rule->trigger);
continue;
+ }
if (have_threshold)
{
GNUNET_assert (GNUNET_OK ==
@@ -2961,16 +2975,19 @@ TALER_KYCLOGIC_kyc_test_required (
have_threshold = true;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Matched rule %u with timeframe %s\n",
+ "Matched rule %u with timeframe %s and threshold %s\n",
i,
GNUNET_TIME_relative2s (rule->timeframe,
- true));
+ true),
+ TALER_amount2s (&rule->threshold));
range = GNUNET_TIME_relative_max (range,
rule->timeframe);
}
if (! have_threshold)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "No rules apply\n");
*triggered_rule = NULL;
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
diff --git a/src/util/amount.c b/src/util/amount.c
@@ -243,17 +243,23 @@ enum GNUNET_GenericReturnValue
TALER_amount_set_zero (const char *cur,
struct TALER_Amount *amount)
{
+ char tmp[TALER_CURRENCY_LEN];
size_t slen;
if (GNUNET_OK !=
TALER_check_currency (cur))
return GNUNET_SYSERR;
slen = strlen (cur);
+ /* make a copy of 'cur' to 'tmp' as the memset may clobber cur
+ if cur aliases &amount->currency! */
+ memcpy (tmp,
+ cur,
+ slen);
memset (amount,
0,
sizeof (struct TALER_Amount));
for (unsigned int i = 0; i<slen; i++)
- amount->currency[i] = cur[i];
+ amount->currency[i] = tmp[i];
return GNUNET_OK;
}