commit eadd86ae0dd44d4135a5ad020a73babe54963a7d
parent 1bf0b3a87520ddb14934995a68fe2347b23b28ce
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Wed, 18 Jun 2025 12:51:03 +0200
fix #9027
Diffstat:
8 files changed, 40 insertions(+), 33 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_aml-legitimization-measures-get.c b/src/exchange/taler-exchange-httpd_aml-legitimization-measures-get.c
@@ -50,7 +50,7 @@ static void
record_cb (
void *cls,
struct TALER_NormalizedPaytoHashP *h_payto,
- struct GNUNET_TIME_Timestamp start_time,
+ struct GNUNET_TIME_Absolute start_time,
const json_t *jmeasures,
bool is_finished,
uint64_t measure_serial_id)
@@ -67,7 +67,8 @@ record_cb (
GNUNET_JSON_pack_uint64 ("rowid",
measure_serial_id),
GNUNET_JSON_pack_timestamp ("start_time",
- start_time),
+ GNUNET_TIME_absolute_to_timestamp (
+ start_time)),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_object_incref ("measures",
(json_t *) jmeasures)),
@@ -111,6 +112,10 @@ TEH_handler_aml_legitimization_measures_get (
if (offset > INT64_MAX)
{
GNUNET_break_op (0); /* broken client */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Received invalid offset %llu > %llu\n",
+ (unsigned long long) offset,
+ (unsigned long long) INT64_MAX);
offset = INT64_MAX;
}
TALER_MHD_parse_request_arg_auto (rc->connection,
diff --git a/src/exchangedb/pg_select_aml_measures.c b/src/exchangedb/pg_select_aml_measures.c
@@ -73,7 +73,7 @@ handle_aml_result (void *cls,
{
struct TALER_NormalizedPaytoHashP h_payto;
uint64_t rowid;
- struct GNUNET_TIME_Timestamp start_time;
+ struct GNUNET_TIME_Absolute start_time;
json_t *jmeasures = NULL;
bool is_finished;
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -81,8 +81,8 @@ handle_aml_result (void *cls,
&rowid),
GNUNET_PQ_result_spec_auto_from_type ("h_normalized_payto",
&h_payto),
- GNUNET_PQ_result_spec_timestamp ("start_time",
- &start_time),
+ GNUNET_PQ_result_spec_absolute_time ("start_time",
+ &start_time),
TALER_PQ_result_spec_json ("jmeasures",
&jmeasures),
GNUNET_PQ_result_spec_bool ("is_finished",
@@ -114,7 +114,7 @@ enum GNUNET_DB_QueryStatus
TEH_PG_select_aml_measures (
void *cls,
const struct TALER_NormalizedPaytoHashP *h_payto,
- enum TALER_EXCHANGE_YesNoAll finished_only,
+ enum TALER_EXCHANGE_YesNoAll active_only,
uint64_t offset,
int64_t limit,
TALER_EXCHANGEDB_LegitimizationMeasureCallback cb,
@@ -128,9 +128,9 @@ TEH_PG_select_aml_measures (
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_auto_from_type (h_payto),
GNUNET_PQ_query_param_bool ((TALER_EXCHANGE_YNA_ALL ==
- finished_only)),
- GNUNET_PQ_query_param_bool ((TALER_EXCHANGE_YNA_YES ==
- finished_only)),
+ active_only)),
+ GNUNET_PQ_query_param_bool ((TALER_EXCHANGE_YNA_NO ==
+ active_only)),
GNUNET_PQ_query_param_uint64 (&offset),
GNUNET_PQ_query_param_uint64 (&ulimit),
GNUNET_PQ_query_param_end
diff --git a/src/exchangedb/pg_select_aml_measures.h b/src/exchangedb/pg_select_aml_measures.h
@@ -32,7 +32,7 @@
* @param cls closure
* @param h_payto account for which the attribute data is stored,
* NULL to select for all accounts
- * @param finished_only select only measures that are finished
+ * @param active_only select only measures that are active
* @param offset row offset to select from
* @param limit number of results to return, negative to
* return in descending order from @a offset
@@ -44,7 +44,7 @@ enum GNUNET_DB_QueryStatus
TEH_PG_select_aml_measures (
void *cls,
const struct TALER_NormalizedPaytoHashP *h_payto,
- enum TALER_EXCHANGE_YesNoAll finished_only,
+ enum TALER_EXCHANGE_YesNoAll active_only,
uint64_t offset,
int64_t limit,
TALER_EXCHANGEDB_LegitimizationMeasureCallback cb,
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
@@ -3379,7 +3379,7 @@ typedef void
(*TALER_EXCHANGEDB_LegitimizationMeasureCallback) (
void *cls,
struct TALER_NormalizedPaytoHashP *h_payto,
- struct GNUNET_TIME_Timestamp start_time,
+ struct GNUNET_TIME_Absolute start_time,
const json_t *jmeasures,
bool is_finished,
uint64_t measure_serial_id);
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
@@ -18,7 +18,7 @@ lib_LTLIBRARIES = \
libtalerexchange.la
libtalerexchange_la_LDFLAGS = \
- -version-info 16:0:0 \
+ -version-info 17:0:1 \
-no-undefined
libtalerexchange_la_SOURCES = \
exchange_api_add_aml_decision.c \
diff --git a/src/lib/exchange_api_aml_legitimizations_get.c b/src/lib/exchange_api_aml_legitimizations_get.c
@@ -256,6 +256,9 @@ handle_aml_legitimizations_get_finished (void *cls,
result.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
}
break;
+ case MHD_HTTP_NO_CONTENT:
+ /* can happen */
+ break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */
@@ -321,7 +324,7 @@ TALER_EXCHANGE_aml_legitimizations_get_create (
TALER_officer_aml_query_sign (officer_priv,
&algh->officer_sig);
algh->options.limit = -20; /* Default to last 20 entries */
- algh->options.offset = UINT64_MAX; /* Default to maximum row id */
+ algh->options.offset = INT64_MAX; /* Default to maximum row id */
algh->options.active = TALER_EXCHANGE_YNA_ALL; /* Default to all */
return algh;
}
@@ -379,6 +382,11 @@ TALER_EXCHANGE_aml_legitimizations_get_start (
}
algh->cb = cb;
algh->cb_cls = cb_cls;
+ if (algh->options.offset > INT64_MAX)
+ {
+ GNUNET_break (0);
+ algh->options.offset = INT64_MAX;
+ }
{
char *end;
@@ -418,11 +426,16 @@ TALER_EXCHANGE_aml_legitimizations_get_start (
"limit",
limit_str,
"offset",
- offset_str,
+ ( (algh->options.limit > 0) &&
+ (0 == algh->options.offset) ) ||
+ ( (algh->options.limit <= 0) &&
+ (INT64_MAX <= algh->options.offset) )
+ ? NULL
+ : offset_str,
"h_payto",
NULL == algh->options.h_payto
? NULL
- : offset_str,
+ : paytoh_str,
"active",
TALER_EXCHANGE_YNA_ALL == algh->options.active
? NULL
@@ -465,15 +478,12 @@ TALER_EXCHANGE_aml_legitimizations_get_start (
algh->job_headers = curl_slist_append (NULL,
hdr);
GNUNET_free (hdr);
- GNUNET_break (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_HTTPHEADER,
- algh->job_headers));
}
algh->job
- = GNUNET_CURL_job_add (
+ = GNUNET_CURL_job_add2 (
algh->ctx,
eh,
+ algh->job_headers,
&handle_aml_legitimizations_get_finished,
algh);
}
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
@@ -37,7 +37,7 @@ libtalertwistertesting_la_LDFLAGS = \
endif
libtalertesting_la_LDFLAGS = \
- -version-info 2:1:1 \
+ -version-info 3:0:2 \
-no-undefined
libtalertesting_la_SOURCES = \
testing_api_cmd_age_withdraw.c \
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
@@ -605,20 +605,12 @@ run (void *cls,
NULL,
"EUR:1000",
MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
-#if FIXME_LATER_9027
- /* FIXME: the above created a legitimization_measure, but NOT
- an actual *decision*, hence no decisions show up here!
- Design issue: we may want _some_ way to expose _measures_ to AML staff!
- What we have: wire_targets JOIN legitimization_measures
- USING (account_token) WHERE wire_targets.wire_target_h_payto=$ACCT
- will show that a _measure_ was triggered for the account.
- */
- TALER_TESTING_cmd_check_aml_decisions (
+ TALER_TESTING_cmd_get_active_legitimization_measures (
"check-decisions-wallet-pending",
"create-aml-officer-1",
"wallet-trigger-kyc-for-aml",
- MHD_HTTP_OK),
-#endif
+ MHD_HTTP_OK,
+ "{\"measures\": [{\"check_name\": \"oauth-test-id\", \"prog_name\": \"oauth-output-check\", \"context\": {}}], \"is_and_combinator\": true, \"verboten\": false}"),
/* Test that we are not allowed to take AML decisions as our
AML staff account is on read-only */
TALER_TESTING_cmd_take_aml_decision (