exchange

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

commit 1c53b027665639f3d6cde4edb0e76472040d1a3c
parent 250a2376b5d2941647220676e33b7086f3a32648
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 12 Jun 2025 09:39:45 +0200

implement per account (h_payto) filter for GET /aml/*/transfer-* endpoints (for #10031)

Diffstat:
Msrc/exchange/taler-exchange-httpd_aml-transfer-get.c | 9+++++++++
Msrc/exchangedb/pg_select_exchange_credit_transfers.c | 6++++++
Msrc/exchangedb/pg_select_exchange_credit_transfers.h | 2++
Msrc/exchangedb/pg_select_exchange_debit_transfers.c | 6++++++
Msrc/exchangedb/pg_select_exchange_debit_transfers.h | 2++
Msrc/exchangedb/pg_select_exchange_kycauth_transfers.c | 6++++++
Msrc/exchangedb/pg_select_exchange_kycauth_transfers.h | 2++
Msrc/include/taler_exchangedb_plugin.h | 6++++++
8 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_aml-transfer-get.c b/src/exchange/taler-exchange-httpd_aml-transfer-get.c @@ -101,6 +101,8 @@ aml_transfer_get ( int64_t limit = -20; uint64_t offset; struct TALER_Amount threshold; + struct TALER_NormalizedPaytoHashP h_payto; + bool have_payto = false; if (NULL != args[0]) { @@ -111,6 +113,10 @@ aml_transfer_get ( TALER_EC_GENERIC_ENDPOINT_UNKNOWN, args[0]); } + TALER_MHD_parse_request_arg_auto (rc->connection, + "h_payto", + &h_payto, + have_payto); TALER_MHD_parse_request_snumber (rc->connection, "limit", &limit); @@ -151,6 +157,7 @@ aml_transfer_get ( &threshold, offset, limit, + have_payto ? &h_payto : NULL, &record_cb, transfers); query = "select_exchange_debit_transfers"; @@ -161,6 +168,7 @@ aml_transfer_get ( &threshold, offset, limit, + have_payto ? &h_payto : NULL, &record_cb, transfers); query = "select_exchange_credit_transfers"; @@ -171,6 +179,7 @@ aml_transfer_get ( &threshold, offset, limit, + have_payto ? &h_payto : NULL, &record_cb, transfers); query = "select_exchange_kycauth_transfers"; diff --git a/src/exchangedb/pg_select_exchange_credit_transfers.c b/src/exchangedb/pg_select_exchange_credit_transfers.c @@ -112,6 +112,7 @@ TEH_PG_select_exchange_credit_transfers ( const struct TALER_Amount *threshold, uint64_t offset, int64_t limit, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlTransferCallback cb, void *cb_cls) { @@ -128,6 +129,9 @@ TEH_PG_select_exchange_credit_transfers ( GNUNET_PQ_query_param_uint64 (&ulimit), TALER_PQ_query_param_amount (pg->conn, threshold), + NULL != h_payto + ? GNUNET_PQ_query_param_auto_from_type (h_payto) + : GNUNET_PQ_query_param_null (), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; @@ -143,6 +147,7 @@ TEH_PG_select_exchange_credit_transfers ( " LEFT JOIN wire_targets wt" " ON (ri.wire_source_h_payto = wt.wire_target_h_payto)" " WHERE (ri.reserve_in_serial_id > $1)" + " AND ( ($4::BYTEA IS NULL) OR (wt.h_normalized_payto=$4) )" " AND ( ( (ri.credit).val > ($3::taler_amount).val)" " OR ( ( (ri.credit).val >= ($3::taler_amount).val)" " AND ( (ri.credit).frac >= ($3::taler_amount).frac) ) )" @@ -159,6 +164,7 @@ TEH_PG_select_exchange_credit_transfers ( " LEFT JOIN wire_targets wt" " ON (ri.wire_source_h_payto = wt.wire_target_h_payto)" " WHERE (ri.reserve_in_serial_id < $1)" + " AND ( ($4::BYTEA IS NULL) OR (wt.h_normalized_payto=$4) )" " AND ( ( (ri.credit).val > ($3::taler_amount).val)" " OR ( ( (ri.credit).val >= ($3::taler_amount).val)" " AND ( (ri.credit).frac >= ($3::taler_amount).frac) ) )" diff --git a/src/exchangedb/pg_select_exchange_credit_transfers.h b/src/exchangedb/pg_select_exchange_credit_transfers.h @@ -33,6 +33,7 @@ * @param threshold minimum wire amount to return data for * @param offset offset in table to filter by * @param limit maximum number of entries to return, negative for descending + * @param h_payto account to filter transfer data by * @param cb function to call on each result * @param cb_cls closure to pass to @a cb * @return transaction status @@ -43,6 +44,7 @@ TEH_PG_select_exchange_credit_transfers ( const struct TALER_Amount *threshold, uint64_t offset, int64_t limit, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlTransferCallback cb, void *cb_cls); diff --git a/src/exchangedb/pg_select_exchange_debit_transfers.c b/src/exchangedb/pg_select_exchange_debit_transfers.c @@ -113,6 +113,7 @@ TEH_PG_select_exchange_debit_transfers ( const struct TALER_Amount *threshold, uint64_t offset, int64_t limit, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlTransferCallback cb, void *cb_cls) { @@ -129,6 +130,9 @@ TEH_PG_select_exchange_debit_transfers ( GNUNET_PQ_query_param_uint64 (&ulimit), TALER_PQ_query_param_amount (pg->conn, threshold), + NULL != h_payto + ? GNUNET_PQ_query_param_auto_from_type (h_payto) + : GNUNET_PQ_query_param_null (), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; @@ -144,6 +148,7 @@ TEH_PG_select_exchange_debit_transfers ( " LEFT JOIN wire_targets wt" " USING (wire_target_h_payto)" " WHERE (wo.wireout_uuid > $1)" + " AND ( ($4::BYTEA IS NULL) OR (wt.h_normalized_payto=$4) )" " AND ( ( (wo.amount).val > ($3::taler_amount).val)" " OR ( ( (wo.amount).val >= ($3::taler_amount).val)" " AND ( (wo.amount).frac >= ($3::taler_amount).frac) ) )" @@ -160,6 +165,7 @@ TEH_PG_select_exchange_debit_transfers ( " LEFT JOIN wire_targets wt" " USING (wire_target_h_payto)" " WHERE (wo.wireout_uuid < $1)" + " AND ( ($4::BYTEA IS NULL) OR (wt.h_normalized_payto=$4) )" " AND ( ( (wo.amount).val > ($3::taler_amount).val)" " OR ( ( (wo.amount).val >= ($3::taler_amount).val)" " AND ( (wo.amount).frac >= ($3::taler_amount).frac) ) )" diff --git a/src/exchangedb/pg_select_exchange_debit_transfers.h b/src/exchangedb/pg_select_exchange_debit_transfers.h @@ -32,6 +32,7 @@ * @param threshold minimum wire amount to return data for * @param offset offset in table to filter by * @param limit maximum number of entries to return, negative for descending + * @param h_payto account to filter transfer data by * @param cb function to call on each result * @param cb_cls closure to pass to @a cb * @return transaction status @@ -42,6 +43,7 @@ TEH_PG_select_exchange_debit_transfers ( const struct TALER_Amount *threshold, uint64_t offset, int64_t limit, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlTransferCallback cb, void *cb_cls); diff --git a/src/exchangedb/pg_select_exchange_kycauth_transfers.c b/src/exchangedb/pg_select_exchange_kycauth_transfers.c @@ -112,6 +112,7 @@ TEH_PG_select_exchange_kycauth_transfers ( const struct TALER_Amount *threshold, uint64_t offset, int64_t limit, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlTransferCallback cb, void *cb_cls) { @@ -128,6 +129,9 @@ TEH_PG_select_exchange_kycauth_transfers ( GNUNET_PQ_query_param_uint64 (&ulimit), TALER_PQ_query_param_amount (pg->conn, threshold), + NULL != h_payto + ? GNUNET_PQ_query_param_auto_from_type (h_payto) + : GNUNET_PQ_query_param_null (), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; @@ -143,6 +147,7 @@ TEH_PG_select_exchange_kycauth_transfers ( " LEFT JOIN wire_targets wt" " ON (ki.wire_source_h_payto = wt.wire_target_h_payto)" " WHERE (ki.reserve_in_serial_id > $1)" + " AND ( ($4::BYTEA IS NULL) OR (wt.h_normalized_payto=$4) )" " AND ( ( (ki.credit).val > ($3::taler_amount).val)" " OR ( ( (ki.credit).val >= ($3::taler_amount).val)" " AND ( (ki.credit).frac >= ($3::taler_amount).frac) ) )" @@ -159,6 +164,7 @@ TEH_PG_select_exchange_kycauth_transfers ( " LEFT JOIN wire_targets wt" " ON (ki.wire_source_h_payto = wt.wire_target_h_payto)" " WHERE (ki.kycauth_in_serial_id < $1)" + " AND ( ($4::BYTEA IS NULL) OR (wt.h_normalized_payto=$4) )" " AND ( ( (ki.credit).val > ($3::taler_amount).val)" " OR ( ( (ki.credit).val >= ($3::taler_amount).val)" " AND ( (ki.credit).frac >= ($3::taler_amount).frac) ) )" diff --git a/src/exchangedb/pg_select_exchange_kycauth_transfers.h b/src/exchangedb/pg_select_exchange_kycauth_transfers.h @@ -33,6 +33,7 @@ * @param threshold minimum wire amount to return data for * @param offset offset in table to filter by * @param limit maximum number of entries to return, negative for descending + * @param h_payto account to filter transfer data by * @param cb function to call on each result * @param cb_cls closure to pass to @a cb * @return transaction status @@ -43,6 +44,7 @@ TEH_PG_select_exchange_kycauth_transfers ( const struct TALER_Amount *threshold, uint64_t offset, int64_t limit, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlTransferCallback cb, void *cb_cls); diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h @@ -8012,6 +8012,7 @@ struct TALER_EXCHANGEDB_Plugin * @param threshold minimum wire amount to return data for * @param offset offset in table to filter by * @param limit maximum number of entries to return, negative for descending + * @param h_payto account to filter transfer data by * @param cb function to call on each result * @param cb_cls closure to pass to @a cb * @return transaction status @@ -8022,6 +8023,7 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_Amount *threshold, uint64_t offset, int64_t limit, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlTransferCallback cb, void *cb_cls); @@ -8033,6 +8035,7 @@ struct TALER_EXCHANGEDB_Plugin * @param threshold minimum wire amount to return data for * @param offset offset in table to filter by * @param limit maximum number of entries to return, negative for descending + * @param h_payto account to filter transfer data by * @param cb function to call on each result * @param cb_cls closure to pass to @a cb * @return transaction status @@ -8043,6 +8046,7 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_Amount *threshold, uint64_t offset, int64_t limit, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlTransferCallback cb, void *cb_cls); @@ -8054,6 +8058,7 @@ struct TALER_EXCHANGEDB_Plugin * @param threshold minimum wire amount to return data for * @param offset offset in table to filter by * @param limit maximum number of entries to return, negative for descending + * @param h_payto account to filter transfer data by * @param cb function to call on each result * @param cb_cls closure to pass to @a cb * @return transaction status @@ -8064,6 +8069,7 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_Amount *threshold, uint64_t offset, int64_t limit, + const struct TALER_NormalizedPaytoHashP *h_payto, TALER_EXCHANGEDB_AmlTransferCallback cb, void *cb_cls);