exchange

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

commit 61f3336601d6fd6fdcf8abfc052902e5404d903e
parent cbc42d229bdd1b33fee821d0877daf74c098f9c4
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 23 Jun 2024 12:22:49 +0200

-more work on add decision

Diffstat:
Msrc/exchange/Makefile.am | 1+
Msrc/exchange/taler-exchange-httpd.c | 48+++++++++++++++++++++++++++++-------------------
Msrc/exchange/taler-exchange-httpd_aml-decisions-get.c | 1+
Msrc/include/taler_exchangedb_plugin.h | 40++++++++++++++++++++++++++++++++++++++++
Msrc/lib/exchange_api_add_aml_decision.c | 10+++++++---
5 files changed, 78 insertions(+), 22 deletions(-)

diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am @@ -126,6 +126,7 @@ taler_exchange_httpd_SOURCES = \ taler-exchange-httpd.c taler-exchange-httpd.h \ taler-exchange-httpd_age-withdraw.c taler-exchange-httpd_age-withdraw.h \ taler-exchange-httpd_age-withdraw_reveal.c taler-exchange-httpd_age-withdraw_reveal.h \ + taler-exchange-httpd_aml-attributes-get.c taler-exchange-httpd_aml-attributes-get.h \ taler-exchange-httpd_aml-decision.c taler-exchange-httpd_aml-decision.h \ taler-exchange-httpd_aml-decisions-get.c \ taler-exchange-httpd_auditors.c taler-exchange-httpd_auditors.h \ diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c @@ -32,6 +32,7 @@ #include "taler_mhd_lib.h" #include "taler-exchange-httpd_age-withdraw.h" #include "taler-exchange-httpd_age-withdraw_reveal.h" +#include "taler-exchange-httpd_aml-attributes-get.h" #include "taler-exchange-httpd_aml-decision.h" #include "taler-exchange-httpd_auditors.h" #include "taler-exchange-httpd_batch-deposit.h" @@ -558,6 +559,10 @@ handle_get_aml (struct TEH_RequestContext *rc, .handler = &TEH_handler_aml_decisions_get }, { + .op = "attributes", + .handler = &TEH_handler_aml_attributes_get + }, + { .op = NULL, .handler = NULL }, @@ -566,10 +571,11 @@ handle_get_aml (struct TEH_RequestContext *rc, if (NULL == args[0]) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_EXCHANGE_GENERIC_AML_OFFICER_PUB_MALFORMED, - "argument missing"); + return TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_EXCHANGE_GENERIC_AML_OFFICER_PUB_MALFORMED, + "argument missing"); } if (GNUNET_OK != GNUNET_STRINGS_string_to_data (args[0], @@ -578,26 +584,29 @@ handle_get_aml (struct TEH_RequestContext *rc, sizeof (officer_pub))) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_EXCHANGE_GENERIC_AML_OFFICER_PUB_MALFORMED, - args[0]); + return TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_EXCHANGE_GENERIC_AML_OFFICER_PUB_MALFORMED, + args[0]); } if (NULL == args[1]) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_EXCHANGE_GENERIC_WRONG_NUMBER_OF_SEGMENTS, - "AML GET operations must specify an operation identifier"); + return TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_EXCHANGE_GENERIC_WRONG_NUMBER_OF_SEGMENTS, + "AML GET operations must specify an operation identifier"); } { const char *sig_hdr; struct TALER_AmlOfficerSignatureP officer_sig; - sig_hdr = MHD_lookup_connection_value (rc->connection, - MHD_HEADER_KIND, - TALER_AML_OFFICER_SIGNATURE_HEADER); + sig_hdr = MHD_lookup_connection_value ( + rc->connection, + MHD_HEADER_KIND, + TALER_AML_OFFICER_SIGNATURE_HEADER); if ( (NULL == sig_hdr) || (GNUNET_OK != GNUNET_STRINGS_string_to_data (sig_hdr, @@ -609,10 +618,11 @@ handle_get_aml (struct TEH_RequestContext *rc, &officer_sig)) ) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_EXCHANGE_GENERIC_AML_OFFICER_GET_SIGNATURE_INVALID, - sig_hdr); + return TALER_MHD_reply_with_error ( + rc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_EXCHANGE_GENERIC_AML_OFFICER_GET_SIGNATURE_INVALID, + sig_hdr); } TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++; } diff --git a/src/exchange/taler-exchange-httpd_aml-decisions-get.c b/src/exchange/taler-exchange-httpd_aml-decisions-get.c @@ -170,6 +170,7 @@ TEH_handler_aml_decisions_get ( TALER_EC_GENERIC_DB_FETCH_FAILED, "select_aml_decisions"); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + json_decref (records); return TALER_MHD_reply_static ( rc->connection, MHD_HTTP_NO_CONTENT, diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h @@ -3539,6 +3539,24 @@ typedef void /** + * Return AML attribute information. + * + * @param cls closure + * @param row_id current row in kyc_attributes table + * @param provider_name which provider collected the data, NULL for user upload + * @param collection_time when were the attributes collected + * @param attributes the collected attributes + */ +typedef void +(*TALER_EXCHANGEDB_AmlAttributeCallback)( + void *cls, + uint64_t row_id, + const char *provider_name, + struct GNUNET_TIME_Timestamp collection_time, + const json_t *attributes); + + +/** * @brief The plugin API, returned from the plugin's "init" function. * The argument given to "init" is simply a configuration handle. */ @@ -7172,6 +7190,28 @@ struct TALER_EXCHANGEDB_Plugin /** + * Lookup AML attributes of a particular account. + * + * @param cls closure + * @param h_payto which account should we return attributes for + * @param offset row to start from + * @param limit how many records to return (negative + * to go back in time, positive to go forward) + * @param cb callback to invoke on each match + * @param cb_cls closure for @a cb + * @return database transaction status + */ + enum GNUNET_DB_QueryStatus + (*select_aml_attributes)( + void *cls, + const struct TALER_PaytoHashP *h_payto, + uint64_t offset, + int64_t limit, + TALER_EXCHANGEDB_AmlAttributeCallback cb, + void *cb_cls); + + + /** * Insert an AML decision. Inserts into AML history and insert or updates AML * status. * diff --git a/src/lib/exchange_api_add_aml_decision.c b/src/lib/exchange_api_add_aml_decision.c @@ -227,6 +227,8 @@ TALER_EXCHANGE_add_aml_decision ( decision_time, h_payto, new_rules, + properties, + keep_investigating, officer_priv, &officer_sig); wh = GNUNET_new (struct TALER_EXCHANGE_AddAmlDecision); @@ -267,12 +269,14 @@ TALER_EXCHANGE_add_aml_decision ( h_payto), GNUNET_JSON_pack_object_steal ("new_rules", new_rules), + GNUNET_JSON_pack_object_incref ("properties", + (json_t *) properties), GNUNET_JSON_pack_bool ("keep_investigating", keep_investigating), - GNUNET_JSON_pack_timestamp ("decision_time", - decision_time), GNUNET_JSON_pack_data_auto ("officer_sig", - &officer_sig)); + &officer_sig), + GNUNET_JSON_pack_timestamp ("decision_time", + decision_time)); eh = TALER_EXCHANGE_curl_easy_get_ (wh->url); if ( (NULL == eh) || (GNUNET_OK !=