diff options
309 files changed, 23530 insertions, 282 deletions
diff --git a/src/auditor/Makefile.am b/src/auditor/Makefile.am index a7d593725..2b9f459ed 100644 --- a/src/auditor/Makefile.am +++ b/src/auditor/Makefile.am @@ -202,6 +202,72 @@ taler_auditor_httpd_SOURCES = \ taler-auditor-httpd_refreshes-hanging-put.c taler-auditor-httpd_refreshes-hanging-put.h \ taler-auditor-httpd_refreshes-hanging-get.c taler-auditor-httpd_refreshes-hanging-get.h \ taler-auditor-httpd_refreshes-hanging-del.c taler-auditor-httpd_refreshes-hanging-del.h \ + taler-auditor-httpd_emergency-by-count-upd.c taler-auditor-httpd_emergency-by-count-upd.h \ + taler-auditor-httpd_row-inconsistency-upd.c taler-auditor-httpd_row-inconsistency-upd.h \ + taler-auditor-httpd_purse-not-closed-inconsistencies-upd.c taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h \ + taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.c taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h \ + taler-auditor-httpd_coin-inconsistency-upd.c taler-auditor-httpd_coin-inconsistency-upd.h \ + taler-auditor-httpd_progress-upd.c taler-auditor-httpd_progress-upd.h \ + taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.c taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h \ + taler-auditor-httpd_refreshes-hanging-upd.c taler-auditor-httpd_refreshes-hanging-upd.h \ + taler-auditor-httpd_emergency-upd.c taler-auditor-httpd_emergency-upd.h \ + taler-auditor-httpd_closure-lags-upd.c taler-auditor-httpd_closure-lags-upd.h \ +taler-auditor-httpd_reserve-in-inconsistency-del.c taler-auditor-httpd_reserve-in-inconsistency-del.h \ +taler-auditor-httpd_reserve-in-inconsistency-put.c taler-auditor-httpd_reserve-in-inconsistency-put.h \ +taler-auditor-httpd_reserve-in-inconsistency-get.c taler-auditor-httpd_reserve-in-inconsistency-get.h \ +taler-auditor-httpd_reserve-in-inconsistency-upd.c taler-auditor-httpd_reserve-in-inconsistency-upd.h \ +taler-auditor-httpd_reserve-not-closed-inconsistency-del.c taler-auditor-httpd_reserve-not-closed-inconsistency-del.h \ +taler-auditor-httpd_reserve-not-closed-inconsistency-put.c taler-auditor-httpd_reserve-not-closed-inconsistency-put.h \ +taler-auditor-httpd_reserve-not-closed-inconsistency-get.c taler-auditor-httpd_reserve-not-closed-inconsistency-get.h \ +taler-auditor-httpd_reserve-not-closed-inconsistency-upd.c taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h \ +taler-auditor-httpd_denominations-without-sigs-del.c taler-auditor-httpd_denominations-without-sigs-del.h \ +taler-auditor-httpd_denominations-without-sigs-put.c taler-auditor-httpd_denominations-without-sigs-put.h \ +taler-auditor-httpd_denominations-without-sigs-get.c taler-auditor-httpd_denominations-without-sigs-get.h \ +taler-auditor-httpd_denominations-without-sigs-upd.c taler-auditor-httpd_denominations-without-sigs-upd.h \ +taler-auditor-httpd_misattribution-in-inconsistency-del.c taler-auditor-httpd_misattribution-in-inconsistency-del.h \ +taler-auditor-httpd_misattribution-in-inconsistency-put.c taler-auditor-httpd_misattribution-in-inconsistency-put.h \ +taler-auditor-httpd_misattribution-in-inconsistency-get.c taler-auditor-httpd_misattribution-in-inconsistency-get.h \ +taler-auditor-httpd_misattribution-in-inconsistency-upd.c taler-auditor-httpd_misattribution-in-inconsistency-upd.h \ +taler-auditor-httpd_reserves-del.c taler-auditor-httpd_reserves-del.h \ +taler-auditor-httpd_reserves-put.c taler-auditor-httpd_reserves-put.h \ +taler-auditor-httpd_reserves-get.c taler-auditor-httpd_reserves-get.h \ +taler-auditor-httpd_reserves-upd.c taler-auditor-httpd_reserves-upd.h \ +taler-auditor-httpd_purses-del.c taler-auditor-httpd_purses-del.h \ +taler-auditor-httpd_purses-put.c taler-auditor-httpd_purses-put.h \ +taler-auditor-httpd_purses-get.c taler-auditor-httpd_purses-get.h \ +taler-auditor-httpd_purses-upd.c taler-auditor-httpd_purses-upd.h \ +taler-auditor-httpd_historic-denomination-revenue-del.c taler-auditor-httpd_historic-denomination-revenue-del.h \ +taler-auditor-httpd_historic-denomination-revenue-put.c taler-auditor-httpd_historic-denomination-revenue-put.h \ +taler-auditor-httpd_historic-denomination-revenue-get.c taler-auditor-httpd_historic-denomination-revenue-get.h \ +taler-auditor-httpd_historic-denomination-revenue-upd.c taler-auditor-httpd_historic-denomination-revenue-upd.h \ +taler-auditor-httpd_denomination-pending-del.c taler-auditor-httpd_denomination-pending-del.h \ +taler-auditor-httpd_denomination-pending-put.c taler-auditor-httpd_denomination-pending-put.h \ +taler-auditor-httpd_denomination-pending-get.c taler-auditor-httpd_denomination-pending-get.h \ +taler-auditor-httpd_denomination-pending-upd.c taler-auditor-httpd_denomination-pending-upd.h \ +taler-auditor-httpd_historic-reserve-summary-del.c taler-auditor-httpd_historic-reserve-summary-del.h \ +taler-auditor-httpd_historic-reserve-summary-put.c taler-auditor-httpd_historic-reserve-summary-put.h \ +taler-auditor-httpd_historic-reserve-summary-get.c taler-auditor-httpd_historic-reserve-summary-get.h \ +taler-auditor-httpd_historic-reserve-summary-upd.c taler-auditor-httpd_historic-reserve-summary-upd.h \ +taler-auditor-httpd_exchange-signkeys-del.c taler-auditor-httpd_exchange-signkeys-del.h \ +taler-auditor-httpd_exchange-signkeys-put.c taler-auditor-httpd_exchange-signkeys-put.h \ +taler-auditor-httpd_exchange-signkeys-get.c taler-auditor-httpd_exchange-signkeys-get.h \ +taler-auditor-httpd_exchange-signkeys-upd.c taler-auditor-httpd_exchange-signkeys-upd.h \ +taler-auditor-httpd_wire-format-inconsistency-del.c taler-auditor-httpd_wire-format-inconsistency-del.h \ +taler-auditor-httpd_wire-format-inconsistency-put.c taler-auditor-httpd_wire-format-inconsistency-put.h \ +taler-auditor-httpd_wire-format-inconsistency-get.c taler-auditor-httpd_wire-format-inconsistency-get.h \ +taler-auditor-httpd_wire-format-inconsistency-upd.c taler-auditor-httpd_wire-format-inconsistency-upd.h \ +taler-auditor-httpd_wire-out-inconsistency-del.c taler-auditor-httpd_wire-out-inconsistency-del.h \ +taler-auditor-httpd_wire-out-inconsistency-put.c taler-auditor-httpd_wire-out-inconsistency-put.h \ +taler-auditor-httpd_wire-out-inconsistency-get.c taler-auditor-httpd_wire-out-inconsistency-get.h \ +taler-auditor-httpd_wire-out-inconsistency-upd.c taler-auditor-httpd_wire-out-inconsistency-upd.h \ +taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.c taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.h \ +taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.c taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.h \ +taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h \ +taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.c taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h \ +taler-auditor-httpd_row-minor-inconsistencies-del.c taler-auditor-httpd_row-minor-inconsistencies-del.h \ +taler-auditor-httpd_row-minor-inconsistencies-put.c taler-auditor-httpd_row-minor-inconsistencies-put.h \ +taler-auditor-httpd_row-minor-inconsistencies-get.c taler-auditor-httpd_row-minor-inconsistencies-get.h \ +taler-auditor-httpd_row-minor-inconsistencies-upd.c taler-auditor-httpd_row-minor-inconsistencies-upd.h \ taler-auditor-httpd_mhd.c taler-auditor-httpd_mhd.h taler_auditor_httpd_LDADD = \ $(LIBGCRYPT_LIBS) \ diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index 13ecc6d6c..34c057228 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -86,6 +86,101 @@ #include "taler-auditor-httpd_mhd.h" #include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_emergency-by-count-upd.h" +#include "taler-auditor-httpd_row-inconsistency-upd.h" +#include "taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h" +#include "taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h" +#include "taler-auditor-httpd_coin-inconsistency-upd.h" +#include "taler-auditor-httpd_progress-upd.h" +#include "taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h" +#include "taler-auditor-httpd_refreshes-hanging-upd.h" +#include "taler-auditor-httpd_emergency-upd.h" +#include "taler-auditor-httpd_closure-lags-upd.h" +#include "taler-auditor-httpd_row-minor-inconsistencies-upd.h" + +#include "taler-auditor-httpd_reserve-in-inconsistency-del.h" +#include "taler-auditor-httpd_reserve-in-inconsistency-put.h" +#include "taler-auditor-httpd_reserve-in-inconsistency-get.h" +#include "taler-auditor-httpd_reserve-in-inconsistency-upd.h" + + +#include "taler-auditor-httpd_reserve-not-closed-inconsistency-del.h" +#include "taler-auditor-httpd_reserve-not-closed-inconsistency-put.h" +#include "taler-auditor-httpd_reserve-not-closed-inconsistency-get.h" +#include "taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h" + + +#include "taler-auditor-httpd_denominations-without-sigs-del.h" +#include "taler-auditor-httpd_denominations-without-sigs-put.h" +#include "taler-auditor-httpd_denominations-without-sigs-get.h" +#include "taler-auditor-httpd_denominations-without-sigs-upd.h" + + +#include "taler-auditor-httpd_misattribution-in-inconsistency-del.h" +#include "taler-auditor-httpd_misattribution-in-inconsistency-put.h" +#include "taler-auditor-httpd_misattribution-in-inconsistency-get.h" +#include "taler-auditor-httpd_misattribution-in-inconsistency-upd.h" + + +#include "taler-auditor-httpd_reserves-del.h" +#include "taler-auditor-httpd_reserves-put.h" +#include "taler-auditor-httpd_reserves-get.h" +#include "taler-auditor-httpd_reserves-upd.h" + + +#include "taler-auditor-httpd_purses-del.h" +#include "taler-auditor-httpd_purses-put.h" +#include "taler-auditor-httpd_purses-get.h" +#include "taler-auditor-httpd_purses-upd.h" + + +#include "taler-auditor-httpd_historic-denomination-revenue-del.h" +#include "taler-auditor-httpd_historic-denomination-revenue-put.h" +#include "taler-auditor-httpd_historic-denomination-revenue-get.h" +#include "taler-auditor-httpd_historic-denomination-revenue-upd.h" + + +#include "taler-auditor-httpd_denomination-pending-del.h" +#include "taler-auditor-httpd_denomination-pending-put.h" +#include "taler-auditor-httpd_denomination-pending-get.h" +#include "taler-auditor-httpd_denomination-pending-upd.h" + + +#include "taler-auditor-httpd_historic-reserve-summary-del.h" +#include "taler-auditor-httpd_historic-reserve-summary-put.h" +#include "taler-auditor-httpd_historic-reserve-summary-get.h" +#include "taler-auditor-httpd_historic-reserve-summary-upd.h" + + +#include "taler-auditor-httpd_exchange-signkeys-del.h" +#include "taler-auditor-httpd_exchange-signkeys-put.h" +#include "taler-auditor-httpd_exchange-signkeys-get.h" +#include "taler-auditor-httpd_exchange-signkeys-upd.h" + + +#include "taler-auditor-httpd_wire-format-inconsistency-del.h" +#include "taler-auditor-httpd_wire-format-inconsistency-put.h" +#include "taler-auditor-httpd_wire-format-inconsistency-get.h" +#include "taler-auditor-httpd_wire-format-inconsistency-upd.h" + + +#include "taler-auditor-httpd_wire-out-inconsistency-del.h" +#include "taler-auditor-httpd_wire-out-inconsistency-put.h" +#include "taler-auditor-httpd_wire-out-inconsistency-get.h" +#include "taler-auditor-httpd_wire-out-inconsistency-upd.h" + + +#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.h" +#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.h" +#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h" +#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h" + + +#include "taler-auditor-httpd_row-minor-inconsistencies-del.h" +#include "taler-auditor-httpd_row-minor-inconsistencies-put.h" +#include "taler-auditor-httpd_row-minor-inconsistencies-get.h" +#include "taler-auditor-httpd_row-minor-inconsistencies-upd.h" + /** * Auditor protocol version string. * @@ -353,6 +448,481 @@ handle_mhd_request (void *cls, &TAH_BAD_SIG_LOSSES_handler_update, MHD_HTTP_OK }, + { "/closure-lags", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_CLOSURE_LAGS_handler_get, + MHD_HTTP_OK }, + { "/closure-lags", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_CLOSURE_LAGS_PUT_handler, + MHD_HTTP_OK }, + { "/closure-lags", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_CLOSURE_LAGS_handler_delete, + MHD_HTTP_OK }, + { "/closure-lags", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_CLOSURE_LAGS_handler_update, + MHD_HTTP_OK }, + + { "/emergency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_EMERGENCY_handler_get, + MHD_HTTP_OK }, + { "/emergency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_EMERGENCY_PUT_handler, + MHD_HTTP_OK }, + { "/emergency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_EMERGENCY_handler_delete, + MHD_HTTP_OK }, + { "/emergency", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_EMERGENCY_handler_update, + MHD_HTTP_OK }, + + { "/refreshes-hanging", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_REFRESHES_HANGING_handler_get, + MHD_HTTP_OK }, + { "/refreshes-hanging", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_REFRESHES_HANGING_PUT_handler, + MHD_HTTP_OK }, + { "/refreshes-hanging", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_REFRESHES_HANGING_handler_delete, + MHD_HTTP_OK }, + { "/refreshes-hanging", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_REFRESHES_HANGING_handler_update, + MHD_HTTP_OK }, + + { "/denomination-key-validity-withdraw-inconsistency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_get, + MHD_HTTP_OK }, + { "/denomination-key-validity-withdraw-inconsistency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_PUT_handler, + MHD_HTTP_OK }, + { "/denomination-key-validity-withdraw-inconsistency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_delete, + MHD_HTTP_OK }, + { "/denomination-key-validity-withdraw-inconsistency", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_update, + MHD_HTTP_OK }, + + { "/progress", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_PROGRESS_handler_get, + MHD_HTTP_OK }, + { "/progress", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_PROGRESS_PUT_handler, + MHD_HTTP_OK }, + { "/progress", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_PROGRESS_handler_delete, + MHD_HTTP_OK }, + { "/progress", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_PROGRESS_handler_update, + MHD_HTTP_OK }, + + { "/reserve-balance-insufficient-inconsistency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_get, + MHD_HTTP_OK }, + { "/reserve-balance-insufficient-inconsistency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_put, + MHD_HTTP_OK }, + { "/reserve-balance-insufficient-inconsistency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_delete, + MHD_HTTP_OK }, + { "/reserve-balance-insufficient-inconsistency", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_update, + MHD_HTTP_OK }, + + { "/purse-not-closed-inconsistencies", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_get, + MHD_HTTP_OK }, + { "/purse-not-closed-inconsistencies", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_PUT_handler, + MHD_HTTP_OK }, + { "/purse-not-closed-inconsistencies", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_delete, + MHD_HTTP_OK }, + { "/purse-not-closed-inconsistencies", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_update, + MHD_HTTP_OK }, + + { "/emergency-by-count", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_EMERGENCY_BY_COUNT_handler_get, + MHD_HTTP_OK }, + { "/emergency-by-count", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_EMERGENCY_BY_COUNT_PUT_handler, + MHD_HTTP_OK }, + { "/emergency-by-count", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_EMERGENCY_BY_COUNT_handler_delete, + MHD_HTTP_OK }, + { "/emergency-by-count", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_EMERGENCY_BY_COUNT_handler_update, + MHD_HTTP_OK }, + + { "/reserve-in-inconsistency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_RESERVE_IN_INCONSISTENCY_handler_get, + MHD_HTTP_OK }, + { "/reserve-in-inconsistency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_RESERVE_IN_INCONSISTENCY_handler_put, + MHD_HTTP_OK }, + { "/reserve-in-inconsistency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_RESERVE_IN_INCONSISTENCY_handler_delete, + MHD_HTTP_OK }, + { "/reserve-in-inconsistency", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_RESERVE_IN_INCONSISTENCY_handler_update, + MHD_HTTP_OK }, + + + { "/reserve-not-closed-inconsistency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_get, + MHD_HTTP_OK }, + { "/reserve-not-closed-inconsistency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_put, + MHD_HTTP_OK }, + { "/reserve-not-closed-inconsistency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_delete, + MHD_HTTP_OK }, + { "/reserve-not-closed-inconsistency", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_update, + MHD_HTTP_OK }, + + + { "/denominations-without-sigs", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_DENOMINATIONS_WITHOUT_SIGS_handler_get, + MHD_HTTP_OK }, + { "/denominations-without-sigs", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_DENOMINATIONS_WITHOUT_SIGS_handler_put, + MHD_HTTP_OK }, + { "/denominations-without-sigs", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_DENOMINATIONS_WITHOUT_SIGS_handler_delete, + MHD_HTTP_OK }, + { "/denominations-without-sigs", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_DENOMINATIONS_WITHOUT_SIGS_handler_update, + MHD_HTTP_OK }, + + + { "/misattribution-in-inconsistency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_get, + MHD_HTTP_OK }, + { "/misattribution-in-inconsistency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_put, + MHD_HTTP_OK }, + { "/misattribution-in-inconsistency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_delete, + MHD_HTTP_OK }, + { "/misattribution-in-inconsistency", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_update, + MHD_HTTP_OK }, + + + { "/reserves", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_RESERVES_handler_get, + MHD_HTTP_OK }, + { "/reserves", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_RESERVES_handler_put, + MHD_HTTP_OK }, + { "/reserves", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_RESERVES_handler_delete, + MHD_HTTP_OK }, + { "/reserves", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_RESERVES_handler_update, + MHD_HTTP_OK }, + + + { "/purses", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_PURSES_handler_get, + MHD_HTTP_OK }, + { "/purses", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_PURSES_handler_put, + MHD_HTTP_OK }, + { "/purses", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_PURSES_handler_delete, + MHD_HTTP_OK }, + { "/purses", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_PURSES_handler_update, + MHD_HTTP_OK }, + + + { "/historic-denomination-revenue", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_HISTORIC_DENOMINATION_REVENUE_handler_get, + MHD_HTTP_OK }, + { "/historic-denomination-revenue", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_HISTORIC_DENOMINATION_REVENUE_handler_put, + MHD_HTTP_OK }, + { "/historic-denomination-revenue", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_HISTORIC_DENOMINATION_REVENUE_handler_delete, + MHD_HTTP_OK }, + { "/historic-denomination-revenue", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_HISTORIC_DENOMINATION_REVENUE_handler_update, + MHD_HTTP_OK }, + + + { "/denomination-pending", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_DENOMINATION_PENDING_handler_get, + MHD_HTTP_OK }, + { "/denomination-pending", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_DENOMINATION_PENDING_handler_put, + MHD_HTTP_OK }, + { "/denomination-pending", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_DENOMINATION_PENDING_handler_delete, + MHD_HTTP_OK }, + { "/denomination-pending", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_DENOMINATION_PENDING_handler_update, + MHD_HTTP_OK }, + + + { "/historic-reserve-summary", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_HISTORIC_RESERVE_SUMMARY_handler_get, + MHD_HTTP_OK }, + { "/historic-reserve-summary", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_HISTORIC_RESERVE_SUMMARY_handler_put, + MHD_HTTP_OK }, + { "/historic-reserve-summary", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_HISTORIC_RESERVE_SUMMARY_handler_delete, + MHD_HTTP_OK }, + { "/historic-reserve-summary", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_HISTORIC_RESERVE_SUMMARY_handler_update, + MHD_HTTP_OK }, + + + { "/exchange-signkeys", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_EXCHANGE_SIGNKEYS_handler_get, + MHD_HTTP_OK }, + { "/exchange-signkeys", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_EXCHANGE_SIGNKEYS_handler_put, + MHD_HTTP_OK }, + { "/exchange-signkeys", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_EXCHANGE_SIGNKEYS_handler_delete, + MHD_HTTP_OK }, + { "/exchange-signkeys", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_EXCHANGE_SIGNKEYS_handler_update, + MHD_HTTP_OK }, + + + { "/wire-format-inconsistency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_WIRE_FORMAT_INCONSISTENCY_handler_get, + MHD_HTTP_OK }, + { "/wire-format-inconsistency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_WIRE_FORMAT_INCONSISTENCY_handler_put, + MHD_HTTP_OK }, + { "/wire-format-inconsistency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_WIRE_FORMAT_INCONSISTENCY_handler_delete, + MHD_HTTP_OK }, + { "/wire-format-inconsistency", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_WIRE_FORMAT_INCONSISTENCY_handler_update, + MHD_HTTP_OK }, + + + { "/wire-out-inconsistency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_WIRE_OUT_INCONSISTENCY_handler_get, + MHD_HTTP_OK }, + { "/wire-out-inconsistency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_WIRE_OUT_INCONSISTENCY_handler_put, + MHD_HTTP_OK }, + { "/wire-out-inconsistency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_WIRE_OUT_INCONSISTENCY_handler_delete, + MHD_HTTP_OK }, + { "/wire-out-inconsistency", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_WIRE_OUT_INCONSISTENCY_handler_update, + MHD_HTTP_OK }, + + + { "/reserve-balance-summary-wrong-inconsistency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_get, + MHD_HTTP_OK }, + { "/reserve-balance-summary-wrong-inconsistency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_put, + MHD_HTTP_OK }, + { "/reserve-balance-summary-wrong-inconsistency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_delete, + MHD_HTTP_OK }, + { "/reserve-balance-summary-wrong-inconsistency", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_update, + MHD_HTTP_OK }, + + + { "/row-minor-inconsistencies", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_ROW_MINOR_INCONSISTENCIES_handler_get, + MHD_HTTP_OK }, + { "/row-minor-inconsistencies", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_ROW_MINOR_INCONSISTENCIES_handler_put, + MHD_HTTP_OK }, + { "/row-minor-inconsistencies", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_ROW_MINOR_INCONSISTENCIES_handler_delete, + MHD_HTTP_OK }, + { "/row-minor-inconsistencies", MHD_HTTP_METHOD_PATCH, + "application/json", + NULL, 0, + &TAH_ROW_MINOR_INCONSISTENCIES_handler_update, + MHD_HTTP_OK }, + { "/config", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, &handle_config, MHD_HTTP_OK }, diff --git a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c index ee9e709e3..d9edc0662 100644 --- a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c @@ -87,18 +87,28 @@ TAH_AMOUNT_ARITHMETIC_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, ja = json_array (); GNUNET_break (NULL != ja); - uint64_t row_id = 0; - bool return_suppressed; + int64_t limit = -20; + uint64_t offset; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_end () - }; + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json @@ -134,7 +144,8 @@ TAH_AMOUNT_ARITHMETIC_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, qs = TAH_plugin->get_amount_arithmetic_inconsistency ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &add_amount_arithmetic_inconsistency, ja); diff --git a/src/auditor/taler-auditor-httpd_bad-sig-losses-get.c b/src/auditor/taler-auditor-httpd_bad-sig-losses-get.c index 300a3b61a..7b586346e 100644 --- a/src/auditor/taler-auditor-httpd_bad-sig-losses-get.c +++ b/src/auditor/taler-auditor-httpd_bad-sig-losses-get.c @@ -49,8 +49,7 @@ add_bad_sig_losses (void *cls, GNUNET_JSON_pack_uint64 ("row_id", serial_id), GNUNET_JSON_pack_string ("operation", dc->operation), TALER_JSON_pack_amount ("loss", &dc->loss), - GNUNET_JSON_pack_data_auto ("operation_specific_pub", - &dc->operation_specific_pub) + GNUNET_JSON_pack_data_auto ("operation_specific_pub", &dc->operation_specific_pub) ); GNUNET_break (0 == json_array_append_new (list, diff --git a/src/auditor/taler-auditor-httpd_bad-sig-losses-put.c b/src/auditor/taler-auditor-httpd_bad-sig-losses-put.c index 25b533bf7..a8d85a821 100644 --- a/src/auditor/taler-auditor-httpd_bad-sig-losses-put.c +++ b/src/auditor/taler-auditor-httpd_bad-sig-losses-put.c @@ -92,8 +92,7 @@ TAH_BAD_SIG_LOSSES_PUT_handler ( GNUNET_JSON_spec_string ("operation", (const char **) &dc.operation), TALER_JSON_spec_amount ("loss", TAH_currency, &dc.loss), - GNUNET_JSON_spec_fixed_auto ("operation_specific_pub", - &dc.operation_specific_pub), + GNUNET_JSON_spec_fixed_auto ("operation_specific_pub", &dc.operation_specific_pub), GNUNET_JSON_spec_end () diff --git a/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.c b/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.c index dff5373da..09b37e766 100644 --- a/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.c +++ b/src/auditor/taler-auditor-httpd_bad-sig-losses-upd.c @@ -24,7 +24,7 @@ #include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_bad-sig-losses-put.h" +#include "taler-auditor-httpd_bad-sig-losses-upd.h" MHD_RESULT TAH_BAD_SIG_LOSSES_handler_update ( diff --git a/src/auditor/taler-auditor-httpd_closure-lags-get.c b/src/auditor/taler-auditor-httpd_closure-lags-get.c index a41385406..b43cf7afa 100644 --- a/src/auditor/taler-auditor-httpd_closure-lags-get.c +++ b/src/auditor/taler-auditor-httpd_closure-lags-get.c @@ -102,20 +102,28 @@ TAH_CLOSURE_LAGS_handler_get (struct TAH_RequestHandler *rh, } ja = json_array (); GNUNET_break (NULL != ja); + int64_t limit = -20; + uint64_t offset; - uint64_t row_id = 0; - bool return_suppressed; + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + TALER_MHD_parse_request_number (connection, + "offset", + &offset); - GNUNET_JSON_spec_end () - }; + bool return_suppressed = false; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json json_t *json_in; @@ -149,7 +157,8 @@ TAH_CLOSURE_LAGS_handler_get (struct TAH_RequestHandler *rh, qs = TAH_plugin->get_auditor_closure_lags ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &process_closure_lags, ja); diff --git a/src/auditor/taler-auditor-httpd_closure-lags-upd.c b/src/auditor/taler-auditor-httpd_closure-lags-upd.c new file mode 100644 index 000000000..2cf86ecd5 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_closure-lags-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_closure-lags-upd.h" + +MHD_RESULT +TAH_CLOSURE_LAGS_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_closure_lags (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_closure-lags-upd.h b/src/auditor/taler-auditor-httpd_closure-lags-upd.h new file mode 100644 index 000000000..98ae29800 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_closure-lags-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_CLOSURE_LAGS_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_CLOSURE_LAGS_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_CLOSURE_LAGS_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_CLOSURE_LAGS_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c b/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c index ca08f7d4c..84f7a6f60 100644 --- a/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c @@ -31,8 +31,6 @@ add_coin_inconsistency (void *cls, json_t *list = cls; json_t *obj; - printf ("checkpoint pg_3\n"); - obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("operation", &dc->operation), TALER_JSON_pack_amount ("exchange_amount", &dc->exchange_amount), @@ -45,7 +43,7 @@ add_coin_inconsistency (void *cls, json_array_append_new (list, obj)); - printf ("checkpoint pg_4\n"); + return GNUNET_OK; } @@ -87,19 +85,28 @@ TAH_COIN_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, } ja = json_array (); GNUNET_break (NULL != ja); + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - uint64_t row_id = 0; - bool return_suppressed; + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_number (connection, + "offset", + &offset); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + bool return_suppressed = false; - GNUNET_JSON_spec_end () - }; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json @@ -132,11 +139,11 @@ TAH_COIN_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, } } - printf ("checkpoint httpd\n"); qs = TAH_plugin->get_coin_inconsistency ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &add_coin_inconsistency, ja); diff --git a/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.c new file mode 100644 index 000000000..b8e9abbbc --- /dev/null +++ b/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_coin-inconsistency-upd.h" + +MHD_RESULT +TAH_COIN_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_coin_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.h new file mode 100644 index 000000000..c0ad19143 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_coin-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_COIN_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_COIN_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_COIN_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_COIN_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.c b/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.c index 545827888..c1db6627c 100644 --- a/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.c @@ -107,19 +107,28 @@ TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_get (struct } ja = json_array (); GNUNET_break (NULL != ja); + int64_t limit = -20; + uint64_t offset; - uint64_t row_id = 0; - bool return_suppressed; + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + TALER_MHD_parse_request_number (connection, + "offset", + &offset); - GNUNET_JSON_spec_end () - }; + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json @@ -154,7 +163,8 @@ TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_get (struct qs = TAH_plugin->get_denomination_key_validity_withdraw_inconsistency ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &process_denomination_key_validity_withdraw_inconsistency, ja); diff --git a/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.c new file mode 100644 index 000000000..9ff522b8e --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h" + +MHD_RESULT +TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_denomination_key_validity_withdraw_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h new file mode 100644 index 000000000..e5e175f15 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-del.c b/src/auditor/taler-auditor-httpd_denomination-pending-del.c new file mode 100644 index 000000000..9436cb612 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-pending-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_denomination-pending-del.h" + + +MHD_RESULT +TAH_DENOMINATION_PENDING_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_denomination_pending (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /denomination-pending/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "DENOMINATION_PENDING_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-del.h b/src/auditor/taler-auditor-httpd_denomination-pending-del.h new file mode 100644 index 000000000..a58896b47 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-pending-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_DENOMINATION_PENDING_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_DENOMINATION_PENDING_DELETE_done (void); + +/** + * Handle a "/denomination-pending" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_DENOMINATION_PENDING_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-get.c b/src/auditor/taler-auditor-httpd_denomination-pending-get.c new file mode 100644 index 000000000..9b37a837f --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-pending-get.c @@ -0,0 +1,189 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_denomination-pending-get.h" + +/** +* Add denomination-pending to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_denomination_pending (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_DenominationPending + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_data_auto("denom_pub_hash", &dc->denom_pub_hash), +TALER_JSON_pack_amount("denom_balance", &dc->denom_balance), +TALER_JSON_pack_amount("denom_loss", &dc->denom_loss), +GNUNET_JSON_pack_int64("num_issued", dc->num_issued), +TALER_JSON_pack_amount("denom_risk", &dc->denom_risk), +TALER_JSON_pack_amount("recoup_loss", &dc->recoup_loss), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_DENOMINATION_PENDING_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_denomination_pending ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_denomination_pending, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /denomination-pending"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "denomination-pending"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("denomination-pending", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-get.h b/src/auditor/taler-auditor-httpd_denomination-pending-get.h new file mode 100644 index 000000000..a76cb0599 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-pending-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_GET_H +#define SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_DENOMINATION_PENDING_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_DENOMINATION_PENDING_GET_done (void); + +/** +* Handle a "/denomination-pending" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_DENOMINATION_PENDING_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-put.c b/src/auditor/taler-auditor-httpd_denomination-pending-put.c new file mode 100644 index 000000000..6d271ada8 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-pending-put.c @@ -0,0 +1,165 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_denomination-pending-put.h" + +/** +* We have parsed the JSON information about the denomination-pending, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the denomination-pending +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_DenominationPending *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_denomination_pending (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /denomination-pending in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "denomination-pending"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "DENOMINATION_PENDING_OK")); +} + + +MHD_RESULT +TAH_DENOMINATION_PENDING_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_DenominationPending dc; + + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_fixed_auto("denom_pub_hash", &dc.denom_pub_hash), +TALER_JSON_spec_amount("denom_balance", TAH_currency, &dc.denom_balance), +TALER_JSON_spec_amount("denom_loss", TAH_currency, &dc.denom_loss), +GNUNET_JSON_spec_int64("num_issued", &dc.num_issued), +TALER_JSON_spec_amount("denom_risk", TAH_currency, &dc.denom_risk), +TALER_JSON_spec_amount("recoup_loss", TAH_currency, &dc.recoup_loss), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_DENOMINATION_PENDING_PUT_init (void) +{ + +} + + +void +TEAH_DENOMINATION_PENDING_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-put.h b/src/auditor/taler-auditor-httpd_denomination-pending-put.h new file mode 100644 index 000000000..3af8f4eee --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-pending-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_DENOMINATION_PENDING_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_DENOMINATION_PENDING_done (void); + + +/** +* Handle a "/denomination-pending" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_DENOMINATION_PENDING_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-upd.c b/src/auditor/taler-auditor-httpd_denomination-pending-upd.c new file mode 100644 index 000000000..e2f9fa635 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-pending-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_denomination-pending-upd.h" + +MHD_RESULT +TAH_DENOMINATION_PENDING_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_denomination_pending (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denomination-pending-upd.h b/src/auditor/taler-auditor-httpd_denomination-pending-upd.h new file mode 100644 index 000000000..023f99e6e --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denomination-pending-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_DENOMINATION_PENDING_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_DENOMINATION_PENDING_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-del.c b/src/auditor/taler-auditor-httpd_denominations-without-sigs-del.c new file mode 100644 index 000000000..7cb06eb05 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denominations-without-sigs-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_denominations-without-sigs-del.h" + + +MHD_RESULT +TAH_DENOMINATIONS_WITHOUT_SIGS_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_denominations_without_sigs (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /denominations-without-sigs/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "DENOMINATIONS_WITHOUT_SIGS_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-del.h b/src/auditor/taler-auditor-httpd_denominations-without-sigs-del.h new file mode 100644 index 000000000..bb72a6e57 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denominations-without-sigs-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_DENOMINATIONS_WITHOUT_SIGS_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_DENOMINATIONS_WITHOUT_SIGS_DELETE_done (void); + +/** + * Handle a "/denominations-without-sigs" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_DENOMINATIONS_WITHOUT_SIGS_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-get.c b/src/auditor/taler-auditor-httpd_denominations-without-sigs-get.c new file mode 100644 index 000000000..35ae885b8 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denominations-without-sigs-get.c @@ -0,0 +1,188 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_denominations-without-sigs-get.h" + +/** +* Add denominations-without-sigs to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_denominations_without_sigs (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_DenominationsWithoutSigs + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("row_id", serial_id), +GNUNET_JSON_pack_data_auto("denompub_h", &dc->denompub_h), +TALER_JSON_pack_amount("value", &dc->value), +GNUNET_JSON_pack_int64("start_time", dc->start_time), +GNUNET_JSON_pack_int64("end_time", dc->end_time), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_DENOMINATIONS_WITHOUT_SIGS_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_denominations_without_sigs ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_denominations_without_sigs, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /denominations-without-sigs"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "denominations-without-sigs"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("denominations-without-sigs", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-get.h b/src/auditor/taler-auditor-httpd_denominations-without-sigs-get.h new file mode 100644 index 000000000..f908e346a --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denominations-without-sigs-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_GET_H +#define SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_DENOMINATIONS_WITHOUT_SIGS_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_DENOMINATIONS_WITHOUT_SIGS_GET_done (void); + +/** +* Handle a "/denominations-without-sigs" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_DENOMINATIONS_WITHOUT_SIGS_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-put.c b/src/auditor/taler-auditor-httpd_denominations-without-sigs-put.c new file mode 100644 index 000000000..0a7a1b1f3 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denominations-without-sigs-put.c @@ -0,0 +1,163 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_denominations-without-sigs-put.h" + +/** +* We have parsed the JSON information about the denominations-without-sigs, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the denominations-without-sigs +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_denominations_without_sigs (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /denominations-without-sigs in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "denominations-without-sigs"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "DENOMINATIONS_WITHOUT_SIGS_OK")); +} + + +MHD_RESULT +TAH_DENOMINATIONS_WITHOUT_SIGS_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_DenominationsWithoutSigs dc; + + + struct GNUNET_JSON_Specification spec[] = { + +GNUNET_JSON_spec_fixed_auto("denompub_h", &dc.denompub_h), +TALER_JSON_spec_amount("value", TAH_currency, &dc.value), +GNUNET_JSON_spec_int64("start_time", &dc.start_time), +GNUNET_JSON_spec_int64("end_time", &dc.end_time), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_DENOMINATIONS_WITHOUT_SIGS_PUT_init (void) +{ + +} + + +void +TEAH_DENOMINATIONS_WITHOUT_SIGS_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-put.h b/src/auditor/taler-auditor-httpd_denominations-without-sigs-put.h new file mode 100644 index 000000000..0c9f921cb --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denominations-without-sigs-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_DENOMINATIONS_WITHOUT_SIGS_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_DENOMINATIONS_WITHOUT_SIGS_done (void); + + +/** +* Handle a "/denominations-without-sigs" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_DENOMINATIONS_WITHOUT_SIGS_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.c b/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.c new file mode 100644 index 000000000..3a2a9749b --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_denominations-without-sigs-upd.h" + +MHD_RESULT +TAH_DENOMINATIONS_WITHOUT_SIGS_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_denominations_without_sigs (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.h b/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.h new file mode 100644 index 000000000..736c089a4 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_denominations-without-sigs-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_DENOMINATIONS_WITHOUT_SIGS_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_DENOMINATIONS_WITHOUT_SIGS_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_emergency-by-count-get.c b/src/auditor/taler-auditor-httpd_emergency-by-count-get.c index 2ae783aad..e4f9f65ba 100644 --- a/src/auditor/taler-auditor-httpd_emergency-by-count-get.c +++ b/src/auditor/taler-auditor-httpd_emergency-by-count-get.c @@ -107,18 +107,28 @@ TAH_EMERGENCY_BY_COUNT_handler_get (struct TAH_RequestHandler *rh, ja = json_array (); GNUNET_break (NULL != ja); - uint64_t row_id = 0; - bool return_suppressed; + int64_t limit = -20; + uint64_t offset; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_end () - }; + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json @@ -153,7 +163,8 @@ TAH_EMERGENCY_BY_COUNT_handler_get (struct TAH_RequestHandler *rh, qs = TAH_plugin->get_emergency_by_count ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &process_emergency_by_count, ja); diff --git a/src/auditor/taler-auditor-httpd_emergency-by-count-upd.c b/src/auditor/taler-auditor-httpd_emergency-by-count-upd.c new file mode 100644 index 000000000..892f2a29e --- /dev/null +++ b/src/auditor/taler-auditor-httpd_emergency-by-count-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_emergency-by-count-upd.h" + +MHD_RESULT +TAH_EMERGENCY_BY_COUNT_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_emergency_by_count (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_emergency-by-count-upd.h b/src/auditor/taler-auditor-httpd_emergency-by-count-upd.h new file mode 100644 index 000000000..4f5247884 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_emergency-by-count-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_EMERGENCY_BY_COUNT_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_EMERGENCY_BY_COUNT_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_EMERGENCY_BY_COUNT_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_EMERGENCY_BY_COUNT_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_emergency-get.c b/src/auditor/taler-auditor-httpd_emergency-get.c index c9fd03673..64db84857 100644 --- a/src/auditor/taler-auditor-httpd_emergency-get.c +++ b/src/auditor/taler-auditor-httpd_emergency-get.c @@ -107,18 +107,28 @@ TAH_EMERGENCY_handler_get (struct TAH_RequestHandler *rh, ja = json_array (); GNUNET_break (NULL != ja); - uint64_t row_id = 0; - bool return_suppressed; + int64_t limit = -20; + uint64_t offset; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_end () - }; + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json @@ -153,7 +163,8 @@ TAH_EMERGENCY_handler_get (struct TAH_RequestHandler *rh, qs = TAH_plugin->get_emergency ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &process_emergency, ja); diff --git a/src/auditor/taler-auditor-httpd_emergency-upd.c b/src/auditor/taler-auditor-httpd_emergency-upd.c new file mode 100644 index 000000000..f53a7748d --- /dev/null +++ b/src/auditor/taler-auditor-httpd_emergency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_emergency-upd.h" + +MHD_RESULT +TAH_EMERGENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_emergency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_emergency-upd.h b/src/auditor/taler-auditor-httpd_emergency-upd.h new file mode 100644 index 000000000..6e5186f3f --- /dev/null +++ b/src/auditor/taler-auditor-httpd_emergency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_EMERGENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_EMERGENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_EMERGENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_EMERGENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_exchange-signkeys-del.c b/src/auditor/taler-auditor-httpd_exchange-signkeys-del.c new file mode 100644 index 000000000..7ff5c2fd6 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_exchange-signkeys-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_exchange-signkeys-del.h" + + +MHD_RESULT +TAH_EXCHANGE_SIGNKEYS_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_exchange_signkeys (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /exchange-signkeys/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "EXCHANGE_SIGNKEYS_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_exchange-signkeys-del.h b/src/auditor/taler-auditor-httpd_exchange-signkeys-del.h new file mode 100644 index 000000000..a61821476 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_exchange-signkeys-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_EXCHANGE_SIGNKEYS_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_EXCHANGE_SIGNKEYS_DELETE_done (void); + +/** + * Handle a "/exchange-signkeys" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_EXCHANGE_SIGNKEYS_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_exchange-signkeys-get.c b/src/auditor/taler-auditor-httpd_exchange-signkeys-get.c new file mode 100644 index 000000000..7f7ba049a --- /dev/null +++ b/src/auditor/taler-auditor-httpd_exchange-signkeys-get.c @@ -0,0 +1,188 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_exchange-signkeys-get.h" + +/** +* Add exchange-signkeys to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_exchange_signkeys (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_ExchangeSignkeys + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_data_auto("exchange_pub", &dc->exchange_pub), +GNUNET_JSON_pack_data_auto("master_sig", &dc->master_sig), +GNUNET_JSON_pack_int64("ep_valid_from", dc->ep_valid_from), +GNUNET_JSON_pack_int64("ep_expire_sign", dc->ep_expire_sign), +GNUNET_JSON_pack_int64("ep_expire_legal", dc->ep_expire_legal), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_EXCHANGE_SIGNKEYS_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_exchange_signkeys ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_exchange_signkeys, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /exchange-signkeys"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "exchange-signkeys"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("exchange-signkeys", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_exchange-signkeys-get.h b/src/auditor/taler-auditor-httpd_exchange-signkeys-get.h new file mode 100644 index 000000000..2532c0ac7 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_exchange-signkeys-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_GET_H +#define SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_EXCHANGE_SIGNKEYS_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_EXCHANGE_SIGNKEYS_GET_done (void); + +/** +* Handle a "/exchange-signkeys" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_EXCHANGE_SIGNKEYS_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_exchange-signkeys-put.c b/src/auditor/taler-auditor-httpd_exchange-signkeys-put.c new file mode 100644 index 000000000..8e6d7a8ee --- /dev/null +++ b/src/auditor/taler-auditor-httpd_exchange-signkeys-put.c @@ -0,0 +1,164 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_exchange-signkeys-put.h" + +/** +* We have parsed the JSON information about the exchange-signkeys, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the exchange-signkeys +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_ExchangeSignkeys *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_exchange_signkeys (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /exchange-signkeys in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "exchange-signkeys"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "EXCHANGE_SIGNKEYS_OK")); +} + + +MHD_RESULT +TAH_EXCHANGE_SIGNKEYS_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_ExchangeSignkeys dc; + + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_fixed_auto("exchange_pub", &dc.exchange_pub), +GNUNET_JSON_spec_fixed_auto("master_sig", &dc.master_sig), +GNUNET_JSON_spec_int64("ep_valid_from", &dc.ep_valid_from), +GNUNET_JSON_spec_int64("ep_expire_sign", &dc.ep_expire_sign), +GNUNET_JSON_spec_int64("ep_expire_legal", &dc.ep_expire_legal), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_EXCHANGE_SIGNKEYS_PUT_init (void) +{ + +} + + +void +TEAH_EXCHANGE_SIGNKEYS_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_exchange-signkeys-put.h b/src/auditor/taler-auditor-httpd_exchange-signkeys-put.h new file mode 100644 index 000000000..b890010ab --- /dev/null +++ b/src/auditor/taler-auditor-httpd_exchange-signkeys-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_EXCHANGE_SIGNKEYS_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_EXCHANGE_SIGNKEYS_done (void); + + +/** +* Handle a "/exchange-signkeys" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_EXCHANGE_SIGNKEYS_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_exchange-signkeys-upd.c b/src/auditor/taler-auditor-httpd_exchange-signkeys-upd.c new file mode 100644 index 000000000..c76a0e18b --- /dev/null +++ b/src/auditor/taler-auditor-httpd_exchange-signkeys-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_exchange-signkeys-upd.h" + +MHD_RESULT +TAH_EXCHANGE_SIGNKEYS_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_exchange_signkeys (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_exchange-signkeys-upd.h b/src/auditor/taler-auditor-httpd_exchange-signkeys-upd.h new file mode 100644 index 000000000..87978573d --- /dev/null +++ b/src/auditor/taler-auditor-httpd_exchange-signkeys-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_EXCHANGE_SIGNKEYS_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_EXCHANGE_SIGNKEYS_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_fee-time-inconsistency-get.c b/src/auditor/taler-auditor-httpd_fee-time-inconsistency-get.c index ea01dfd45..e0a368035 100644 --- a/src/auditor/taler-auditor-httpd_fee-time-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_fee-time-inconsistency-get.c @@ -100,19 +100,28 @@ TAH_FEE_TIME_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, ja = json_array (); GNUNET_break (NULL != ja); - uint64_t row_id = 0; - bool return_suppressed; + int64_t limit = -20; + uint64_t offset; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_end () - }; + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json json_t *json_in; @@ -146,7 +155,8 @@ TAH_FEE_TIME_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, qs = TAH_plugin->get_fee_time_inconsistency ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &add_fee_time_inconsistency, ja); diff --git a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-del.c b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-del.c new file mode 100644 index 000000000..e9c3eba90 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_historic-denomination-revenue-del.h" + + +MHD_RESULT +TAH_HISTORIC_DENOMINATION_REVENUE_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_historic_denomination_revenue (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /historic-denomination-revenue/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "HISTORIC_DENOMINATION_REVENUE_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-del.h b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-del.h new file mode 100644 index 000000000..d9684a61d --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_HISTORIC_DENOMINATION_REVENUE_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_HISTORIC_DENOMINATION_REVENUE_DELETE_done (void); + +/** + * Handle a "/historic-denomination-revenue" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_HISTORIC_DENOMINATION_REVENUE_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.c b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.c new file mode 100644 index 000000000..af3a84784 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.c @@ -0,0 +1,187 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_historic-denomination-revenue-get.h" + +/** +* Add historic-denomination-revenue to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_historic_denomination_revenue (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_HistoricDenominationRevenue + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_data_auto("denom_pub_hash", &dc->denom_pub_hash), +GNUNET_JSON_pack_int64("revenue_timestamp", dc->revenue_timestamp), +TALER_JSON_pack_amount("revenue_balance", &dc->revenue_balance), +TALER_JSON_pack_amount("loss_balance", &dc->loss_balance), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_HISTORIC_DENOMINATION_REVENUE_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_historic_denomination_revenue ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_historic_denomination_revenue, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /historic-denomination-revenue"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "historic-denomination-revenue"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("historic-denomination-revenue", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.h b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.h new file mode 100644 index 000000000..90bb6069f --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_GET_H +#define SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_HISTORIC_DENOMINATION_REVENUE_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_HISTORIC_DENOMINATION_REVENUE_GET_done (void); + +/** +* Handle a "/historic-denomination-revenue" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_HISTORIC_DENOMINATION_REVENUE_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-put.c b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-put.c new file mode 100644 index 000000000..938507c14 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-put.c @@ -0,0 +1,163 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_historic-denomination-revenue-put.h" + +/** +* We have parsed the JSON information about the historic-denomination-revenue, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the historic-denomination-revenue +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_historic_denomination_revenue (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /historic-denomination-revenue in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "historic-denomination-revenue"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "HISTORIC_DENOMINATION_REVENUE_OK")); +} + + +MHD_RESULT +TAH_HISTORIC_DENOMINATION_REVENUE_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_HistoricDenominationRevenue dc; + + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_fixed_auto("denom_pub_hash", &dc.denom_pub_hash), +GNUNET_JSON_spec_int64("revenue_timestamp", &dc.revenue_timestamp), +TALER_JSON_spec_amount("revenue_balance", TAH_currency, &dc.revenue_balance), +TALER_JSON_spec_amount("loss_balance", TAH_currency, &dc.loss_balance), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_HISTORIC_DENOMINATION_REVENUE_PUT_init (void) +{ + +} + + +void +TEAH_HISTORIC_DENOMINATION_REVENUE_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-put.h b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-put.h new file mode 100644 index 000000000..f2f904594 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_HISTORIC_DENOMINATION_REVENUE_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_HISTORIC_DENOMINATION_REVENUE_done (void); + + +/** +* Handle a "/historic-denomination-revenue" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_HISTORIC_DENOMINATION_REVENUE_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-upd.c b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-upd.c new file mode 100644 index 000000000..1f01d5ce4 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_historic-denomination-revenue-upd.h" + +MHD_RESULT +TAH_HISTORIC_DENOMINATION_REVENUE_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_historic_denomination_revenue (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-denomination-revenue-upd.h b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-upd.h new file mode 100644 index 000000000..226c50dd5 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-denomination-revenue-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_HISTORIC_DENOMINATION_REVENUE_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_HISTORIC_DENOMINATION_REVENUE_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-reserve-summary-del.c b/src/auditor/taler-auditor-httpd_historic-reserve-summary-del.c new file mode 100644 index 000000000..373d5d12f --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-reserve-summary-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_historic-reserve-summary-del.h" + + +MHD_RESULT +TAH_HISTORIC_RESERVE_SUMMARY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_historic_reserve_summary (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /historic-reserve-summary/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "HISTORIC_RESERVE_SUMMARY_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-reserve-summary-del.h b/src/auditor/taler-auditor-httpd_historic-reserve-summary-del.h new file mode 100644 index 000000000..e6c2a270f --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-reserve-summary-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_HISTORIC_RESERVE_SUMMARY_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_HISTORIC_RESERVE_SUMMARY_DELETE_done (void); + +/** + * Handle a "/historic-reserve-summary" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_HISTORIC_RESERVE_SUMMARY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.c b/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.c new file mode 100644 index 000000000..f6f2ad8e3 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.c @@ -0,0 +1,186 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_historic-reserve-summary-get.h" + +/** +* Add historic-reserve-summary to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_historic_reserve_summary (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_HistoricReserveSummary + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("start_date", dc->start_date), +GNUNET_JSON_pack_int64("end_date", dc->end_date), +TALER_JSON_pack_amount("reserve_profits", &dc->reserve_profits), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_HISTORIC_RESERVE_SUMMARY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_historic_reserve_summary ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_historic_reserve_summary, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /historic-reserve-summary"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "historic-reserve-summary"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("historic-reserve-summary", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.h b/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.h new file mode 100644 index 000000000..76b012650 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-reserve-summary-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_GET_H +#define SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_HISTORIC_RESERVE_SUMMARY_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_HISTORIC_RESERVE_SUMMARY_GET_done (void); + +/** +* Handle a "/historic-reserve-summary" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_HISTORIC_RESERVE_SUMMARY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-reserve-summary-put.c b/src/auditor/taler-auditor-httpd_historic-reserve-summary-put.c new file mode 100644 index 000000000..89d9c5100 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-reserve-summary-put.c @@ -0,0 +1,162 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_historic-reserve-summary-put.h" + +/** +* We have parsed the JSON information about the historic-reserve-summary, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the historic-reserve-summary +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_HistoricReserveSummary *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_historic_reserve_summary (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /historic-reserve-summary in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "historic-reserve-summary"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "HISTORIC_RESERVE_SUMMARY_OK")); +} + + +MHD_RESULT +TAH_HISTORIC_RESERVE_SUMMARY_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_HistoricReserveSummary dc; + + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_int64("start_date", &dc.start_date), +GNUNET_JSON_spec_int64("end_date", &dc.end_date), +TALER_JSON_spec_amount("reserve_profits", TAH_currency, &dc.reserve_profits), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_HISTORIC_RESERVE_SUMMARY_PUT_init (void) +{ + +} + + +void +TEAH_HISTORIC_RESERVE_SUMMARY_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-reserve-summary-put.h b/src/auditor/taler-auditor-httpd_historic-reserve-summary-put.h new file mode 100644 index 000000000..cbe19a697 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-reserve-summary-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_HISTORIC_RESERVE_SUMMARY_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_HISTORIC_RESERVE_SUMMARY_done (void); + + +/** +* Handle a "/historic-reserve-summary" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_HISTORIC_RESERVE_SUMMARY_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-reserve-summary-upd.c b/src/auditor/taler-auditor-httpd_historic-reserve-summary-upd.c new file mode 100644 index 000000000..0a79f94fb --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-reserve-summary-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_historic-reserve-summary-upd.h" + +MHD_RESULT +TAH_HISTORIC_RESERVE_SUMMARY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_historic_reserve_summary (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_historic-reserve-summary-upd.h b/src/auditor/taler-auditor-httpd_historic-reserve-summary-upd.h new file mode 100644 index 000000000..907de2c44 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_historic-reserve-summary-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_HISTORIC_RESERVE_SUMMARY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_HISTORIC_RESERVE_SUMMARY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-del.c b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-del.c new file mode 100644 index 000000000..128b9a42a --- /dev/null +++ b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_misattribution-in-inconsistency-del.h" + + +MHD_RESULT +TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_misattribution_in_inconsistency (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /misattribution-in-inconsistency/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "MISATTRIBUTION_IN_INCONSISTENCY_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-del.h b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-del.h new file mode 100644 index 000000000..b0136b676 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_MISATTRIBUTION_IN_INCONSISTENCY_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_MISATTRIBUTION_IN_INCONSISTENCY_DELETE_done (void); + +/** + * Handle a "/misattribution-in-inconsistency" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-get.c b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-get.c new file mode 100644 index 000000000..268c58636 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-get.c @@ -0,0 +1,187 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_misattribution-in-inconsistency-get.h" + +/** +* Add misattribution-in-inconsistency to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_misattribution_in_inconsistency (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_MisattributionInInconsistency + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("row_id", serial_id), +TALER_JSON_pack_amount("amount", &dc->amount), +GNUNET_JSON_pack_int64("bank_row", dc->bank_row), +GNUNET_JSON_pack_data_auto("reserve_pub", &dc->reserve_pub), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_misattribution_in_inconsistency ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_misattribution_in_inconsistency, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /misattribution-in-inconsistency"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "misattribution-in-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("misattribution-in-inconsistency", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-get.h b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-get.h new file mode 100644 index 000000000..f4ba8557a --- /dev/null +++ b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_GET_H +#define SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_MISATTRIBUTION_IN_INCONSISTENCY_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_MISATTRIBUTION_IN_INCONSISTENCY_GET_done (void); + +/** +* Handle a "/misattribution-in-inconsistency" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-put.c b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-put.c new file mode 100644 index 000000000..99bfd48ed --- /dev/null +++ b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-put.c @@ -0,0 +1,162 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_misattribution-in-inconsistency-put.h" + +/** +* We have parsed the JSON information about the misattribution-in-inconsistency, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the misattribution-in-inconsistency +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_MisattributionInInconsistency *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_misattribution_in_inconsistency (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /misattribution-in-inconsistency in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "misattribution-in-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "MISATTRIBUTION_IN_INCONSISTENCY_OK")); +} + + +MHD_RESULT +TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_MisattributionInInconsistency dc; + + + struct GNUNET_JSON_Specification spec[] = { + +TALER_JSON_spec_amount("amount", TAH_currency, &dc.amount), +GNUNET_JSON_spec_int64("bank_row", &dc.bank_row), +GNUNET_JSON_spec_fixed_auto("reserve_pub", &dc.reserve_pub), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_MISATTRIBUTION_IN_INCONSISTENCY_PUT_init (void) +{ + +} + + +void +TEAH_MISATTRIBUTION_IN_INCONSISTENCY_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-put.h b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-put.h new file mode 100644 index 000000000..c2d3aa9f9 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_MISATTRIBUTION_IN_INCONSISTENCY_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_MISATTRIBUTION_IN_INCONSISTENCY_done (void); + + +/** +* Handle a "/misattribution-in-inconsistency" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.c new file mode 100644 index 000000000..d86645ff9 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_misattribution-in-inconsistency-upd.h" + +MHD_RESULT +TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_misattribution_in_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.h new file mode 100644 index 000000000..9839ca1b6 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_misattribution-in-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_MISATTRIBUTION_IN_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_MISATTRIBUTION_IN_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_progress-get.c b/src/auditor/taler-auditor-httpd_progress-get.c index c4abc9710..2ebc8976b 100644 --- a/src/auditor/taler-auditor-httpd_progress-get.c +++ b/src/auditor/taler-auditor-httpd_progress-get.c @@ -96,18 +96,28 @@ TAH_PROGRESS_handler_get (struct TAH_RequestHandler *rh, ja = json_array (); GNUNET_break (NULL != ja); - uint64_t row_id = 0; - bool return_suppressed; + int64_t limit = -20; + uint64_t offset; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_end () - }; + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json @@ -142,7 +152,8 @@ TAH_PROGRESS_handler_get (struct TAH_RequestHandler *rh, qs = TAH_plugin->get_progress ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &process_progress, ja); diff --git a/src/auditor/taler-auditor-httpd_progress-upd.c b/src/auditor/taler-auditor-httpd_progress-upd.c new file mode 100644 index 000000000..906644138 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_progress-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_progress-upd.h" + +MHD_RESULT +TAH_PROGRESS_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_progress (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_progress-upd.h b/src/auditor/taler-auditor-httpd_progress-upd.h new file mode 100644 index 000000000..ca435db2d --- /dev/null +++ b/src/auditor/taler-auditor-httpd_progress-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_PROGRESS_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_PROGRESS_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_PROGRESS_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_PROGRESS_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-get.c b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-get.c index 3c434f8e4..ef60854a4 100644 --- a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-get.c +++ b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-get.c @@ -103,19 +103,28 @@ TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_get (struct TAH_RequestHandler *rh, ja = json_array (); GNUNET_break (NULL != ja); - uint64_t row_id = 0; - bool return_suppressed; + int64_t limit = -20; + uint64_t offset; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_end () - }; + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json json_t *json_in; @@ -149,7 +158,8 @@ TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_get (struct TAH_RequestHandler *rh, qs = TAH_plugin->get_purse_not_closed_inconsistencies ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &process_purse_not_closed_inconsistencies, ja); diff --git a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.c b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.c new file mode 100644 index 000000000..226f9ea2f --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h" + +MHD_RESULT +TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_purse_not_closed_inconsistencies (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h new file mode 100644 index 000000000..fb6928e7f --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purse-not-closed-inconsistencies-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_PURSE_NOT_CLOSED_INCONSISTENCIES_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_PURSE_NOT_CLOSED_INCONSISTENCIES_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_PURSE_NOT_CLOSED_INCONSISTENCIES_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_PURSE_NOT_CLOSED_INCONSISTENCIES_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purses-del.c b/src/auditor/taler-auditor-httpd_purses-del.c new file mode 100644 index 000000000..da81e3b59 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purses-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_purses-del.h" + + +MHD_RESULT +TAH_PURSES_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_purses (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /purses/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "PURSES_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purses-del.h b/src/auditor/taler-auditor-httpd_purses-del.h new file mode 100644 index 000000000..f797c5161 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purses-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_PURSES_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_PURSES_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_PURSES_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_PURSES_DELETE_done (void); + +/** + * Handle a "/purses" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_PURSES_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_PURSES_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purses-get.c b/src/auditor/taler-auditor-httpd_purses-get.c new file mode 100644 index 000000000..20d97ac83 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purses-get.c @@ -0,0 +1,188 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_purses-get.h" + +/** +* Add purses to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_purses (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_Purses + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("auditor_purses_rowid", dc->auditor_purses_rowid), +GNUNET_JSON_pack_data_auto("purse_pub", &dc->purse_pub), +TALER_JSON_pack_amount("balance", &dc->balance), +TALER_JSON_pack_amount("target", &dc->target), +GNUNET_JSON_pack_int64("expiration_date", dc->expiration_date), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_PURSES_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_purses ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_purses, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /purses"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "purses"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("purses", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purses-get.h b/src/auditor/taler-auditor-httpd_purses-get.h new file mode 100644 index 000000000..ba607b438 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purses-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_PURSES_GET_H +#define SRC_TALER_AUDITOR_HTTPD_PURSES_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_PURSES_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_PURSES_GET_done (void); + +/** +* Handle a "/purses" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_PURSES_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_PURSES_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purses-put.c b/src/auditor/taler-auditor-httpd_purses-put.c new file mode 100644 index 000000000..c5edd2c91 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purses-put.c @@ -0,0 +1,164 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_purses-put.h" + +/** +* We have parsed the JSON information about the purses, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the purses +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_Purses *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_purses (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /purses in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "purses"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "PURSES_OK")); +} + + +MHD_RESULT +TAH_PURSES_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_Purses dc; + + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_int64("auditor_purses_rowid", &dc.auditor_purses_rowid), +GNUNET_JSON_spec_fixed_auto("purse_pub", &dc.purse_pub), +TALER_JSON_spec_amount("balance", TAH_currency, &dc.balance), +TALER_JSON_spec_amount("target", TAH_currency, &dc.target), +GNUNET_JSON_spec_int64("expiration_date", &dc.expiration_date), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_PURSES_PUT_init (void) +{ + +} + + +void +TEAH_PURSES_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purses-put.h b/src/auditor/taler-auditor-httpd_purses-put.h new file mode 100644 index 000000000..fc4a9c73e --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purses-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_PURSES_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_PURSES_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_PURSES_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_PURSES_done (void); + + +/** +* Handle a "/purses" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_PURSES_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_PURSES_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purses-upd.c b/src/auditor/taler-auditor-httpd_purses-upd.c new file mode 100644 index 000000000..7c188de2e --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purses-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_purses-upd.h" + +MHD_RESULT +TAH_PURSES_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_purses (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_purses-upd.h b/src/auditor/taler-auditor-httpd_purses-upd.h new file mode 100644 index 000000000..d4f9cf8fd --- /dev/null +++ b/src/auditor/taler-auditor-httpd_purses-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_PURSES_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_PURSES_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_PURSES_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_PURSES_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_refreshes-hanging-get.c b/src/auditor/taler-auditor-httpd_refreshes-hanging-get.c index 2a7c8ae42..d8654d2c8 100644 --- a/src/auditor/taler-auditor-httpd_refreshes-hanging-get.c +++ b/src/auditor/taler-auditor-httpd_refreshes-hanging-get.c @@ -99,18 +99,28 @@ TAH_REFRESHES_HANGING_handler_get (struct TAH_RequestHandler *rh, ja = json_array (); GNUNET_break (NULL != ja); - uint64_t row_id = 0; - bool return_suppressed; + int64_t limit = -20; + uint64_t offset; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_end () - }; + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json @@ -145,7 +155,8 @@ TAH_REFRESHES_HANGING_handler_get (struct TAH_RequestHandler *rh, qs = TAH_plugin->get_refreshes_hanging ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &process_refreshes_hanging, ja); diff --git a/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.c b/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.c new file mode 100644 index 000000000..bf7bd8ea1 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_refreshes-hanging-upd.h" + +MHD_RESULT +TAH_REFRESHES_HANGING_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_refreshes_hanging (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.h b/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.h new file mode 100644 index 000000000..b928bc6d4 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_refreshes-hanging-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_REFRESHES_HANGING_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_REFRESHES_HANGING_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_REFRESHES_HANGING_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_REFRESHES_HANGING_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c index 799d47a87..cad7f0b43 100644 --- a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c @@ -110,18 +110,28 @@ TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_get (struct ja = json_array (); GNUNET_break (NULL != ja); - uint64_t row_id = 0; - bool return_suppressed; + int64_t limit = -20; + uint64_t offset; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_end () - }; + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json @@ -156,7 +166,8 @@ TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_get (struct qs = TAH_plugin->get_reserve_balance_insufficient_inconsistency ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &process_reserve_balance_insufficient_inconsistency, ja); diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.c new file mode 100644 index 000000000..124efd6dc --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h" + +MHD_RESULT +TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_reserve_balance_insufficient_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h new file mode 100644 index 000000000..6955ea8f7 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.c b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.c new file mode 100644 index 000000000..071dcbe9d --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.h" + + +MHD_RESULT +TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_reserve_balance_summary_wrong_inconsistency (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /reserve-balance-summary-wrong-inconsistency/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.h b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.h new file mode 100644 index 000000000..d0a362663 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_DELETE_done (void); + +/** + * Handle a "/reserve-balance-summary-wrong-inconsistency" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c new file mode 100644 index 000000000..212b58852 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.c @@ -0,0 +1,187 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h" + +/** +* Add reserve-balance-summary-wrong-inconsistency to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_reserve_balance_summary_wrong_inconsistency (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("row_id", serial_id), +GNUNET_JSON_pack_data_auto("reserve_pub", &dc->reserve_pub), +TALER_JSON_pack_amount("exchange_amount", &dc->exchange_amount), +TALER_JSON_pack_amount("auditor_amount", &dc->auditor_amount), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_reserve_balance_summary_wrong_inconsistency ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_reserve_balance_summary_wrong_inconsistency, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /reserve-balance-summary-wrong-inconsistency"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "reserve-balance-summary-wrong-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("reserve-balance-summary-wrong-inconsistency", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h new file mode 100644 index 000000000..bef81ee1a --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_GET_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_GET_done (void); + +/** +* Handle a "/reserve-balance-summary-wrong-inconsistency" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.c b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.c new file mode 100644 index 000000000..df6cac9b4 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.c @@ -0,0 +1,162 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.h" + +/** +* We have parsed the JSON information about the reserve-balance-summary-wrong-inconsistency, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the reserve-balance-summary-wrong-inconsistency +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_reserve_balance_summary_wrong_inconsistency (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /reserve-balance-summary-wrong-inconsistency in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "reserve-balance-summary-wrong-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_OK")); +} + + +MHD_RESULT +TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency dc; + + + struct GNUNET_JSON_Specification spec[] = { + +GNUNET_JSON_spec_fixed_auto("reserve_pub", &dc.reserve_pub), +TALER_JSON_spec_amount("exchange_amount", TAH_currency, &dc.exchange_amount), +TALER_JSON_spec_amount("auditor_amount", TAH_currency, &dc.auditor_amount), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_PUT_init (void) +{ + +} + + +void +TEAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.h b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.h new file mode 100644 index 000000000..8df20f12e --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_done (void); + + +/** +* Handle a "/reserve-balance-summary-wrong-inconsistency" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.c new file mode 100644 index 000000000..df8ee3e1c --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h" + +MHD_RESULT +TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_reserve_balance_summary_wrong_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h new file mode 100644 index 000000000..dc4626cb4 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-balance-summary-wrong-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-del.c b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-del.c new file mode 100644 index 000000000..0fb10be55 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_reserve-in-inconsistency-del.h" + + +MHD_RESULT +TAH_RESERVE_IN_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_reserve_in_inconsistency (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /reserve-in-inconsistency/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "RESERVE_IN_INCONSISTENCY_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-del.h b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-del.h new file mode 100644 index 000000000..4d4dfe087 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_RESERVE_IN_INCONSISTENCY_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_RESERVE_IN_INCONSISTENCY_DELETE_done (void); + +/** + * Handle a "/reserve-in-inconsistency" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_RESERVE_IN_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c new file mode 100644 index 000000000..55773073f --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.c @@ -0,0 +1,190 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-in-inconsistency-get.h" + +/** +* Add reserve-in-inconsistency to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_reserve_in_inconsistency (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_ReserveInInconsistency + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("row_id", serial_id), +TALER_JSON_pack_amount("amount_exchange_expected", &dc->amount_exchange_expected), +TALER_JSON_pack_amount("amount_wired", &dc->amount_wired), + GNUNET_JSON_pack_data_auto("reserve_pub", &dc->reserve_pub), +GNUNET_JSON_pack_int64("timestamp", dc->timestamp), +GNUNET_JSON_pack_string("account", dc->account), +GNUNET_JSON_pack_string("diagnostic", dc->diagnostic), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVE_IN_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_reserve_in_inconsistency ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_reserve_in_inconsistency, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /reserve-in-inconsistency"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "reserve-in-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("reserve-in-inconsistency", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.h b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.h new file mode 100644 index 000000000..06d5b8917 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_GET_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_RESERVE_IN_INCONSISTENCY_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_RESERVE_IN_INCONSISTENCY_GET_done (void); + +/** +* Handle a "/reserve-in-inconsistency" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVE_IN_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-put.c b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-put.c new file mode 100644 index 000000000..e5d57243c --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-put.c @@ -0,0 +1,166 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-in-inconsistency-put.h" + +/** +* We have parsed the JSON information about the reserve-in-inconsistency, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the reserve-in-inconsistency +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_ReserveInInconsistency *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_reserve_in_inconsistency (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /reserve-in-inconsistency in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "reserve-in-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "RESERVE_IN_INCONSISTENCY_OK")); +} + + +MHD_RESULT +TAH_RESERVE_IN_INCONSISTENCY_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_ReserveInInconsistency dc; + + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_int64("row_id", dc.row_id), +TALER_JSON_spec_amount("amount_exchange_expected", TAH_currency, &dc.amount_exchange_expected), +TALER_JSON_spec_amount("amount_wired", TAH_currency, &dc.amount_wired), +GNUNET_JSON_spec_fixed_auto("reserve_pub", &dc.reserve_pub), +GNUNET_JSON_spec_int64("timestamp", &dc.timestamp), +GNUNET_JSON_spec_fixed_auto("account", &dc.account), +GNUNET_JSON_spec_fixed_auto("diagnostic", &dc.diagnostic), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_RESERVE_IN_INCONSISTENCY_PUT_init (void) +{ + +} + + +void +TEAH_RESERVE_IN_INCONSISTENCY_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-put.h b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-put.h new file mode 100644 index 000000000..be3328983 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_RESERVE_IN_INCONSISTENCY_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_RESERVE_IN_INCONSISTENCY_done (void); + + +/** +* Handle a "/reserve-in-inconsistency" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVE_IN_INCONSISTENCY_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.c new file mode 100644 index 000000000..73a4a63f9 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-in-inconsistency-upd.h" + +MHD_RESULT +TAH_RESERVE_IN_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_reserve_in_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.h new file mode 100644 index 000000000..90036d8b3 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-in-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_RESERVE_IN_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_IN_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-del.c b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-del.c new file mode 100644 index 000000000..befaa42dc --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_reserve-not-closed-inconsistency-del.h" + + +MHD_RESULT +TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_reserve_not_closed_inconsistency (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /reserve-not-closed-inconsistency/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "RESERVE_NOT_CLOSED_INCONSISTENCY_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-del.h b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-del.h new file mode 100644 index 000000000..e30e26d19 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_RESERVE_NOT_CLOSED_INCONSISTENCY_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_RESERVE_NOT_CLOSED_INCONSISTENCY_DELETE_done (void); + +/** + * Handle a "/reserve-not-closed-inconsistency" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c new file mode 100644 index 000000000..e2c9a00a5 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.c @@ -0,0 +1,188 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-not-closed-inconsistency-get.h" + +/** +* Add reserve-not-closed-inconsistency to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_reserve_not_closed_inconsistency (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_ReserveNotClosedInconsistency + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("row_id", serial_id), +GNUNET_JSON_pack_data_auto("reserve_pub", &dc->reserve_pub), +TALER_JSON_pack_amount("balance", &dc->balance), +GNUNET_JSON_pack_int64("expiration_time", dc->expiration_time), +GNUNET_JSON_pack_data_auto("diagnostic", &dc->diagnostic), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_reserve_not_closed_inconsistency ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_reserve_not_closed_inconsistency, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /reserve-not-closed-inconsistency"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "reserve-not-closed-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("reserve-not-closed-inconsistency", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.h b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.h new file mode 100644 index 000000000..a0df5bd65 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_GET_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_RESERVE_NOT_CLOSED_INCONSISTENCY_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_RESERVE_NOT_CLOSED_INCONSISTENCY_GET_done (void); + +/** +* Handle a "/reserve-not-closed-inconsistency" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-put.c b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-put.c new file mode 100644 index 000000000..9524e5da4 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-put.c @@ -0,0 +1,163 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-not-closed-inconsistency-put.h" + +/** +* We have parsed the JSON information about the reserve-not-closed-inconsistency, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the reserve-not-closed-inconsistency +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_reserve_not_closed_inconsistency (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /reserve-not-closed-inconsistency in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "reserve-not-closed-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "RESERVE_NOT_CLOSED_INCONSISTENCY_OK")); +} + + +MHD_RESULT +TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_ReserveNotClosedInconsistency dc; + + + struct GNUNET_JSON_Specification spec[] = { + +GNUNET_JSON_spec_fixed_auto("reserve_pub", &dc.reserve_pub), +TALER_JSON_spec_amount("balance", TAH_currency, &dc.balance), +GNUNET_JSON_spec_int64("expiration_time", &dc.expiration_time), +GNUNET_JSON_spec_fixed_auto("diagnostic", &dc.diagnostic), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_RESERVE_NOT_CLOSED_INCONSISTENCY_PUT_init (void) +{ + +} + + +void +TEAH_RESERVE_NOT_CLOSED_INCONSISTENCY_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-put.h b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-put.h new file mode 100644 index 000000000..1ee211cdf --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_RESERVE_NOT_CLOSED_INCONSISTENCY_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_RESERVE_NOT_CLOSED_INCONSISTENCY_done (void); + + +/** +* Handle a "/reserve-not-closed-inconsistency" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.c new file mode 100644 index 000000000..28a8a1f69 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h" + +MHD_RESULT +TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_reserve_not_closed_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h new file mode 100644 index 000000000..59bba6cbd --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserve-not-closed-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_RESERVE_NOT_CLOSED_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_NOT_CLOSED_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserves-del.c b/src/auditor/taler-auditor-httpd_reserves-del.c new file mode 100644 index 000000000..2de0ab40d --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserves-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_reserves-del.h" + + +MHD_RESULT +TAH_RESERVES_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_reserves (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /reserves/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "RESERVES_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserves-del.h b/src/auditor/taler-auditor-httpd_reserves-del.h new file mode 100644 index 000000000..ac4cdb565 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserves-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVES_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVES_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_RESERVES_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_RESERVES_DELETE_done (void); + +/** + * Handle a "/reserves" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_RESERVES_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVES_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserves-get.c b/src/auditor/taler-auditor-httpd_reserves-get.c new file mode 100644 index 000000000..54b1a1863 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserves-get.c @@ -0,0 +1,194 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserves-get.h" + +/** +* Add reserves to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_reserves (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_Reserves + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("auditor_reserves_rowid", dc->auditor_reserves_rowid), +GNUNET_JSON_pack_data_auto("reserve_pub", &dc->reserve_pub), +TALER_JSON_pack_amount("reserve_balance", &dc->reserve_balance), +TALER_JSON_pack_amount("reserve_loss", &dc->reserve_loss), +TALER_JSON_pack_amount("withdraw_fee_balance", &dc->withdraw_fee_balance), +TALER_JSON_pack_amount("close_fee_balance", &dc->close_fee_balance), +TALER_JSON_pack_amount("purse_fee_balance", &dc->purse_fee_balance), +TALER_JSON_pack_amount("open_fee_balance", &dc->open_fee_balance), +TALER_JSON_pack_amount("history_fee_balance", &dc->history_fee_balance), +GNUNET_JSON_pack_int64("expiration_date", dc->expiration_date), +GNUNET_JSON_pack_string("origin_account", dc->origin_account), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVES_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_reserves ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_reserves, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /reserves"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "reserves"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("reserves", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserves-get.h b/src/auditor/taler-auditor-httpd_reserves-get.h new file mode 100644 index 000000000..139ead99b --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserves-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_RESERVES_GET_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVES_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_RESERVES_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_RESERVES_GET_done (void); + +/** +* Handle a "/reserves" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVES_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVES_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserves-put.c b/src/auditor/taler-auditor-httpd_reserves-put.c new file mode 100644 index 000000000..5b85db3cd --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserves-put.c @@ -0,0 +1,170 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserves-put.h" + +/** +* We have parsed the JSON information about the reserves, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the reserves +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_Reserves *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_reserves (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /reserves in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "reserves"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "RESERVES_OK")); +} + + +MHD_RESULT +TAH_RESERVES_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_Reserves dc; + + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_int64("auditor_reserves_rowid", &dc.auditor_reserves_rowid), +GNUNET_JSON_spec_fixed_auto("reserve_pub", &dc.reserve_pub), +TALER_JSON_spec_amount("reserve_balance", TAH_currency, &dc.reserve_balance), +TALER_JSON_spec_amount("reserve_loss", TAH_currency, &dc.reserve_loss), +TALER_JSON_spec_amount("withdraw_fee_balance", TAH_currency, &dc.withdraw_fee_balance), +TALER_JSON_spec_amount("close_fee_balance", TAH_currency, &dc.close_fee_balance), +TALER_JSON_spec_amount("purse_fee_balance", TAH_currency, &dc.purse_fee_balance), +TALER_JSON_spec_amount("open_fee_balance", TAH_currency, &dc.open_fee_balance), +TALER_JSON_spec_amount("history_fee_balance", TAH_currency, &dc.history_fee_balance), +GNUNET_JSON_spec_int64("expiration_date", &dc.expiration_date), +GNUNET_JSON_spec_string("origin_account", (const char **)dc.origin_account), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_RESERVES_PUT_init (void) +{ + +} + + +void +TEAH_RESERVES_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserves-put.h b/src/auditor/taler-auditor-httpd_reserves-put.h new file mode 100644 index 000000000..eb09584fb --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserves-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVES_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVES_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_RESERVES_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_RESERVES_done (void); + + +/** +* Handle a "/reserves" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_RESERVES_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVES_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserves-upd.c b/src/auditor/taler-auditor-httpd_reserves-upd.c new file mode 100644 index 000000000..fca94651e --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserves-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_reserves-upd.h" + +MHD_RESULT +TAH_RESERVES_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_reserves (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_reserves-upd.h b/src/auditor/taler-auditor-httpd_reserves-upd.h new file mode 100644 index 000000000..fc60e2a0b --- /dev/null +++ b/src/auditor/taler-auditor-httpd_reserves-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVES_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVES_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_RESERVES_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVES_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-inconsistency-get.c b/src/auditor/taler-auditor-httpd_row-inconsistency-get.c index d921aee19..f2c70a843 100644 --- a/src/auditor/taler-auditor-httpd_row-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_row-inconsistency-get.c @@ -87,18 +87,28 @@ TAH_ROW_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, ja = json_array (); GNUNET_break (NULL != ja); - uint64_t row_id = 0; - bool return_suppressed; + int64_t limit = -20; + uint64_t offset; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); - GNUNET_JSON_spec_bool ("return_suppressed", - &return_suppressed), + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; - GNUNET_JSON_spec_end () - }; + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; // read the input json @@ -131,11 +141,10 @@ TAH_ROW_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, } } - printf ("checkpoint httpd\n"); - qs = TAH_plugin->get_row_inconsistency ( TAH_plugin->cls, - row_id, + limit, + offset, return_suppressed, &add_row_inconsistency, ja); diff --git a/src/auditor/taler-auditor-httpd_row-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_row-inconsistency-upd.c new file mode 100644 index 000000000..2a4cda8f9 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_row-inconsistency-upd.h" + +MHD_RESULT +TAH_ROW_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_row_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_row-inconsistency-upd.h new file mode 100644 index 000000000..e616f7af0 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_ROW_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_ROW_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_ROW_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_ROW_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-del.c b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-del.c new file mode 100644 index 000000000..165f1d4b1 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_row-minor-inconsistencies-del.h" + + +MHD_RESULT +TAH_ROW_MINOR_INCONSISTENCIES_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_row_minor_inconsistencies (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /row-minor-inconsistencies/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "ROW_MINOR_INCONSISTENCIES_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-del.h b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-del.h new file mode 100644 index 000000000..04e4b344d --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_ROW_MINOR_INCONSISTENCIES_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_ROW_MINOR_INCONSISTENCIES_DELETE_done (void); + +/** + * Handle a "/row-minor-inconsistencies" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_ROW_MINOR_INCONSISTENCIES_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c new file mode 100644 index 000000000..81ff2e6fb --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.c @@ -0,0 +1,186 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_row-minor-inconsistencies-get.h" + +/** +* Add row-minor-inconsistencies to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_row_minor_inconsistencies (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_RowMinorInconsistencies + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("row_id", serial_id), +GNUNET_JSON_pack_string("row_table", dc->row_table), +GNUNET_JSON_pack_string("diagnostic", dc->diagnostic), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_ROW_MINOR_INCONSISTENCIES_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_row_minor_inconsistencies ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_row_minor_inconsistencies, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /row-minor-inconsistencies"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "row-minor-inconsistencies"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("row-minor-inconsistencies", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.h b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.h new file mode 100644 index 000000000..d21f24d20 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_GET_H +#define SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_ROW_MINOR_INCONSISTENCIES_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_ROW_MINOR_INCONSISTENCIES_GET_done (void); + +/** +* Handle a "/row-minor-inconsistencies" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_ROW_MINOR_INCONSISTENCIES_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-put.c b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-put.c new file mode 100644 index 000000000..1b32dd4f4 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-put.c @@ -0,0 +1,161 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_row-minor-inconsistencies-put.h" + +/** +* We have parsed the JSON information about the row-minor-inconsistencies, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the row-minor-inconsistencies +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_RowMinorInconsistencies *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_row_minor_inconsistencies (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /row-minor-inconsistencies in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "row-minor-inconsistencies"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "ROW_MINOR_INCONSISTENCIES_OK")); +} + + +MHD_RESULT +TAH_ROW_MINOR_INCONSISTENCIES_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_RowMinorInconsistencies dc; + + + struct GNUNET_JSON_Specification spec[] = { + +GNUNET_JSON_spec_fixed_auto("row_table", &dc.row_table), +GNUNET_JSON_spec_fixed_auto("diagnostic", &dc.diagnostic), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_ROW_MINOR_INCONSISTENCIES_PUT_init (void) +{ + +} + + +void +TEAH_ROW_MINOR_INCONSISTENCIES_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-put.h b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-put.h new file mode 100644 index 000000000..c1ffd45dd --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_ROW_MINOR_INCONSISTENCIES_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_ROW_MINOR_INCONSISTENCIES_done (void); + + +/** +* Handle a "/row-minor-inconsistencies" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_ROW_MINOR_INCONSISTENCIES_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.c b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.c new file mode 100644 index 000000000..ea8c8cb21 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_row-minor-inconsistencies-upd.h" + +MHD_RESULT +TAH_ROW_MINOR_INCONSISTENCIES_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_row_minor_inconsistencies (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.h b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.h new file mode 100644 index 000000000..d42c158bd --- /dev/null +++ b/src/auditor/taler-auditor-httpd_row-minor-inconsistencies-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_ROW_MINOR_INCONSISTENCIES_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_ROW_MINOR_INCONSISTENCIES_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-del.c b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-del.c new file mode 100644 index 000000000..e40bc7b09 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_wire-format-inconsistency-del.h" + + +MHD_RESULT +TAH_WIRE_FORMAT_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_wire_format_inconsistency (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /wire-format-inconsistency/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "WIRE_FORMAT_INCONSISTENCY_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-del.h b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-del.h new file mode 100644 index 000000000..9a4399b6c --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_WIRE_FORMAT_INCONSISTENCY_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_WIRE_FORMAT_INCONSISTENCY_DELETE_done (void); + +/** + * Handle a "/wire-format-inconsistency" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_WIRE_FORMAT_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c new file mode 100644 index 000000000..f342505ba --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.c @@ -0,0 +1,187 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_wire-format-inconsistency-get.h" + +/** +* Add wire-format-inconsistency to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_wire_format_inconsistency (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_WireFormatInconsistency + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("row_id", serial_id), +TALER_JSON_pack_amount("amount", &dc->amount), +GNUNET_JSON_pack_int64("wire_offset", dc->wire_offset), +GNUNET_JSON_pack_data_auto("diagnostic", dc->diagnostic), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_WIRE_FORMAT_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_wire_format_inconsistency ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_wire_format_inconsistency, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /wire-format-inconsistency"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "wire-format-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("wire-format-inconsistency", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.h b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.h new file mode 100644 index 000000000..6d170c884 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_GET_H +#define SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_WIRE_FORMAT_INCONSISTENCY_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_WIRE_FORMAT_INCONSISTENCY_GET_done (void); + +/** +* Handle a "/wire-format-inconsistency" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_WIRE_FORMAT_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-put.c b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-put.c new file mode 100644 index 000000000..66e8eb968 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-put.c @@ -0,0 +1,162 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_wire-format-inconsistency-put.h" + +/** +* We have parsed the JSON information about the wire-format-inconsistency, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the wire-format-inconsistency +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_WireFormatInconsistency *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_wire_format_inconsistency (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /wire-format-inconsistency in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "wire-format-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "WIRE_FORMAT_INCONSISTENCY_OK")); +} + + +MHD_RESULT +TAH_WIRE_FORMAT_INCONSISTENCY_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_WireFormatInconsistency dc; + + + struct GNUNET_JSON_Specification spec[] = { + +TALER_JSON_spec_amount("amount", TAH_currency, &dc.amount), +GNUNET_JSON_spec_int64("wire_offset", &dc.wire_offset), +GNUNET_JSON_spec_fixed_auto("diagnostic", &dc.diagnostic), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_WIRE_FORMAT_INCONSISTENCY_PUT_init (void) +{ + +} + + +void +TEAH_WIRE_FORMAT_INCONSISTENCY_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-put.h b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-put.h new file mode 100644 index 000000000..b64c29275 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_WIRE_FORMAT_INCONSISTENCY_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_WIRE_FORMAT_INCONSISTENCY_done (void); + + +/** +* Handle a "/wire-format-inconsistency" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_WIRE_FORMAT_INCONSISTENCY_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.c new file mode 100644 index 000000000..5af604098 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_wire-format-inconsistency-upd.h" + +MHD_RESULT +TAH_WIRE_FORMAT_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_wire_format_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.h new file mode 100644 index 000000000..c9e17a11a --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-format-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_WIRE_FORMAT_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_FORMAT_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-del.c b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-del.c new file mode 100644 index 000000000..3d3ce9a54 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-del.c @@ -0,0 +1,87 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "taler-auditor-httpd_wire-out-inconsistency-del.h" + + +MHD_RESULT +TAH_WIRE_OUT_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + MHD_RESULT res; + enum GNUNET_DB_QueryStatus qs; + + uint64_t row_id; + + if (args[1] != NULL) + row_id = atoi (args[1]); + else + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + + // execute the transaction + qs = TAH_plugin->delete_wire_out_inconsistency (TAH_plugin->cls, + row_id); + + if (0 == qs) + { + // goes in here if there was an error with the transaction + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to handle DELETE /wire-out-inconsistency/ %s", + args[1]); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + // TODO: not the correct ec + TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + "exchange signature invalid"); + + } + + // on success? + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_NO_CONTENT, + GNUNET_JSON_pack_string ("status", + "WIRE_OUT_INCONSISTENCY_OK")); + + return res; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-del.h b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-del.h new file mode 100644 index 000000000..9da4d03b3 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-del.h @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_DEL_H +#define SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_DEL_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** + * Initialize subsystem. + */ +void +TEAH_WIRE_OUT_INCONSISTENCY_DELETE_init (void); + +/** + * Shut down subsystem. + */ +void +TEAH_WIRE_OUT_INCONSISTENCY_DELETE_done (void); + +/** + * Handle a "/wire-out-inconsistency" request. Parses the JSON, and, if + * successful, checks the signatures and stores the result in the DB. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] connection_cls the connection's closure (can be updated) + * @param upload_data upload data + * @param[in,out] upload_data_size number of bytes (left) in @a upload_data + * @return MHD result code + */ +MHD_RESULT +TAH_WIRE_OUT_INCONSISTENCY_handler_delete (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_DEL_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c new file mode 100644 index 000000000..76a3bb631 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c @@ -0,0 +1,187 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_wire-out-inconsistency-get.h" + +/** +* Add wire-out-inconsistency to the list. +* +* @param[in,out] cls a `json_t *` array to extend +* @param serial_id location of the @a dc in the database +* @param dc struct of inconsistencies +* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating +*/ +static enum GNUNET_GenericReturnValue +process_wire_out_inconsistency (void *cls, + uint64_t serial_id, + const struct + TALER_AUDITORDB_WireOutInconsistency + *dc) +{ + json_t *list = cls; + json_t *obj; + + obj = GNUNET_JSON_PACK ( + + GNUNET_JSON_pack_int64("row_id", serial_id), +GNUNET_JSON_pack_string("destination_account", dc->destination_account), +TALER_JSON_pack_amount("expected", &dc->expected), +TALER_JSON_pack_amount("claimed", &dc->claimed), +GNUNET_JSON_pack_bool("suppressed", dc->suppressed) + + + ); + GNUNET_break (0 == + json_array_append_new (list, + obj)); + + + return GNUNET_OK; +} + + +/** +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_WIRE_OUT_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + json_t *ja; + enum GNUNET_DB_QueryStatus qs; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + ja = json_array (); + GNUNET_break (NULL != ja); + + int64_t limit = -20; + uint64_t offset; + + TALER_MHD_parse_request_snumber (connection, + "limit", + &limit); + + if (limit < 0) + offset = INT64_MAX; + else + offset = 0; + + TALER_MHD_parse_request_number (connection, + "offset", + &offset); + + bool return_suppressed = false; + + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_bool ("return_suppressed", &return_suppressed), + GNUNET_JSON_spec_end () + }; + + // read the input json + json_t *json_in; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json_in); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json_in)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json_in, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json_in); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json_in); + return MHD_YES; /* failure */ + } + } + + qs = TAH_plugin->get_wire_out_inconsistency ( + TAH_plugin->cls, + limit, + offset, + return_suppressed, + &process_wire_out_inconsistency, + ja); + + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + json_decref (ja); + TALER_LOG_WARNING ( + "Failed to handle GET /wire-out-inconsistency"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "wire-out-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("wire-out-inconsistency", + ja)); +} + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.h b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.h new file mode 100644 index 000000000..df59bfe0d --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + #ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_GET_H +#define SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_GET_H + +#include <gnunet/gnunet_util_lib.h> +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_WIRE_OUT_INCONSISTENCY_GET_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_WIRE_OUT_INCONSISTENCY_GET_done (void); + +/** +* Handle a "/wire-out-inconsistency" request. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_WIRE_OUT_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_GET_H + + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-put.c b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-put.c new file mode 100644 index 000000000..2c7462c4b --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-put.c @@ -0,0 +1,162 @@ + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_wire-out-inconsistency-put.h" + +/** +* We have parsed the JSON information about the wire-out-inconsistency, do some +* basic sanity checks and then execute the +* transaction. +* +* @param connection the MHD connection to handle +* @param dc information about the wire-out-inconsistency +* @return MHD result code +*/ +static MHD_RESULT +process_inconsistency ( + struct MHD_Connection *connection, + const struct TALER_AUDITORDB_WireOutInconsistency *dc) +{ + + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + /* execute transaction */ + qs = TAH_plugin->insert_wire_out_inconsistency (TAH_plugin->cls, + dc); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ( + "Failed to store /wire-out-inconsistency in database"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "wire-out-inconsistency"); + } + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("status", + "WIRE_OUT_INCONSISTENCY_OK")); +} + + +MHD_RESULT +TAH_WIRE_OUT_INCONSISTENCY_handler_put ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + + struct TALER_AUDITORDB_WireOutInconsistency dc; + + + struct GNUNET_JSON_Specification spec[] = { + +GNUNET_JSON_spec_fixed_auto("destination_account", &dc.destination_account), +TALER_JSON_spec_amount("expected", TAH_currency, &dc.expected), +TALER_JSON_spec_amount("claimed", TAH_currency, &dc.claimed), +GNUNET_JSON_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_JSON_spec_end () + }; + + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + MHD_RESULT res; + + res = process_inconsistency (connection, &dc); + GNUNET_JSON_parse_free (spec); + + json_decref (json); + return res; + +} + + +void +TEAH_WIRE_OUT_INCONSISTENCY_PUT_init (void) +{ + +} + + +void +TEAH_WIRE_OUT_INCONSISTENCY_PUT_done (void) +{ + +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-put.h b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-put.h new file mode 100644 index 000000000..190cf2dbf --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-put.h @@ -0,0 +1,63 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_PUT_H + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +/** +* Initialize subsystem. +*/ +void +TEAH_BAD_WIRE_OUT_INCONSISTENCY_init (void); + +/** +* Shut down subsystem. +*/ +void +TEAH_BAD_WIRE_OUT_INCONSISTENCY_done (void); + + +/** +* Handle a "/wire-out-inconsistency" request. Parses the JSON, and, if +* successful, checks the signatures and stores the result in the DB. +* +* @param rh context of the handler +* @param connection the MHD connection to handle +* @param[in,out] connection_cls the connection's closure (can be updated) +* @param upload_data upload data +* @param[in,out] upload_data_size number of bytes (left) in @a upload_data +* @return MHD result code +*/ +MHD_RESULT +TAH_WIRE_OUT_INCONSISTENCY_handler_put (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + + +#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_PUT_H + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.c b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.c new file mode 100644 index 000000000..9ed7c4a27 --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.c @@ -0,0 +1,139 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include <jansson.h> +#include <microhttpd.h> +#include <pthread.h> +#include "taler_json_lib.h" +#include "taler_mhd_lib.h" +#include "taler-auditor-httpd.h" +#include "taler-auditor-httpd_wire-out-inconsistency-upd.h" + +MHD_RESULT +TAH_WIRE_OUT_INCONSISTENCY_handler_update ( + struct TAH_RequestHandler *rh, + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]) +{ + enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + + struct TALER_AUDITORDB_Generic_Update gu; + + struct GNUNET_JSON_Specification spec[] = { + + GNUNET_JSON_spec_uint64 ("row_id", &gu.row_id), + GNUNET_JSON_spec_bool ("suppressed", &gu.suppressed), + + GNUNET_JSON_spec_end () + }; + + json_t *json; + + (void) rh; + (void) connection_cls; + (void) upload_data; + (void) upload_data_size; + { + enum GNUNET_GenericReturnValue res; + + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); + if (GNUNET_SYSERR == res) + return MHD_NO; + if ((GNUNET_NO == res) || + (NULL == json)) + return MHD_YES; + res = TALER_MHD_parse_json_data (connection, + json, + spec); + if (GNUNET_SYSERR == res) + { + json_decref (json); + return MHD_NO; /* hard failure */ + } + if (GNUNET_NO == res) + { + json_decref (json); + return MHD_YES; /* failure */ + } + } + + /* execute transaction */ + qs = TAH_plugin->update_wire_out_inconsistency (TAH_plugin->cls, &gu); + + GNUNET_JSON_parse_free (spec); + json_decref (json); + + MHD_RESULT ret = MHD_NO; + + switch (qs) + { + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, + "update_account"); + break; + case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); + ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "unexpected serialization problem"); + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ACCOUNT_UNKNOWN, + "no updates executed"); + break; + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + ret = TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + break; + } + + return ret; +} + +
\ No newline at end of file diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.h b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.h new file mode 100644 index 000000000..5fb79130f --- /dev/null +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-upd.h @@ -0,0 +1,40 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_UPD_H +#define SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_UPD_H + + +#include <microhttpd.h> +#include "taler-auditor-httpd.h" + +MHD_RESULT +TAH_WIRE_OUT_INCONSISTENCY_handler_update (struct TAH_RequestHandler *rh, + struct MHD_Connection * + connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size, + const char *const args[]); + +#endif // SRC_TALER_AUDITOR_HTTPD_WIRE_OUT_INCONSISTENCY_UPD_H + + +
\ No newline at end of file diff --git a/src/auditordb/0002-auditor_bad_sig_losses.sql b/src/auditordb/0002-auditor_bad_sig_losses.sql index e4e87f398..803f25124 100644 --- a/src/auditordb/0002-auditor_bad_sig_losses.sql +++ b/src/auditordb/0002-auditor_bad_sig_losses.sql @@ -18,7 +18,7 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_bad_sig_losses
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- operation VARCHAR(64),
+ operation TEXT,
loss taler_amount,
operation_specific_pub BYTEA NOT NULL CHECK (LENGTH(operation_specific_pub)=32),
suppressed BOOLEAN NOT NULL DEFAULT FALSE
diff --git a/src/auditordb/0002-auditor_row_inconsistency.sql b/src/auditordb/0002-auditor_row_inconsistency.sql index 20bf9fd7d..0b1d74a85 100644 --- a/src/auditordb/0002-auditor_row_inconsistency.sql +++ b/src/auditordb/0002-auditor_row_inconsistency.sql @@ -18,8 +18,8 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_row_inconsistency
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- row_table VARCHAR(64),
- diagnostic VARCHAR(64),
+ row_table TEXT,
+ diagnostic TEXT,
suppressed BOOLEAN NOT NULL DEFAULT FALSE
);
COMMENT ON TABLE auditor_row_inconsistency
diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am index 79cb8ae36..0dc499d35 100644 --- a/src/auditordb/Makefile.am +++ b/src/auditordb/Makefile.am @@ -126,6 +126,72 @@ pg_get_auditor_closure_lags.c pg_get_auditor_closure_lags.h \ pg_del_refreshes_hanging.c pg_del_refreshes_hanging.h \ pg_insert_refreshes_hanging.c pg_insert_refreshes_hanging.h \ pg_get_refreshes_hanging.c pg_get_refreshes_hanging.h \ +pg_update_emergency_by_count.c pg_update_emergency_by_count.h \ +pg_update_row_inconsistency.c pg_update_row_inconsistency.h \ +pg_update_purse_not_closed_inconsistencies.c pg_update_purse_not_closed_inconsistencies.h \ +pg_update_reserve_balance_insufficient_inconsistency.c pg_update_reserve_balance_insufficient_inconsistency.h \ +pg_update_coin_inconsistency.c pg_update_coin_inconsistency.h \ +pg_update_progress.c pg_update_progress.h \ +pg_update_denomination_key_validity_withdraw_inconsistency.c pg_update_denomination_key_validity_withdraw_inconsistency.h \ +pg_update_refreshes_hanging.c pg_update_refreshes_hanging.h \ +pg_update_emergency.c pg_update_emergency.h \ +pg_update_closure_lags.c pg_update_closure_lags.h \ +pg_get_reserve_in_inconsistency.c pg_get_reserve_in_inconsistency.h \ +pg_del_reserve_in_inconsistency.c pg_del_reserve_in_inconsistency.h \ +pg_insert_reserve_in_inconsistency.c pg_insert_reserve_in_inconsistency.h \ +pg_update_reserve_in_inconsistency.c pg_update_reserve_in_inconsistency.h \ +pg_get_reserve_not_closed_inconsistency.c pg_get_reserve_not_closed_inconsistency.h \ +pg_del_reserve_not_closed_inconsistency.c pg_del_reserve_not_closed_inconsistency.h \ +pg_insert_reserve_not_closed_inconsistency.c pg_insert_reserve_not_closed_inconsistency.h \ +pg_update_reserve_not_closed_inconsistency.c pg_update_reserve_not_closed_inconsistency.h \ +pg_get_denominations_without_sigs.c pg_get_denominations_without_sigs.h \ +pg_del_denominations_without_sigs.c pg_del_denominations_without_sigs.h \ +pg_insert_denominations_without_sigs.c pg_insert_denominations_without_sigs.h \ +pg_update_denominations_without_sigs.c pg_update_denominations_without_sigs.h \ +pg_get_misattribution_in_inconsistency.c pg_get_misattribution_in_inconsistency.h \ +pg_del_misattribution_in_inconsistency.c pg_del_misattribution_in_inconsistency.h \ +pg_insert_misattribution_in_inconsistency.c pg_insert_misattribution_in_inconsistency.h \ +pg_update_misattribution_in_inconsistency.c pg_update_misattribution_in_inconsistency.h \ +pg_get_reserves.c pg_get_reserves.h \ +pg_del_reserves.c pg_del_reserves.h \ +pg_insert_reserves.c pg_insert_reserves.h \ +pg_update_reserves.c pg_update_reserves.h \ +pg_get_purses.c pg_get_purses.h \ +pg_del_purses.c pg_del_purses.h \ +pg_insert_purses.c pg_insert_purses.h \ +pg_update_purses.c pg_update_purses.h \ +pg_get_historic_denomination_revenue.c pg_get_historic_denomination_revenue.h \ +pg_del_historic_denomination_revenue.c pg_del_historic_denomination_revenue.h \ +pg_insert_historic_denomination_revenue.c pg_insert_historic_denomination_revenue.h \ +pg_update_historic_denomination_revenue.c pg_update_historic_denomination_revenue.h \ +pg_get_denomination_pending.c pg_get_denomination_pending.h \ +pg_del_denomination_pending.c pg_del_denomination_pending.h \ +pg_insert_denomination_pending.c pg_insert_denomination_pending.h \ +pg_update_denomination_pending.c pg_update_denomination_pending.h \ +pg_get_historic_reserve_summary.c pg_get_historic_reserve_summary.h \ +pg_del_historic_reserve_summary.c pg_del_historic_reserve_summary.h \ +pg_insert_historic_reserve_summary.c pg_insert_historic_reserve_summary.h \ +pg_update_historic_reserve_summary.c pg_update_historic_reserve_summary.h \ +pg_get_exchange_signkeys.c pg_get_exchange_signkeys.h \ +pg_del_exchange_signkeys.c pg_del_exchange_signkeys.h \ +pg_insert_exchange_signkeys.c pg_insert_exchange_signkeys.h \ +pg_update_exchange_signkeys.c pg_update_exchange_signkeys.h \ +pg_get_wire_format_inconsistency.c pg_get_wire_format_inconsistency.h \ +pg_del_wire_format_inconsistency.c pg_del_wire_format_inconsistency.h \ +pg_insert_wire_format_inconsistency.c pg_insert_wire_format_inconsistency.h \ +pg_update_wire_format_inconsistency.c pg_update_wire_format_inconsistency.h \ +pg_get_wire_out_inconsistency.c pg_get_wire_out_inconsistency.h \ +pg_del_wire_out_inconsistency.c pg_del_wire_out_inconsistency.h \ +pg_insert_wire_out_inconsistency.c pg_insert_wire_out_inconsistency.h \ +pg_update_wire_out_inconsistency.c pg_update_wire_out_inconsistency.h \ +pg_get_reserve_balance_summary_wrong_inconsistency.c pg_get_reserve_balance_summary_wrong_inconsistency.h \ +pg_del_reserve_balance_summary_wrong_inconsistency.c pg_del_reserve_balance_summary_wrong_inconsistency.h \ +pg_insert_reserve_balance_summary_wrong_inconsistency.c pg_insert_reserve_balance_summary_wrong_inconsistency.h \ +pg_update_reserve_balance_summary_wrong_inconsistency.c pg_update_reserve_balance_summary_wrong_inconsistency.h \ +pg_get_row_minor_inconsistencies.c pg_get_row_minor_inconsistencies.h \ +pg_del_row_minor_inconsistencies.c pg_del_row_minor_inconsistencies.h \ +pg_insert_row_minor_inconsistencies.c pg_insert_row_minor_inconsistencies.h \ +pg_update_row_minor_inconsistencies.c pg_update_row_minor_inconsistencies.h \ pg_del_auditor_progress.c pg_del_auditor_progress.h libtaler_plugin_auditordb_postgres_la_LDFLAGS = \ $(TALER_PLUGIN_LDFLAGS) diff --git a/src/auditordb/pg_del_denomination_pending.c b/src/auditordb/pg_del_denomination_pending.c new file mode 100644 index 000000000..7d9158ea9 --- /dev/null +++ b/src/auditordb/pg_del_denomination_pending.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_denomination_pending.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_denomination_pending ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_denomination_pending", + "DELETE" + " FROM auditor_denomination_pending" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_denomination_pending", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_denomination_pending.h b/src/auditordb/pg_del_denomination_pending.h new file mode 100644 index 000000000..62d1651c4 --- /dev/null +++ b/src/auditordb/pg_del_denomination_pending.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_DENOMINATION_PENDING_H +#define SRC_PG_DEL_DENOMINATION_PENDING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_denomination_pending ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_DENOMINATION_PENDING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_denominations_without_sigs.c b/src/auditordb/pg_del_denominations_without_sigs.c new file mode 100644 index 000000000..8d5214f98 --- /dev/null +++ b/src/auditordb/pg_del_denominations_without_sigs.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_denominations_without_sigs.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_denominations_without_sigs ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_denominations_without_sigs", + "DELETE" + " FROM auditor_denominations_without_sigs" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_denominations_without_sigs", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_denominations_without_sigs.h b/src/auditordb/pg_del_denominations_without_sigs.h new file mode 100644 index 000000000..2329d430b --- /dev/null +++ b/src/auditordb/pg_del_denominations_without_sigs.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_DENOMINATIONS_WITHOUT_SIGS_H +#define SRC_PG_DEL_DENOMINATIONS_WITHOUT_SIGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_denominations_without_sigs ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_DENOMINATIONS_WITHOUT_SIGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_exchange_signkeys.c b/src/auditordb/pg_del_exchange_signkeys.c new file mode 100644 index 000000000..0ae722c1d --- /dev/null +++ b/src/auditordb/pg_del_exchange_signkeys.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_exchange_signkeys.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_exchange_signkeys ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_exchange_signkeys", + "DELETE" + " FROM auditor_exchange_signkeys" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_exchange_signkeys", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_exchange_signkeys.h b/src/auditordb/pg_del_exchange_signkeys.h new file mode 100644 index 000000000..d81fcb1d0 --- /dev/null +++ b/src/auditordb/pg_del_exchange_signkeys.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_EXCHANGE_SIGNKEYS_H +#define SRC_PG_DEL_EXCHANGE_SIGNKEYS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_exchange_signkeys ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_EXCHANGE_SIGNKEYS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_historic_denomination_revenue.c b/src/auditordb/pg_del_historic_denomination_revenue.c new file mode 100644 index 000000000..8376c1c4d --- /dev/null +++ b/src/auditordb/pg_del_historic_denomination_revenue.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_historic_denomination_revenue.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_historic_denomination_revenue ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_historic_denomination_revenue", + "DELETE" + " FROM auditor_historic_denomination_revenue" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_historic_denomination_revenue", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_historic_denomination_revenue.h b/src/auditordb/pg_del_historic_denomination_revenue.h new file mode 100644 index 000000000..6fa62c542 --- /dev/null +++ b/src/auditordb/pg_del_historic_denomination_revenue.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_HISTORIC_DENOMINATION_REVENUE_H +#define SRC_PG_DEL_HISTORIC_DENOMINATION_REVENUE_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_historic_denomination_revenue ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_HISTORIC_DENOMINATION_REVENUE_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_historic_reserve_summary.c b/src/auditordb/pg_del_historic_reserve_summary.c new file mode 100644 index 000000000..e6e99cc39 --- /dev/null +++ b/src/auditordb/pg_del_historic_reserve_summary.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_historic_reserve_summary.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_historic_reserve_summary ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_historic_reserve_summary", + "DELETE" + " FROM auditor_historic_reserve_summary" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_historic_reserve_summary", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_historic_reserve_summary.h b/src/auditordb/pg_del_historic_reserve_summary.h new file mode 100644 index 000000000..eeeacf2dc --- /dev/null +++ b/src/auditordb/pg_del_historic_reserve_summary.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_HISTORIC_RESERVE_SUMMARY_H +#define SRC_PG_DEL_HISTORIC_RESERVE_SUMMARY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_historic_reserve_summary ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_HISTORIC_RESERVE_SUMMARY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_misattribution_in_inconsistency.c b/src/auditordb/pg_del_misattribution_in_inconsistency.c new file mode 100644 index 000000000..052e3ff5a --- /dev/null +++ b/src/auditordb/pg_del_misattribution_in_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_misattribution_in_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_misattribution_in_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_misattribution_in_inconsistency", + "DELETE" + " FROM auditor_misattribution_in_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_misattribution_in_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_misattribution_in_inconsistency.h b/src/auditordb/pg_del_misattribution_in_inconsistency.h new file mode 100644 index 000000000..57cd551ea --- /dev/null +++ b/src/auditordb/pg_del_misattribution_in_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_MISATTRIBUTION_IN_INCONSISTENCY_H +#define SRC_PG_DEL_MISATTRIBUTION_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_misattribution_in_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_MISATTRIBUTION_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_purses.c b/src/auditordb/pg_del_purses.c new file mode 100644 index 000000000..03661b6e7 --- /dev/null +++ b/src/auditordb/pg_del_purses.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_purses.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_purses ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_purses", + "DELETE" + " FROM auditor_purses" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_purses", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_purses.h b/src/auditordb/pg_del_purses.h new file mode 100644 index 000000000..94b41b272 --- /dev/null +++ b/src/auditordb/pg_del_purses.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_PURSES_H +#define SRC_PG_DEL_PURSES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_purses ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_PURSES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.c new file mode 100644 index 000000000..b7cc6e5b4 --- /dev/null +++ b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_reserve_balance_summary_wrong_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_balance_summary_wrong_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_reserve_balance_summary_wrong_inconsistency", + "DELETE" + " FROM auditor_reserve_balance_summary_wrong_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_reserve_balance_summary_wrong_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.h b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.h new file mode 100644 index 000000000..e5640d2cb --- /dev/null +++ b/src/auditordb/pg_del_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H +#define SRC_PG_DEL_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_balance_summary_wrong_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_in_inconsistency.c b/src/auditordb/pg_del_reserve_in_inconsistency.c new file mode 100644 index 000000000..5e0e6dbe6 --- /dev/null +++ b/src/auditordb/pg_del_reserve_in_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_reserve_in_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_in_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_reserve_in_inconsistency", + "DELETE" + " FROM auditor_reserve_in_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_reserve_in_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_in_inconsistency.h b/src/auditordb/pg_del_reserve_in_inconsistency.h new file mode 100644 index 000000000..ae274bb53 --- /dev/null +++ b/src/auditordb/pg_del_reserve_in_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_RESERVE_IN_INCONSISTENCY_H +#define SRC_PG_DEL_RESERVE_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_in_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_RESERVE_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_not_closed_inconsistency.c b/src/auditordb/pg_del_reserve_not_closed_inconsistency.c new file mode 100644 index 000000000..56a902132 --- /dev/null +++ b/src/auditordb/pg_del_reserve_not_closed_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_reserve_not_closed_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_not_closed_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_reserve_not_closed_inconsistency", + "DELETE" + " FROM auditor_reserve_not_closed_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_reserve_not_closed_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserve_not_closed_inconsistency.h b/src/auditordb/pg_del_reserve_not_closed_inconsistency.h new file mode 100644 index 000000000..2aa89c718 --- /dev/null +++ b/src/auditordb/pg_del_reserve_not_closed_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_RESERVE_NOT_CLOSED_INCONSISTENCY_H +#define SRC_PG_DEL_RESERVE_NOT_CLOSED_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserve_not_closed_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_RESERVE_NOT_CLOSED_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserves.c b/src/auditordb/pg_del_reserves.c new file mode 100644 index 000000000..1413c028b --- /dev/null +++ b/src/auditordb/pg_del_reserves.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_reserves.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserves ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_reserves", + "DELETE" + " FROM auditor_reserves" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_reserves", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_reserves.h b/src/auditordb/pg_del_reserves.h new file mode 100644 index 000000000..7e87a6189 --- /dev/null +++ b/src/auditordb/pg_del_reserves.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_RESERVES_H +#define SRC_PG_DEL_RESERVES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_reserves ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_RESERVES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_row_minor_inconsistencies.c b/src/auditordb/pg_del_row_minor_inconsistencies.c new file mode 100644 index 000000000..9a2c6953f --- /dev/null +++ b/src/auditordb/pg_del_row_minor_inconsistencies.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_row_minor_inconsistencies.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_row_minor_inconsistencies ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_row_minor_inconsistencies", + "DELETE" + " FROM auditor_row_minor_inconsistencies" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_row_minor_inconsistencies", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_row_minor_inconsistencies.h b/src/auditordb/pg_del_row_minor_inconsistencies.h new file mode 100644 index 000000000..c3df22c2d --- /dev/null +++ b/src/auditordb/pg_del_row_minor_inconsistencies.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_ROW_MINOR_INCONSISTENCIES_H +#define SRC_PG_DEL_ROW_MINOR_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_row_minor_inconsistencies ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_ROW_MINOR_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_wire_format_inconsistency.c b/src/auditordb/pg_del_wire_format_inconsistency.c new file mode 100644 index 000000000..018381f8c --- /dev/null +++ b/src/auditordb/pg_del_wire_format_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_wire_format_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_wire_format_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_wire_format_inconsistency", + "DELETE" + " FROM auditor_wire_format_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_wire_format_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_wire_format_inconsistency.h b/src/auditordb/pg_del_wire_format_inconsistency.h new file mode 100644 index 000000000..f298e4dd8 --- /dev/null +++ b/src/auditordb/pg_del_wire_format_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_WIRE_FORMAT_INCONSISTENCY_H +#define SRC_PG_DEL_WIRE_FORMAT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_wire_format_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_WIRE_FORMAT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_wire_out_inconsistency.c b/src/auditordb/pg_del_wire_out_inconsistency.c new file mode 100644 index 000000000..0976cec4d --- /dev/null +++ b/src/auditordb/pg_del_wire_out_inconsistency.c @@ -0,0 +1,47 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "pg_del_wire_out_inconsistency.h" + +#include "taler_pq_lib.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_del_wire_out_inconsistency ( + void *cls, + uint64_t row_id) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&row_id), + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_delete_wire_out_inconsistency", + "DELETE" + " FROM auditor_wire_out_inconsistency" + " WHERE row_id=$1;"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_delete_wire_out_inconsistency", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_del_wire_out_inconsistency.h b/src/auditordb/pg_del_wire_out_inconsistency.h new file mode 100644 index 000000000..d7e3b54c1 --- /dev/null +++ b/src/auditordb/pg_del_wire_out_inconsistency.h @@ -0,0 +1,42 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_DEL_WIRE_OUT_INCONSISTENCY_H +#define SRC_PG_DEL_WIRE_OUT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +/** + * Delete a row from the bad sig losses table. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param row_id row to delete + * @return query transaction status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_del_wire_out_inconsistency ( + void *cls, + uint64_t row_id); + +#endif // SRC_PG_DEL_WIRE_OUT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_amount_arithmetic_inconsistency.c b/src/auditordb/pg_get_amount_arithmetic_inconsistency.c index c768f43ac..312d9e233 100644 --- a/src/auditordb/pg_get_amount_arithmetic_inconsistency.c +++ b/src/auditordb/pg_get_amount_arithmetic_inconsistency.c @@ -102,19 +102,21 @@ amount_arithmetic_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_amount_arithmetic_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - // GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct AmountArithmeticInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -123,7 +125,7 @@ TAH_PG_get_amount_arithmetic_inconsistency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_amount_arithmetic_inconsistency_select", + "auditor_amount_arithmetic_inconsistency_select_desc", "SELECT" " row_id" ",operation" @@ -131,10 +133,27 @@ TAH_PG_get_amount_arithmetic_inconsistency ( ",auditor_amount" ",profitable" " FROM auditor_amount_arithmetic_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id<$1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_amount_arithmetic_inconsistency_select_asc", + "SELECT" + " row_id" + ",operation" + ",exchange_amount" + ",auditor_amount" + ",profitable" + " FROM auditor_amount_arithmetic_inconsistency" + " WHERE (row_id>$1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_amount_arithmetic_inconsistency_select", + (limit > 0) ? "auditor_amount_arithmetic_inconsistency_select_asc" : "auditor_amount_arithmetic_inconsistency_select_desc", params, &amount_arithmetic_inconsistency_cb, &dcc); diff --git a/src/auditordb/pg_get_amount_arithmetic_inconsistency.h b/src/auditordb/pg_get_amount_arithmetic_inconsistency.h index 845ae117c..3d00cccce 100644 --- a/src/auditordb/pg_get_amount_arithmetic_inconsistency.h +++ b/src/auditordb/pg_get_amount_arithmetic_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_amount_arithmetic_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_auditor_closure_lags.c b/src/auditordb/pg_get_auditor_closure_lags.c index 6624ca378..409be8a9b 100644 --- a/src/auditordb/pg_get_auditor_closure_lags.c +++ b/src/auditordb/pg_get_auditor_closure_lags.c @@ -96,18 +96,20 @@ closure_lags_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_auditor_closure_lags ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_ClosureLagsCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct ClosureLagsContext dcc = { .cb = cb, @@ -117,7 +119,7 @@ TAH_PG_get_auditor_closure_lags ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_closure_lags_get", + "auditor_closure_lags_get_desc", "SELECT" " row_id" ",amount" @@ -125,10 +127,27 @@ TAH_PG_get_auditor_closure_lags ( ",wtid" ",account" " FROM auditor_closure_lags" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_closure_lags_get_asc", + "SELECT" + " row_id" + ",amount" + ",deadline" + ",wtid" + ",account" + " FROM auditor_closure_lags" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_auditor_closure_lags_get", + (limit > 0) ? "auditor_auditor_closure_lags_get_asc" : "auditor_auditor_closure_lags_get_desc", params, &closure_lags_cb, &dcc); diff --git a/src/auditordb/pg_get_auditor_closure_lags.h b/src/auditordb/pg_get_auditor_closure_lags.h index 2497760ed..d94d8fa74 100644 --- a/src/auditordb/pg_get_auditor_closure_lags.h +++ b/src/auditordb/pg_get_auditor_closure_lags.h @@ -24,7 +24,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_auditor_closure_lags ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_ClosureLagsCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_coin_inconsistency.c b/src/auditordb/pg_get_coin_inconsistency.c index 949136ca3..0e6c45a18 100644 --- a/src/auditordb/pg_get_coin_inconsistency.c +++ b/src/auditordb/pg_get_coin_inconsistency.c @@ -106,19 +106,21 @@ coin_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_coin_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_CoinInconsistencyCallback cb, void *cb_cls) { printf ("checkpoint pg_0\n"); struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - // GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct CoinInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -129,7 +131,7 @@ TAH_PG_get_coin_inconsistency ( printf ("checkpoint pg_1\n"); PREPARE (pg, - "auditor_coin_inconsistency_select", + "auditor_coin_inconsistency_select_desc", "SELECT" " row_id" ",operation" @@ -138,10 +140,28 @@ TAH_PG_get_coin_inconsistency ( ",coin_pub" ",profitable" " FROM auditor_coin_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_coin_inconsistency_select_asc", + "SELECT" + " row_id" + ",operation" + ",exchange_amount" + ",auditor_amount" + ",coin_pub" + ",profitable" + " FROM auditor_coin_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_coin_inconsistency_select", + (limit > 0) ? "auditor_coin_inconsistency_select_asc" : "auditor_coin_inconsistency_select_desc", params, &coin_inconsistency_cb, &dcc); diff --git a/src/auditordb/pg_get_coin_inconsistency.h b/src/auditordb/pg_get_coin_inconsistency.h index f64b1aa1e..bff9b82b5 100644 --- a/src/auditordb/pg_get_coin_inconsistency.h +++ b/src/auditordb/pg_get_coin_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_coin_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_CoinInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c index 685e71381..94537b151 100644 --- a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c +++ b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.c @@ -97,19 +97,21 @@ denomination_key_validity_withdraw_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_denomination_key_validity_withdraw_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct DenominationKeyValidityWithdrawInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -118,17 +120,33 @@ TAH_PG_get_denomination_key_validity_withdraw_inconsistency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_denomination_key_validity_withdraw_inconsistency_get", + "auditor_denomination_key_validity_withdraw_inconsistency_get_desc", "SELECT" " row_id" ",execution_date" ",reserve_pub" ",denompub_h" " FROM auditor_denomination_key_validity_withdraw_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_denomination_key_validity_withdraw_inconsistency_get_asc", + "SELECT" + " row_id" + ",execution_date" + ",reserve_pub" + ",denompub_h" + " FROM auditor_denomination_key_validity_withdraw_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_denomination_key_validity_withdraw_inconsistency_get", + (limit > 0 ) ? "auditor_denomination_key_validity_withdraw_inconsistency_get_asc" : "auditor_denomination_key_validity_withdraw_inconsistency_get_desc", params, & denomination_key_validity_withdraw_inconsistency_cb, diff --git a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h index 0421eb3bc..ab40da401 100644 --- a/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h +++ b/src/auditordb/pg_get_denomination_key_validity_withdraw_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_denomination_key_validity_withdraw_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_denomination_pending.c b/src/auditordb/pg_get_denomination_pending.c new file mode 100644 index 000000000..e7b82fe9b --- /dev/null +++ b/src/auditordb/pg_get_denomination_pending.c @@ -0,0 +1,188 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_denomination_pending.h" + + +struct DenominationPendingContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_DenominationPendingCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_denomination_pending(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct DenominationPendingContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +denomination_pending_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct DenominationPendingContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_DenominationPending dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("denom_pub_hash", &dc.denom_pub_hash), +TALER_PQ_RESULT_SPEC_AMOUNT("denom_balance", &dc.denom_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("denom_loss", &dc.denom_loss), +GNUNET_PQ_result_spec_int64("num_issued", &dc.num_issued), +TALER_PQ_RESULT_SPEC_AMOUNT("denom_risk", &dc.denom_risk), +TALER_PQ_RESULT_SPEC_AMOUNT("recoup_loss", &dc.recoup_loss), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_denomination_pending ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_DenominationPendingCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct DenominationPendingContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_denomination_pending_get_desc", + "SELECT" + " denom_pub_hash," +" denom_balance," +" denom_loss," +" num_issued," +" denom_risk," +" recoup_loss," +" suppressed" + " FROM auditor_denomination_pending" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_denomination_pending_get_asc", + "SELECT" + " denom_pub_hash," +" denom_balance," +" denom_loss," +" num_issued," +" denom_risk," +" recoup_loss," +" suppressed" + " FROM auditor_denomination_pending" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_denomination_pending_get_asc" + : "auditor_denomination_pending_get_desc", + params, + &denomination_pending_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_denomination_pending.h b/src/auditordb/pg_get_denomination_pending.h new file mode 100644 index 000000000..ac157e676 --- /dev/null +++ b/src/auditordb/pg_get_denomination_pending.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_DENOMINATION_PENDING_H +#define SRC_PG_GET_DENOMINATION_PENDING_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about denomination-pending from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_denomination_pending ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_DenominationPendingCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_DENOMINATION_PENDING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_denominations_without_sigs.c b/src/auditordb/pg_get_denominations_without_sigs.c new file mode 100644 index 000000000..227c00d45 --- /dev/null +++ b/src/auditordb/pg_get_denominations_without_sigs.c @@ -0,0 +1,184 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_denominations_without_sigs.h" + + +struct DenominationsWithoutSigsContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_DenominationsWithoutSigsCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_denominations_without_sigs(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct DenominationsWithoutSigsContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +denominations_without_sigs_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct DenominationsWithoutSigsContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_DenominationsWithoutSigs dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("denompub_h", &dc.denompub_h), +TALER_PQ_RESULT_SPEC_AMOUNT("value", &dc.value), +GNUNET_PQ_result_spec_int64("start_time", &dc.start_time), +GNUNET_PQ_result_spec_int64("end_time", &dc.end_time), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_denominations_without_sigs ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_DenominationsWithoutSigsCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct DenominationsWithoutSigsContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_denominations_without_sigs_get_desc", + "SELECT" + " row_id," +" denompub_h," +" value," +" start_time," +" end_time," +" suppressed" + " FROM auditor_denominations_without_sigs" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_denominations_without_sigs_get_asc", + "SELECT" + " row_id," +" denompub_h," +" value," +" start_time," +" end_time," +" suppressed" + " FROM auditor_denominations_without_sigs" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_denominations_without_sigs_get_asc" + : "auditor_denominations_without_sigs_get_desc", + params, + &denominations_without_sigs_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_denominations_without_sigs.h b/src/auditordb/pg_get_denominations_without_sigs.h new file mode 100644 index 000000000..7186dee00 --- /dev/null +++ b/src/auditordb/pg_get_denominations_without_sigs.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_DENOMINATIONS_WITHOUT_SIGS_H +#define SRC_PG_GET_DENOMINATIONS_WITHOUT_SIGS_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about denominations-without-sigs from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_denominations_without_sigs ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_DenominationsWithoutSigsCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_DENOMINATIONS_WITHOUT_SIGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_deposit_confirmations.c b/src/auditordb/pg_get_deposit_confirmations.c index 0601056d9..e5158a69d 100644 --- a/src/auditordb/pg_get_deposit_confirmations.c +++ b/src/auditordb/pg_get_deposit_confirmations.c @@ -176,19 +176,19 @@ TAH_PG_get_deposit_confirmations ( "auditor_deposit_confirmation_select", "SELECT" " deposit_confirmation_serial_id" - // ",h_contract_terms" - // ",h_policy" - // ",h_wire" + ",h_contract_terms" + ",h_policy" + ",h_wire" ",exchange_timestamp" ",wire_deadline" ",refund_deadline" ",total_without_fee" - // ",coin_pubs" - // ",coin_sigs" - // ",merchant_pub" - // ",exchange_sig" - // ",exchange_pub" - // ",master_sig" + ",coin_pubs" + ",coin_sigs" + ",merchant_pub" + ",exchange_sig" + ",exchange_pub" + ",master_sig" " FROM auditor_deposit_confirmations" " WHERE deposit_confirmation_serial_id>$1" " AND ($2 OR NOT suppressed);"); diff --git a/src/auditordb/pg_get_emergency.c b/src/auditordb/pg_get_emergency.c index 7e44aade1..33a8de1f0 100644 --- a/src/auditordb/pg_get_emergency.c +++ b/src/auditordb/pg_get_emergency.c @@ -99,18 +99,20 @@ emergency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_emergency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_EmergencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct EmergencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -119,7 +121,7 @@ TAH_PG_get_emergency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_emergency_get", + "auditor_emergency_get_desc", "SELECT" " row_id" ",denompub_h" @@ -129,10 +131,29 @@ TAH_PG_get_emergency ( ",deposit_end" ",value" " FROM auditor_emergency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_emergency_get_asc", + "SELECT" + " row_id" + ",denompub_h" + ",denom_risk" + ",denom_loss" + ",deposit_start" + ",deposit_end" + ",value" + " FROM auditor_emergency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_emergency_get", + (limit > 0) ? "auditor_emergency_get_asc" : "auditor_emergency_get_desc", params, &emergency_cb, &dcc); diff --git a/src/auditordb/pg_get_emergency.h b/src/auditordb/pg_get_emergency.h index 86f01a7bc..64415750b 100644 --- a/src/auditordb/pg_get_emergency.h +++ b/src/auditordb/pg_get_emergency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_emergency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_EmergencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_emergency_by_count.c b/src/auditordb/pg_get_emergency_by_count.c index 56d83e16e..b056683c1 100644 --- a/src/auditordb/pg_get_emergency_by_count.c +++ b/src/auditordb/pg_get_emergency_by_count.c @@ -102,18 +102,20 @@ emergency_by_count_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_emergency_by_count ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_EmergenciesByCountCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct EmergencyByCountContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -122,7 +124,7 @@ TAH_PG_get_emergency_by_count ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_emergency_by_count_get", + "auditor_emergency_by_count_get_desc", "SELECT" " row_id" ",denompub_h" @@ -133,10 +135,30 @@ TAH_PG_get_emergency_by_count ( ",deposit_end" ",value" " FROM auditor_emergency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_emergency_by_count_get_asc", + "SELECT" + " row_id" + ",denompub_h" + ",num_issued" + ",num_known" + ",risk" + ",start" + ",deposit_end" + ",value" + " FROM auditor_emergency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_emergency_by_count_get", + (limit > 0) ? "auditor_emergency_by_count_get_asc" : "auditor_emergency_by_count_get_desc", params, &emergency_by_count_cb, &dcc); diff --git a/src/auditordb/pg_get_emergency_by_count.h b/src/auditordb/pg_get_emergency_by_count.h index 99944afa3..b6b4e0f04 100644 --- a/src/auditordb/pg_get_emergency_by_count.h +++ b/src/auditordb/pg_get_emergency_by_count.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_emergency_by_count ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_EmergenciesByCountCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_exchange_signkeys.c b/src/auditordb/pg_get_exchange_signkeys.c new file mode 100644 index 000000000..0d0ee64dd --- /dev/null +++ b/src/auditordb/pg_get_exchange_signkeys.c @@ -0,0 +1,185 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_exchange_signkeys.h" + + +struct ExchangeSignkeysContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ExchangeSignkeysCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_exchange_signkeys(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ExchangeSignkeysContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +exchange_signkeys_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ExchangeSignkeysContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ExchangeSignkeys dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("exchange_pub", &dc.exchange_pub), +GNUNET_PQ_result_spec_auto_from_type("master_sig", &dc.master_sig), +GNUNET_PQ_result_spec_int64("ep_valid_from", &dc.ep_valid_from), +GNUNET_PQ_result_spec_int64("ep_expire_sign", &dc.ep_expire_sign), +GNUNET_PQ_result_spec_int64("ep_expire_legal", &dc.ep_expire_legal), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_exchange_signkeys ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ExchangeSignkeysCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ExchangeSignkeysContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_exchange_signkeys_get_desc", + "SELECT" + " exchange_pub," +" master_sig," +" ep_valid_from," +" ep_expire_sign," +" ep_expire_legal," +" suppressed" + " FROM auditor_exchange_signkeys" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_exchange_signkeys_get_asc", + "SELECT" + " exchange_pub," +" master_sig," +" ep_valid_from," +" ep_expire_sign," +" ep_expire_legal," +" suppressed" + " FROM auditor_exchange_signkeys" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_exchange_signkeys_get_asc" + : "auditor_exchange_signkeys_get_desc", + params, + &exchange_signkeys_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_exchange_signkeys.h b/src/auditordb/pg_get_exchange_signkeys.h new file mode 100644 index 000000000..45d071b32 --- /dev/null +++ b/src/auditordb/pg_get_exchange_signkeys.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_EXCHANGE_SIGNKEYS_H +#define SRC_PG_GET_EXCHANGE_SIGNKEYS_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about exchange-signkeys from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_exchange_signkeys ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ExchangeSignkeysCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_EXCHANGE_SIGNKEYS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_fee_time_inconsistency.c b/src/auditordb/pg_get_fee_time_inconsistency.c index c24a4e54c..5b1a7aa3f 100644 --- a/src/auditordb/pg_get_fee_time_inconsistency.c +++ b/src/auditordb/pg_get_fee_time_inconsistency.c @@ -99,18 +99,20 @@ fee_time_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_fee_time_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_FeeTimeInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct FeeTimeInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -119,17 +121,33 @@ TAH_PG_get_fee_time_inconsistency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_fee_time_inconsistency_get", + "auditor_fee_time_inconsistency_get_desc", "SELECT" " row_id" ",type" ",time" ",diagnostic" " FROM auditor_fee_time_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_fee_time_inconsistency_get_asc", + "SELECT" + " row_id" + ",type" + ",time" + ",diagnostic" + " FROM auditor_fee_time_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_fee_time_inconsistency_get", + (limit > 0) ? "auditor_fee_time_inconsistency_get_asc" : "auditor_fee_time_inconsistency_get_desc", params, &fee_time_inconsistency_cb, &dcc); diff --git a/src/auditordb/pg_get_fee_time_inconsistency.h b/src/auditordb/pg_get_fee_time_inconsistency.h index 6d182432e..7c4796b4b 100644 --- a/src/auditordb/pg_get_fee_time_inconsistency.h +++ b/src/auditordb/pg_get_fee_time_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_fee_time_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_FeeTimeInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_historic_denomination_revenue.c b/src/auditordb/pg_get_historic_denomination_revenue.c new file mode 100644 index 000000000..ca14e88a0 --- /dev/null +++ b/src/auditordb/pg_get_historic_denomination_revenue.c @@ -0,0 +1,182 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_historic_denomination_revenue.h" + + +struct HistoricDenominationRevenueContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_HistoricDenominationRevenueCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_historic_denomination_revenue(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct HistoricDenominationRevenueContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +historic_denomination_revenue_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct HistoricDenominationRevenueContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_HistoricDenominationRevenue dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("denom_pub_hash", &dc.denom_pub_hash), +GNUNET_PQ_result_spec_int64("revenue_timestamp", &dc.revenue_timestamp), +TALER_PQ_RESULT_SPEC_AMOUNT("revenue_balance", &dc.revenue_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("loss_balance", &dc.loss_balance), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_historic_denomination_revenue ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_HistoricDenominationRevenueCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct HistoricDenominationRevenueContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_historic_denomination_revenue_get_desc", + "SELECT" + " denom_pub_hash," +" revenue_timestamp," +" revenue_balance," +" loss_balance," +" suppressed" + " FROM auditor_historic_denomination_revenue" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_historic_denomination_revenue_get_asc", + "SELECT" + " denom_pub_hash," +" revenue_timestamp," +" revenue_balance," +" loss_balance," +" suppressed" + " FROM auditor_historic_denomination_revenue" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_historic_denomination_revenue_get_asc" + : "auditor_historic_denomination_revenue_get_desc", + params, + &historic_denomination_revenue_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_historic_denomination_revenue.h b/src/auditordb/pg_get_historic_denomination_revenue.h new file mode 100644 index 000000000..82a73c8ec --- /dev/null +++ b/src/auditordb/pg_get_historic_denomination_revenue.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_HISTORIC_DENOMINATION_REVENUE_H +#define SRC_PG_GET_HISTORIC_DENOMINATION_REVENUE_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about historic-denomination-revenue from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_historic_denomination_revenue ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_HistoricDenominationRevenueCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_HISTORIC_DENOMINATION_REVENUE_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_historic_reserve_summary.c b/src/auditordb/pg_get_historic_reserve_summary.c new file mode 100644 index 000000000..454224533 --- /dev/null +++ b/src/auditordb/pg_get_historic_reserve_summary.c @@ -0,0 +1,179 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_historic_reserve_summary.h" + + +struct HistoricReserveSummaryContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_HistoricReserveSummaryCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_historic_reserve_summary(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct HistoricReserveSummaryContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +historic_reserve_summary_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct HistoricReserveSummaryContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_HistoricReserveSummary dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_int64("start_date", &dc.start_date), +GNUNET_PQ_result_spec_int64("end_date", &dc.end_date), +TALER_PQ_RESULT_SPEC_AMOUNT("reserve_profits", &dc.reserve_profits), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_historic_reserve_summary ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_HistoricReserveSummaryCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct HistoricReserveSummaryContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_historic_reserve_summary_get_desc", + "SELECT" + " start_date," +" end_date," +" reserve_profits," +" suppressed" + " FROM auditor_historic_reserve_summary" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_historic_reserve_summary_get_asc", + "SELECT" + " start_date," +" end_date," +" reserve_profits," +" suppressed" + " FROM auditor_historic_reserve_summary" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_historic_reserve_summary_get_asc" + : "auditor_historic_reserve_summary_get_desc", + params, + &historic_reserve_summary_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_historic_reserve_summary.h b/src/auditordb/pg_get_historic_reserve_summary.h new file mode 100644 index 000000000..c0e912268 --- /dev/null +++ b/src/auditordb/pg_get_historic_reserve_summary.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_HISTORIC_RESERVE_SUMMARY_H +#define SRC_PG_GET_HISTORIC_RESERVE_SUMMARY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about historic-reserve-summary from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_historic_reserve_summary ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_HistoricReserveSummaryCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_HISTORIC_RESERVE_SUMMARY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_misattribution_in_inconsistency.c b/src/auditordb/pg_get_misattribution_in_inconsistency.c new file mode 100644 index 000000000..a47b11306 --- /dev/null +++ b/src/auditordb/pg_get_misattribution_in_inconsistency.c @@ -0,0 +1,181 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_misattribution_in_inconsistency.h" + + +struct MisattributionInInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_MisattributionInInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_misattribution_in_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct MisattributionInInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +misattribution_in_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct MisattributionInInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_MisattributionInInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + TALER_PQ_RESULT_SPEC_AMOUNT("amount", &dc.amount), +GNUNET_PQ_result_spec_int64("bank_row", &dc.bank_row), +GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_misattribution_in_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_MisattributionInInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct MisattributionInInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_misattribution_in_inconsistency_get_desc", + "SELECT" + " row_id," +" amount," +" bank_row," +" reserve_pub," +" suppressed" + " FROM auditor_misattribution_in_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_misattribution_in_inconsistency_get_asc", + "SELECT" + " row_id," +" amount," +" bank_row," +" reserve_pub," +" suppressed" + " FROM auditor_misattribution_in_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_misattribution_in_inconsistency_get_asc" + : "auditor_misattribution_in_inconsistency_get_desc", + params, + &misattribution_in_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_misattribution_in_inconsistency.h b/src/auditordb/pg_get_misattribution_in_inconsistency.h new file mode 100644 index 000000000..54fb6c03e --- /dev/null +++ b/src/auditordb/pg_get_misattribution_in_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_MISATTRIBUTION_IN_INCONSISTENCY_H +#define SRC_PG_GET_MISATTRIBUTION_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about misattribution-in-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_misattribution_in_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_MisattributionInInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_MISATTRIBUTION_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_purse_not_closed_inconsistencies.c b/src/auditordb/pg_get_purse_not_closed_inconsistencies.c index 4ba51e0a3..7489f7ccb 100644 --- a/src/auditordb/pg_get_purse_not_closed_inconsistencies.c +++ b/src/auditordb/pg_get_purse_not_closed_inconsistencies.c @@ -100,18 +100,20 @@ purse_not_closed_inconsistencies_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_purse_not_closed_inconsistencies ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct PurseNotClosedInconsistenciesContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -120,17 +122,33 @@ TAH_PG_get_purse_not_closed_inconsistencies ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_purse_not_closed_inconsistencies_get", + "auditor_purse_not_closed_inconsistencies_get_desc", "SELECT" " row_id" ",purse_pub" ",amount" ",expiration_date" " FROM auditor_purse_not_closed_inconsistencies" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_purse_not_closed_inconsistencies_get_asc", + "SELECT" + " row_id" + ",purse_pub" + ",amount" + ",expiration_date" + " FROM auditor_purse_not_closed_inconsistencies" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_purse_not_closed_inconsistencies_get", + (limit > 0) ? "auditor_purse_not_closed_inconsistencies_get_asc" : "auditor_purse_not_closed_inconsistencies_get_desc", params, & purse_not_closed_inconsistencies_cb, diff --git a/src/auditordb/pg_get_purse_not_closed_inconsistencies.h b/src/auditordb/pg_get_purse_not_closed_inconsistencies.h index 188180485..658aeea80 100644 --- a/src/auditordb/pg_get_purse_not_closed_inconsistencies.h +++ b/src/auditordb/pg_get_purse_not_closed_inconsistencies.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_purse_not_closed_inconsistencies ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_purses.c b/src/auditordb/pg_get_purses.c new file mode 100644 index 000000000..a977a1a94 --- /dev/null +++ b/src/auditordb/pg_get_purses.c @@ -0,0 +1,185 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_purses.h" + + +struct PursesContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_PursesCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_purses(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct PursesContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +purses_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct PursesContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_Purses dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_int64("auditor_purses_rowid", &dc.auditor_purses_rowid), +GNUNET_PQ_result_spec_auto_from_type("purse_pub", &dc.purse_pub), +TALER_PQ_RESULT_SPEC_AMOUNT("balance", &dc.balance), +TALER_PQ_RESULT_SPEC_AMOUNT("target", &dc.target), +GNUNET_PQ_result_spec_int64("expiration_date", &dc.expiration_date), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_purses ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_PursesCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct PursesContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_purses_get_desc", + "SELECT" + " auditor_purses_rowid," +" purse_pub," +" balance," +" target," +" expiration_date," +" suppressed" + " FROM auditor_purses" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_purses_get_asc", + "SELECT" + " auditor_purses_rowid," +" purse_pub," +" balance," +" target," +" expiration_date," +" suppressed" + " FROM auditor_purses" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_purses_get_asc" + : "auditor_purses_get_desc", + params, + &purses_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_purses.h b/src/auditordb/pg_get_purses.h new file mode 100644 index 000000000..1890d9bb8 --- /dev/null +++ b/src/auditordb/pg_get_purses.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_PURSES_H +#define SRC_PG_GET_PURSES_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about purses from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_purses ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_PursesCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_PURSES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_refreshes_hanging.c b/src/auditordb/pg_get_refreshes_hanging.c index 5c88966f4..d4dd83b67 100644 --- a/src/auditordb/pg_get_refreshes_hanging.c +++ b/src/auditordb/pg_get_refreshes_hanging.c @@ -98,18 +98,20 @@ refreshes_hanging_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_refreshes_hanging ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_RefreshesHangingCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct RefreshesHangingContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -118,16 +120,31 @@ TAH_PG_get_refreshes_hanging ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_refreshes_hanging_get", + "auditor_refreshes_hanging_get_desc", "SELECT" " row_id" ",amount" ",coin_pub" " FROM auditor_refreshes_hanging" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_refreshes_hanging_get_asc", + "SELECT" + " row_id" + ",amount" + ",coin_pub" + " FROM auditor_refreshes_hanging" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_refreshes_hanging_get", + (limit > 0) ? "auditor_refreshes_hanging_get_asc" : "auditor_refreshes_hanging_get_desc", params, &refreshes_hanging_cb, &dcc); diff --git a/src/auditordb/pg_get_refreshes_hanging.h b/src/auditordb/pg_get_refreshes_hanging.h index 2dd72ed8d..7603c9b3d 100644 --- a/src/auditordb/pg_get_refreshes_hanging.h +++ b/src/auditordb/pg_get_refreshes_hanging.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_refreshes_hanging ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_RefreshesHangingCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c index 250af182d..4182e5dc9 100644 --- a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c +++ b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c @@ -100,18 +100,20 @@ reserve_balance_insufficient_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_reserve_balance_insufficient_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - // GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct ReserveBalanceInsufficientInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -120,17 +122,33 @@ TAH_PG_get_reserve_balance_insufficient_inconsistency ( enum GNUNET_DB_QueryStatus qs; PREPARE (pg, - "auditor_reserve_balance_insufficient_inconsistency_get", + "auditor_reserve_balance_insufficient_inconsistency_get_desc", "SELECT" " row_id" ",reserve_pub" ",inconsistency_gain" ",inconsistency_amount" " FROM auditor_reserve_balance_insufficient_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_reserve_balance_insufficient_inconsistency_get_asc", + "SELECT" + " row_id" + ",reserve_pub" + ",inconsistency_gain" + ",inconsistency_amount" + " FROM auditor_reserve_balance_insufficient_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_reserve_balance_insufficient_inconsistency_get", + (limit > 0) ? "auditor_reserve_balance_insufficient_inconsistency_get_asc" : "auditor_reserve_balance_insufficient_inconsistency_get_desc", params, & reserve_balance_insufficient_inconsistency_cb, diff --git a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h index 892e75cee..5133f8149 100644 --- a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h +++ b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_reserve_balance_insufficient_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c new file mode 100644 index 000000000..5e7ac3533 --- /dev/null +++ b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,181 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_reserve_balance_summary_wrong_inconsistency.h" + + +struct ReserveBalanceSummaryWrongInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_reserve_balance_summary_wrong_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ReserveBalanceSummaryWrongInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +reserve_balance_summary_wrong_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ReserveBalanceSummaryWrongInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +TALER_PQ_RESULT_SPEC_AMOUNT("exchange_amount", &dc.exchange_amount), +TALER_PQ_RESULT_SPEC_AMOUNT("auditor_amount", &dc.auditor_amount), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_balance_summary_wrong_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ReserveBalanceSummaryWrongInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_reserve_balance_summary_wrong_inconsistency_get_desc", + "SELECT" + " row_id," +" reserve_pub," +" exchange_amount," +" auditor_amount," +" suppressed" + " FROM auditor_reserve_balance_summary_wrong_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_reserve_balance_summary_wrong_inconsistency_get_asc", + "SELECT" + " row_id," +" reserve_pub," +" exchange_amount," +" auditor_amount," +" suppressed" + " FROM auditor_reserve_balance_summary_wrong_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_reserve_balance_summary_wrong_inconsistency_get_asc" + : "auditor_reserve_balance_summary_wrong_inconsistency_get_desc", + params, + &reserve_balance_summary_wrong_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.h b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.h new file mode 100644 index 000000000..2b70e556e --- /dev/null +++ b/src/auditordb/pg_get_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H +#define SRC_PG_GET_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about reserve-balance-summary-wrong-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_balance_summary_wrong_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_in_inconsistency.c b/src/auditordb/pg_get_reserve_in_inconsistency.c new file mode 100644 index 000000000..22950f537 --- /dev/null +++ b/src/auditordb/pg_get_reserve_in_inconsistency.c @@ -0,0 +1,190 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_reserve_in_inconsistency.h" + + +struct ReserveInInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ReserveInInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_reserve_in_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ReserveInInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +reserve_in_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ReserveInInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ReserveInInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + TALER_PQ_RESULT_SPEC_AMOUNT("amount_exchange_expected", &dc.amount_exchange_expected), +TALER_PQ_RESULT_SPEC_AMOUNT("amount_wired", &dc.amount_wired), +GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +GNUNET_PQ_result_spec_int64("timestamp", &dc.timestamp), +GNUNET_PQ_result_spec_auto_from_type("account", &dc.account), +GNUNET_PQ_result_spec_auto_from_type("diagnostic", &dc.diagnostic), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_in_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ReserveInInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ReserveInInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_reserve_in_inconsistency_get_desc", + "SELECT" + " row_id," +" amount_exchange_expected," +" amount_wired," +" reserve_pub," +" timestamp," +" account," +" diagnostic," +" suppressed" + " FROM auditor_reserve_in_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_reserve_in_inconsistency_get_asc", + "SELECT" + " row_id," +" amount_exchange_expected," +" amount_wired," +" reserve_pub," +" timestamp," +" account," +" diagnostic," +" suppressed" + " FROM auditor_reserve_in_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_reserve_in_inconsistency_get_asc" + : "auditor_reserve_in_inconsistency_get_desc", + params, + &reserve_in_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_in_inconsistency.h b/src/auditordb/pg_get_reserve_in_inconsistency.h new file mode 100644 index 000000000..2313ce090 --- /dev/null +++ b/src/auditordb/pg_get_reserve_in_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_RESERVE_IN_INCONSISTENCY_H +#define SRC_PG_GET_RESERVE_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about reserve-in-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_in_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveInInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_RESERVE_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_not_closed_inconsistency.c b/src/auditordb/pg_get_reserve_not_closed_inconsistency.c new file mode 100644 index 000000000..ebef6697f --- /dev/null +++ b/src/auditordb/pg_get_reserve_not_closed_inconsistency.c @@ -0,0 +1,184 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_reserve_not_closed_inconsistency.h" + + +struct ReserveNotClosedInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_reserve_not_closed_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ReserveNotClosedInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +reserve_not_closed_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ReserveNotClosedInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_ReserveNotClosedInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +TALER_PQ_RESULT_SPEC_AMOUNT("balance", &dc.balance), +GNUNET_PQ_result_spec_int64("expiration_time", &dc.expiration_time), +GNUNET_PQ_result_spec_auto_from_type("diagnostic", &dc.diagnostic), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_not_closed_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ReserveNotClosedInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_reserve_not_closed_inconsistency_get_desc", + "SELECT" + " row_id," +" reserve_pub," +" balance," +" expiration_time," +" diagnostic," +" suppressed" + " FROM auditor_reserve_not_closed_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_reserve_not_closed_inconsistency_get_asc", + "SELECT" + " row_id," +" reserve_pub," +" balance," +" expiration_time," +" diagnostic," +" suppressed" + " FROM auditor_reserve_not_closed_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_reserve_not_closed_inconsistency_get_asc" + : "auditor_reserve_not_closed_inconsistency_get_desc", + params, + &reserve_not_closed_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserve_not_closed_inconsistency.h b/src/auditordb/pg_get_reserve_not_closed_inconsistency.h new file mode 100644 index 000000000..6dc28f46b --- /dev/null +++ b/src/auditordb/pg_get_reserve_not_closed_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_RESERVE_NOT_CLOSED_INCONSISTENCY_H +#define SRC_PG_GET_RESERVE_NOT_CLOSED_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about reserve-not-closed-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserve_not_closed_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_RESERVE_NOT_CLOSED_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserves.c b/src/auditordb/pg_get_reserves.c new file mode 100644 index 000000000..8eefba898 --- /dev/null +++ b/src/auditordb/pg_get_reserves.c @@ -0,0 +1,203 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_reserves.h" + + +struct ReservesContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_ReservesCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_reserves(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct ReservesContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +reserves_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct ReservesContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_Reserves dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_int64("auditor_reserves_rowid", &dc.auditor_reserves_rowid), +GNUNET_PQ_result_spec_auto_from_type("reserve_pub", &dc.reserve_pub), +TALER_PQ_RESULT_SPEC_AMOUNT("reserve_balance", &dc.reserve_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("reserve_loss", &dc.reserve_loss), +TALER_PQ_RESULT_SPEC_AMOUNT("withdraw_fee_balance", &dc.withdraw_fee_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("close_fee_balance", &dc.close_fee_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("purse_fee_balance", &dc.purse_fee_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("open_fee_balance", &dc.open_fee_balance), +TALER_PQ_RESULT_SPEC_AMOUNT("history_fee_balance", &dc.history_fee_balance), +GNUNET_PQ_result_spec_int64("expiration_date", &dc.expiration_date), +GNUNET_PQ_result_spec_string("origin_account", &dc.origin_account), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserves ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_ReservesCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct ReservesContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_reserves_get_desc", + "SELECT" + " auditor_reserves_rowid," +" reserve_pub," +" reserve_balance," +" reserve_loss," +" withdraw_fee_balance," +" close_fee_balance," +" purse_fee_balance," +" open_fee_balance," +" history_fee_balance," +" expiration_date," +" origin_account," +" suppressed" + " FROM auditor_reserves" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_reserves_get_asc", + "SELECT" + " auditor_reserves_rowid," +" reserve_pub," +" reserve_balance," +" reserve_loss," +" withdraw_fee_balance," +" close_fee_balance," +" purse_fee_balance," +" open_fee_balance," +" history_fee_balance," +" expiration_date," +" origin_account," +" suppressed" + " FROM auditor_reserves" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_reserves_get_asc" + : "auditor_reserves_get_desc", + params, + &reserves_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_reserves.h b/src/auditordb/pg_get_reserves.h new file mode 100644 index 000000000..0fe15fddd --- /dev/null +++ b/src/auditordb/pg_get_reserves.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_RESERVES_H +#define SRC_PG_GET_RESERVES_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about reserves from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_reserves ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReservesCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_RESERVES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_row_inconsistency.c b/src/auditordb/pg_get_row_inconsistency.c index 922880da8..67f83f6ed 100644 --- a/src/auditordb/pg_get_row_inconsistency.c +++ b/src/auditordb/pg_get_row_inconsistency.c @@ -99,18 +99,20 @@ row_inconsistency_cb (void *cls, enum GNUNET_DB_QueryStatus TAH_PG_get_row_inconsistency ( void *cls, - uint64_t start_id, - bool return_suppressed, // maybe not needed + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed TALER_AUDITORDB_RowInconsistencyCallback cb, void *cb_cls) { struct PostgresClosure *pg = cls; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&start_id), - // GNUNET_PQ_query_param_bool (return_suppressed), - GNUNET_PQ_query_param_end - }; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; struct RowInconsistencyContext dcc = { .cb = cb, .cb_cls = cb_cls, @@ -120,16 +122,31 @@ TAH_PG_get_row_inconsistency ( PREPARE (pg, - "auditor_row_inconsistency_select", + "auditor_row_inconsistency_select_desc", "SELECT" " row_id" ",row_table" ",diagnostic" " FROM auditor_row_inconsistency" - " WHERE row_id>$1" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" ); + PREPARE (pg, + "auditor_row_inconsistency_select_asc", + "SELECT" + " row_id" + ",row_table" + ",diagnostic" + " FROM auditor_row_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, - "auditor_row_inconsistency_select", + (limit > 0) ? "auditor_row_inconsistency_select_asc" : "auditor_row_inconsistency_select_desc", params, &row_inconsistency_cb, &dcc); diff --git a/src/auditordb/pg_get_row_inconsistency.h b/src/auditordb/pg_get_row_inconsistency.h index 7bfd37e32..ef0136f39 100644 --- a/src/auditordb/pg_get_row_inconsistency.h +++ b/src/auditordb/pg_get_row_inconsistency.h @@ -22,7 +22,8 @@ enum GNUNET_DB_QueryStatus TAH_PG_get_row_inconsistency ( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_RowInconsistencyCallback cb, void *cb_cls); diff --git a/src/auditordb/pg_get_row_minor_inconsistencies.c b/src/auditordb/pg_get_row_minor_inconsistencies.c new file mode 100644 index 000000000..002abbda3 --- /dev/null +++ b/src/auditordb/pg_get_row_minor_inconsistencies.c @@ -0,0 +1,178 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_row_minor_inconsistencies.h" + + +struct RowMinorInconsistenciesContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_RowMinorInconsistenciesCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_row_minor_inconsistencies(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct RowMinorInconsistenciesContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +row_minor_inconsistencies_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct RowMinorInconsistenciesContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_RowMinorInconsistencies dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("row_table", &dc.row_table), +GNUNET_PQ_result_spec_auto_from_type("diagnostic", &dc.diagnostic), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_row_minor_inconsistencies ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_RowMinorInconsistenciesCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct RowMinorInconsistenciesContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_row_minor_inconsistencies_get_desc", + "SELECT" + " row_id," +" row_table," +" diagnostic," +" suppressed" + " FROM auditor_row_minor_inconsistencies" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_row_minor_inconsistencies_get_asc", + "SELECT" + " row_id," +" row_table," +" diagnostic," +" suppressed" + " FROM auditor_row_minor_inconsistencies" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_row_minor_inconsistencies_get_asc" + : "auditor_row_minor_inconsistencies_get_desc", + params, + &row_minor_inconsistencies_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_row_minor_inconsistencies.h b/src/auditordb/pg_get_row_minor_inconsistencies.h new file mode 100644 index 000000000..5c71b3f78 --- /dev/null +++ b/src/auditordb/pg_get_row_minor_inconsistencies.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_ROW_MINOR_INCONSISTENCIES_H +#define SRC_PG_GET_ROW_MINOR_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about row-minor-inconsistencies from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_row_minor_inconsistencies ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_RowMinorInconsistenciesCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_ROW_MINOR_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_wire_format_inconsistency.c b/src/auditordb/pg_get_wire_format_inconsistency.c new file mode 100644 index 000000000..ec443616e --- /dev/null +++ b/src/auditordb/pg_get_wire_format_inconsistency.c @@ -0,0 +1,181 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_wire_format_inconsistency.h" + + +struct WireFormatInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_WireFormatInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_wire_format_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct WireFormatInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +wire_format_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct WireFormatInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_WireFormatInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + TALER_PQ_RESULT_SPEC_AMOUNT("amount", &dc.amount), +GNUNET_PQ_result_spec_int64("wire_offset", &dc.wire_offset), +GNUNET_PQ_result_spec_auto_from_type("diagnostic", &dc.diagnostic), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_wire_format_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_WireFormatInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct WireFormatInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_wire_format_inconsistency_get_desc", + "SELECT" + " row_id," +" amount," +" wire_offset," +" diagnostic," +" suppressed" + " FROM auditor_wire_format_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_wire_format_inconsistency_get_asc", + "SELECT" + " row_id," +" amount," +" wire_offset," +" diagnostic," +" suppressed" + " FROM auditor_wire_format_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_wire_format_inconsistency_get_asc" + : "auditor_wire_format_inconsistency_get_desc", + params, + &wire_format_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_wire_format_inconsistency.h b/src/auditordb/pg_get_wire_format_inconsistency.h new file mode 100644 index 000000000..ce4bc303a --- /dev/null +++ b/src/auditordb/pg_get_wire_format_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_WIRE_FORMAT_INCONSISTENCY_H +#define SRC_PG_GET_WIRE_FORMAT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about wire-format-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_wire_format_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_WireFormatInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_WIRE_FORMAT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_wire_out_inconsistency.c b/src/auditordb/pg_get_wire_out_inconsistency.c new file mode 100644 index 000000000..f9394375d --- /dev/null +++ b/src/auditordb/pg_get_wire_out_inconsistency.c @@ -0,0 +1,181 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_error_codes.h" +#include "taler_dbevents.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_get_wire_out_inconsistency.h" + + +struct WireOutInconsistencyContext +{ + + /** + * Function to call for each bad sig loss. + */ + TALER_AUDITORDB_WireOutInconsistencyCallback cb; + + /** + * Closure for @e cb + */ + void *cb_cls; + + /** + * Plugin context. + */ + struct PostgresClosure *pg; + + /** + * Query status to return. + */ + enum GNUNET_DB_QueryStatus qs; +}; + + +/** + * Helper function for #TAH_PG_get_wire_out_inconsistency(). + * To be called with the results of a SELECT statement + * that has returned @a num_results results. + * + * @param cls closure of type `struct WireOutInconsistencyContext *` + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +wire_out_inconsistency_cb (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct WireOutInconsistencyContext *dcc = cls; + struct PostgresClosure *pg = dcc->pg; + + for (unsigned int i = 0; i < num_results; i++) + { + uint64_t serial_id; + + struct TALER_AUDITORDB_WireOutInconsistency dc; + + struct GNUNET_PQ_ResultSpec rs[] = { + + GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), + + GNUNET_PQ_result_spec_auto_from_type("destination_account", &dc.destination_account), +TALER_PQ_RESULT_SPEC_AMOUNT("expected", &dc.expected), +TALER_PQ_RESULT_SPEC_AMOUNT("claimed", &dc.claimed), +GNUNET_PQ_result_spec_bool("suppressed", &dc.suppressed), + + + GNUNET_PQ_result_spec_end + }; + enum GNUNET_GenericReturnValue rval; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + return; + } + + dcc->qs = i + 1; + + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) + break; + } +} + + +enum GNUNET_DB_QueryStatus +TAH_PG_get_wire_out_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, // maybe not needed + TALER_AUDITORDB_WireOutInconsistencyCallback cb, + void *cb_cls) +{ + + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&offset), + GNUNET_PQ_query_param_bool (return_suppressed), + GNUNET_PQ_query_param_int64 (&limit), + GNUNET_PQ_query_param_end + }; + struct WireOutInconsistencyContext dcc = { + .cb = cb, + .cb_cls = cb_cls, + .pg = pg + }; + enum GNUNET_DB_QueryStatus qs; + + PREPARE (pg, + "auditor_wire_out_inconsistency_get_desc", + "SELECT" + " row_id," +" destination_account," +" expected," +" claimed," +" suppressed" + " FROM auditor_wire_out_inconsistency" + " WHERE (row_id < $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id DESC" + " LIMIT $3" + ); + PREPARE (pg, + "auditor_wire_out_inconsistency_get_asc", + "SELECT" + " row_id," +" destination_account," +" expected," +" claimed," +" suppressed" + " FROM auditor_wire_out_inconsistency" + " WHERE (row_id > $1)" + " AND ($2 OR suppressed is false)" + " ORDER BY row_id ASC" + " LIMIT $3" + ); + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, + (limit > 0) + ? "auditor_wire_out_inconsistency_get_asc" + : "auditor_wire_out_inconsistency_get_desc", + params, + &wire_out_inconsistency_cb, + &dcc); + + if (qs > 0) + return dcc.qs; + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); + return qs; +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_get_wire_out_inconsistency.h b/src/auditordb/pg_get_wire_out_inconsistency.h new file mode 100644 index 000000000..0fd8562b1 --- /dev/null +++ b/src/auditordb/pg_get_wire_out_inconsistency.h @@ -0,0 +1,51 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_GET_WIRE_OUT_INCONSISTENCY_H +#define SRC_PG_GET_WIRE_OUT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_json_lib.h" +#include "taler_auditordb_plugin.h" + +/** + * Get information about wire-out-inconsistency from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param start_id row/serial ID where to start the iteration (0 from + * the start, exclusive, i.e. serial_ids must start from 1) + * @param return_suppressed should suppressed rows be returned anyway? + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_get_wire_out_inconsistency ( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_WireOutInconsistencyCallback cb, + void *cb_cls); + +#endif // SRC_PG_GET_WIRE_OUT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_denomination_pending.c b/src/auditordb/pg_insert_denomination_pending.c new file mode 100644 index 000000000..70a9981d7 --- /dev/null +++ b/src/auditordb/pg_insert_denomination_pending.c @@ -0,0 +1,64 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_denomination_pending.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_denomination_pending ( + void *cls, + const struct TALER_AUDITORDB_DenominationPending *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->denom_pub_hash), +TALER_PQ_query_param_amount(pg->conn, &dc->denom_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->denom_loss), +GNUNET_PQ_query_param_int64(&dc->num_issued), +TALER_PQ_query_param_amount(pg->conn, &dc->denom_risk), +TALER_PQ_query_param_amount(pg->conn, &dc->recoup_loss), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_denomination_pending_insert", + "INSERT INTO auditor_denomination_pending " + "( denom_pub_hash," +" denom_balance," +" denom_loss," +" num_issued," +" denom_risk," +" recoup_loss," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6,$7);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_denomination_pending_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_denomination_pending.h b/src/auditordb/pg_insert_denomination_pending.h new file mode 100644 index 000000000..32f498f08 --- /dev/null +++ b/src/auditordb/pg_insert_denomination_pending.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_DENOMINATION_PENDING_H +#define SRC_PG_INSERT_DENOMINATION_PENDING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_denomination_pending ( + void *cls, + const struct TALER_AUDITORDB_DenominationPending *dc); + +#endif // SRC_PG_INSERT_DENOMINATION_PENDING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_denominations_without_sigs.c b/src/auditordb/pg_insert_denominations_without_sigs.c new file mode 100644 index 000000000..e22e4ffe9 --- /dev/null +++ b/src/auditordb/pg_insert_denominations_without_sigs.c @@ -0,0 +1,61 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_denominations_without_sigs.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_denominations_without_sigs ( + void *cls, + const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->denompub_h), +TALER_PQ_query_param_amount(pg->conn, &dc->value), +GNUNET_PQ_query_param_int64(&dc->start_time), +GNUNET_PQ_query_param_int64(&dc->end_time), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_denominations_without_sigs_insert", + "INSERT INTO auditor_denominations_without_sigs " + "( row_id," +" denompub_h," +" value," +" start_time," +" end_time," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_denominations_without_sigs_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_denominations_without_sigs.h b/src/auditordb/pg_insert_denominations_without_sigs.h new file mode 100644 index 000000000..eb56f74a6 --- /dev/null +++ b/src/auditordb/pg_insert_denominations_without_sigs.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_DENOMINATIONS_WITHOUT_SIGS_H +#define SRC_PG_INSERT_DENOMINATIONS_WITHOUT_SIGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_denominations_without_sigs ( + void *cls, + const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc); + +#endif // SRC_PG_INSERT_DENOMINATIONS_WITHOUT_SIGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_exchange_signkeys.c b/src/auditordb/pg_insert_exchange_signkeys.c new file mode 100644 index 000000000..09ab0e941 --- /dev/null +++ b/src/auditordb/pg_insert_exchange_signkeys.c @@ -0,0 +1,62 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_exchange_signkeys.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_exchange_signkeys ( + void *cls, + const struct TALER_AUDITORDB_ExchangeSignkeys *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->exchange_pub), +GNUNET_PQ_query_param_auto_from_type(&dc->master_sig), +GNUNET_PQ_query_param_int64(&dc->ep_valid_from), +GNUNET_PQ_query_param_int64(&dc->ep_expire_sign), +GNUNET_PQ_query_param_int64(&dc->ep_expire_legal), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_exchange_signkeys_insert", + "INSERT INTO auditor_exchange_signkeys " + "( exchange_pub," +" master_sig," +" ep_valid_from," +" ep_expire_sign," +" ep_expire_legal," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_exchange_signkeys_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_exchange_signkeys.h b/src/auditordb/pg_insert_exchange_signkeys.h new file mode 100644 index 000000000..62df3aaac --- /dev/null +++ b/src/auditordb/pg_insert_exchange_signkeys.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_EXCHANGE_SIGNKEYS_H +#define SRC_PG_INSERT_EXCHANGE_SIGNKEYS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_exchange_signkeys ( + void *cls, + const struct TALER_AUDITORDB_ExchangeSignkeys *dc); + +#endif // SRC_PG_INSERT_EXCHANGE_SIGNKEYS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_historic_denomination_revenue.c b/src/auditordb/pg_insert_historic_denomination_revenue.c new file mode 100644 index 000000000..c7779c9b3 --- /dev/null +++ b/src/auditordb/pg_insert_historic_denomination_revenue.c @@ -0,0 +1,60 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_historic_denomination_revenue.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_historic_denomination_revenue ( + void *cls, + const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->denom_pub_hash), +GNUNET_PQ_query_param_int64(&dc->revenue_timestamp), +TALER_PQ_query_param_amount(pg->conn, &dc->revenue_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->loss_balance), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_historic_denomination_revenue_insert", + "INSERT INTO auditor_historic_denomination_revenue " + "( denom_pub_hash," +" revenue_timestamp," +" revenue_balance," +" loss_balance," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_historic_denomination_revenue_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_historic_denomination_revenue.h b/src/auditordb/pg_insert_historic_denomination_revenue.h new file mode 100644 index 000000000..0e21ef3e3 --- /dev/null +++ b/src/auditordb/pg_insert_historic_denomination_revenue.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_HISTORIC_DENOMINATION_REVENUE_H +#define SRC_PG_INSERT_HISTORIC_DENOMINATION_REVENUE_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_historic_denomination_revenue ( + void *cls, + const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc); + +#endif // SRC_PG_INSERT_HISTORIC_DENOMINATION_REVENUE_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_historic_reserve_summary.c b/src/auditordb/pg_insert_historic_reserve_summary.c new file mode 100644 index 000000000..420b6223c --- /dev/null +++ b/src/auditordb/pg_insert_historic_reserve_summary.c @@ -0,0 +1,58 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_historic_reserve_summary.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_historic_reserve_summary ( + void *cls, + const struct TALER_AUDITORDB_HistoricReserveSummary *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_int64(&dc->start_date), +GNUNET_PQ_query_param_int64(&dc->end_date), +TALER_PQ_query_param_amount(pg->conn, &dc->reserve_profits), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_historic_reserve_summary_insert", + "INSERT INTO auditor_historic_reserve_summary " + "( start_date," +" end_date," +" reserve_profits," +" suppressed" +") VALUES ($1,$2,$3,$4);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_historic_reserve_summary_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_historic_reserve_summary.h b/src/auditordb/pg_insert_historic_reserve_summary.h new file mode 100644 index 000000000..c3f360b98 --- /dev/null +++ b/src/auditordb/pg_insert_historic_reserve_summary.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_HISTORIC_RESERVE_SUMMARY_H +#define SRC_PG_INSERT_HISTORIC_RESERVE_SUMMARY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_historic_reserve_summary ( + void *cls, + const struct TALER_AUDITORDB_HistoricReserveSummary *dc); + +#endif // SRC_PG_INSERT_HISTORIC_RESERVE_SUMMARY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_misattribution_in_inconsistency.c b/src/auditordb/pg_insert_misattribution_in_inconsistency.c new file mode 100644 index 000000000..45eb8c004 --- /dev/null +++ b/src/auditordb/pg_insert_misattribution_in_inconsistency.c @@ -0,0 +1,59 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_misattribution_in_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_misattribution_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_MisattributionInInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + TALER_PQ_query_param_amount(pg->conn, &dc->amount), +GNUNET_PQ_query_param_int64(&dc->bank_row), +GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_misattribution_in_inconsistency_insert", + "INSERT INTO auditor_misattribution_in_inconsistency " + "( row_id," +" amount," +" bank_row," +" reserve_pub," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_misattribution_in_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_misattribution_in_inconsistency.h b/src/auditordb/pg_insert_misattribution_in_inconsistency.h new file mode 100644 index 000000000..d631e8007 --- /dev/null +++ b/src/auditordb/pg_insert_misattribution_in_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_MISATTRIBUTION_IN_INCONSISTENCY_H +#define SRC_PG_INSERT_MISATTRIBUTION_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_misattribution_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_MisattributionInInconsistency *dc); + +#endif // SRC_PG_INSERT_MISATTRIBUTION_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_purses.c b/src/auditordb/pg_insert_purses.c new file mode 100644 index 000000000..e32b33bd5 --- /dev/null +++ b/src/auditordb/pg_insert_purses.c @@ -0,0 +1,62 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_purses.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_purses ( + void *cls, + const struct TALER_AUDITORDB_Purses *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_int64(&dc->auditor_purses_rowid), +GNUNET_PQ_query_param_auto_from_type(&dc->purse_pub), +TALER_PQ_query_param_amount(pg->conn, &dc->balance), +TALER_PQ_query_param_amount(pg->conn, &dc->target), +GNUNET_PQ_query_param_int64(&dc->expiration_date), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_purses_insert", + "INSERT INTO auditor_purses " + "( auditor_purses_rowid," +" purse_pub," +" balance," +" target," +" expiration_date," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_purses_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_purses.h b/src/auditordb/pg_insert_purses.h new file mode 100644 index 000000000..7fd1f0ab4 --- /dev/null +++ b/src/auditordb/pg_insert_purses.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_PURSES_H +#define SRC_PG_INSERT_PURSES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_purses ( + void *cls, + const struct TALER_AUDITORDB_Purses *dc); + +#endif // SRC_PG_INSERT_PURSES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.c new file mode 100644 index 000000000..34419d062 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,59 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_reserve_balance_summary_wrong_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_balance_summary_wrong_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +TALER_PQ_query_param_amount(pg->conn, &dc->exchange_amount), +TALER_PQ_query_param_amount(pg->conn, &dc->auditor_amount), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserve_balance_summary_wrong_inconsistency_insert", + "INSERT INTO auditor_reserve_balance_summary_wrong_inconsistency " + "( row_id," +" reserve_pub," +" exchange_amount," +" auditor_amount," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_balance_summary_wrong_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.h b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.h new file mode 100644 index 000000000..30281f2cf --- /dev/null +++ b/src/auditordb/pg_insert_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H +#define SRC_PG_INSERT_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_balance_summary_wrong_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc); + +#endif // SRC_PG_INSERT_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_in_inconsistency.c b/src/auditordb/pg_insert_reserve_in_inconsistency.c new file mode 100644 index 000000000..0b69f10e9 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_in_inconsistency.c @@ -0,0 +1,65 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_reserve_in_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveInInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + TALER_PQ_query_param_amount(pg->conn, &dc->amount_exchange_expected), +TALER_PQ_query_param_amount(pg->conn, &dc->amount_wired), +GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +GNUNET_PQ_query_param_int64(&dc->timestamp), +GNUNET_PQ_query_param_auto_from_type(&dc->account), +GNUNET_PQ_query_param_auto_from_type(&dc->diagnostic), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserve_in_inconsistency_insert", + "INSERT INTO auditor_reserve_in_inconsistency " + "( row_id," +" amount_exchange_expected," +" amount_wired," +" reserve_pub," +" timestamp," +" account," +" diagnostic," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_in_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_in_inconsistency.h b/src/auditordb/pg_insert_reserve_in_inconsistency.h new file mode 100644 index 000000000..83856507a --- /dev/null +++ b/src/auditordb/pg_insert_reserve_in_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_RESERVE_IN_INCONSISTENCY_H +#define SRC_PG_INSERT_RESERVE_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveInInconsistency *dc); + +#endif // SRC_PG_INSERT_RESERVE_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c new file mode 100644 index 000000000..6f35e6f77 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.c @@ -0,0 +1,61 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_reserve_not_closed_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_not_closed_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +TALER_PQ_query_param_amount(pg->conn, &dc->balance), +GNUNET_PQ_query_param_int64(&dc->expiration_time), +GNUNET_PQ_query_param_auto_from_type(&dc->diagnostic), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserve_not_closed_inconsistency_insert", + "INSERT INTO auditor_reserve_not_closed_inconsistency " + "( row_id," +" reserve_pub," +" balance," +" expiration_time," +" diagnostic," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserve_not_closed_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserve_not_closed_inconsistency.h b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.h new file mode 100644 index 000000000..c8464d978 --- /dev/null +++ b/src/auditordb/pg_insert_reserve_not_closed_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_RESERVE_NOT_CLOSED_INCONSISTENCY_H +#define SRC_PG_INSERT_RESERVE_NOT_CLOSED_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserve_not_closed_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc); + +#endif // SRC_PG_INSERT_RESERVE_NOT_CLOSED_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserves.c b/src/auditordb/pg_insert_reserves.c new file mode 100644 index 000000000..3bb73a73e --- /dev/null +++ b/src/auditordb/pg_insert_reserves.c @@ -0,0 +1,74 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_reserves.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserves ( + void *cls, + const struct TALER_AUDITORDB_Reserves *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_int64(&dc->auditor_reserves_rowid), +GNUNET_PQ_query_param_auto_from_type(&dc->reserve_pub), +TALER_PQ_query_param_amount(pg->conn, &dc->reserve_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->reserve_loss), +TALER_PQ_query_param_amount(pg->conn, &dc->withdraw_fee_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->close_fee_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->purse_fee_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->open_fee_balance), +TALER_PQ_query_param_amount(pg->conn, &dc->history_fee_balance), +GNUNET_PQ_query_param_int64(&dc->expiration_date), +GNUNET_PQ_query_param_string(dc->origin_account), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_reserves_insert", + "INSERT INTO auditor_reserves " + "( auditor_reserves_rowid," +" reserve_pub," +" reserve_balance," +" reserve_loss," +" withdraw_fee_balance," +" close_fee_balance," +" purse_fee_balance," +" open_fee_balance," +" history_fee_balance," +" expiration_date," +" origin_account," +" suppressed" +") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_reserves_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_reserves.h b/src/auditordb/pg_insert_reserves.h new file mode 100644 index 000000000..6fce382de --- /dev/null +++ b/src/auditordb/pg_insert_reserves.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_RESERVES_H +#define SRC_PG_INSERT_RESERVES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_reserves ( + void *cls, + const struct TALER_AUDITORDB_Reserves *dc); + +#endif // SRC_PG_INSERT_RESERVES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_row_minor_inconsistencies.c b/src/auditordb/pg_insert_row_minor_inconsistencies.c new file mode 100644 index 000000000..c60fdc3c5 --- /dev/null +++ b/src/auditordb/pg_insert_row_minor_inconsistencies.c @@ -0,0 +1,57 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_row_minor_inconsistencies.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_row_minor_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_RowMinorInconsistencies *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->row_table), +GNUNET_PQ_query_param_auto_from_type(&dc->diagnostic), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_row_minor_inconsistencies_insert", + "INSERT INTO auditor_row_minor_inconsistencies " + "( row_id," +" row_table," +" diagnostic," +" suppressed" +") VALUES ($1,$2,$3,$4);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_row_minor_inconsistencies_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_row_minor_inconsistencies.h b/src/auditordb/pg_insert_row_minor_inconsistencies.h new file mode 100644 index 000000000..919f5518a --- /dev/null +++ b/src/auditordb/pg_insert_row_minor_inconsistencies.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_ROW_MINOR_INCONSISTENCIES_H +#define SRC_PG_INSERT_ROW_MINOR_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_row_minor_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_RowMinorInconsistencies *dc); + +#endif // SRC_PG_INSERT_ROW_MINOR_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_wire_format_inconsistency.c b/src/auditordb/pg_insert_wire_format_inconsistency.c new file mode 100644 index 000000000..210bcc5e8 --- /dev/null +++ b/src/auditordb/pg_insert_wire_format_inconsistency.c @@ -0,0 +1,59 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_wire_format_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_wire_format_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_WireFormatInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + TALER_PQ_query_param_amount(pg->conn, &dc->amount), +GNUNET_PQ_query_param_int64(&dc->wire_offset), +GNUNET_PQ_query_param_auto_from_type(&dc->diagnostic), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_wire_format_inconsistency_insert", + "INSERT INTO auditor_wire_format_inconsistency " + "( row_id," +" amount," +" wire_offset," +" diagnostic," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_wire_format_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_wire_format_inconsistency.h b/src/auditordb/pg_insert_wire_format_inconsistency.h new file mode 100644 index 000000000..16bfd568e --- /dev/null +++ b/src/auditordb/pg_insert_wire_format_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_WIRE_FORMAT_INCONSISTENCY_H +#define SRC_PG_INSERT_WIRE_FORMAT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_wire_format_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_WireFormatInconsistency *dc); + +#endif // SRC_PG_INSERT_WIRE_FORMAT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_wire_out_inconsistency.c b/src/auditordb/pg_insert_wire_out_inconsistency.c new file mode 100644 index 000000000..ea72a5fc1 --- /dev/null +++ b/src/auditordb/pg_insert_wire_out_inconsistency.c @@ -0,0 +1,59 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_insert_wire_out_inconsistency.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_insert_wire_out_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_WireOutInconsistency *dc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + + GNUNET_PQ_query_param_auto_from_type(&dc->destination_account), +TALER_PQ_query_param_amount(pg->conn, &dc->expected), +TALER_PQ_query_param_amount(pg->conn, &dc->claimed), +GNUNET_PQ_query_param_bool(dc->suppressed), + + + GNUNET_PQ_query_param_end + }; + + PREPARE (pg, + "auditor_wire_out_inconsistency_insert", + "INSERT INTO auditor_wire_out_inconsistency " + "( row_id," +" destination_account," +" expected," +" claimed," +" suppressed" +") VALUES ($1,$2,$3,$4,$5);" + ); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "auditor_wire_out_inconsistency_insert", + params); +} + +
\ No newline at end of file diff --git a/src/auditordb/pg_insert_wire_out_inconsistency.h b/src/auditordb/pg_insert_wire_out_inconsistency.h new file mode 100644 index 000000000..ad9728eae --- /dev/null +++ b/src/auditordb/pg_insert_wire_out_inconsistency.h @@ -0,0 +1,45 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + + + +#ifndef SRC_PG_INSERT_WIRE_OUT_INCONSISTENCY_H +#define SRC_PG_INSERT_WIRE_OUT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + + +/** + * Insert information about a bad sig loss into the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param dc deposit confirmation information to store + * @return query result status + */ +enum GNUNET_DB_QueryStatus +TAH_PG_insert_wire_out_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_WireOutInconsistency *dc); + +#endif // SRC_PG_INSERT_WIRE_OUT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_closure_lags.c b/src/auditordb/pg_update_closure_lags.c new file mode 100644 index 000000000..0702fce7f --- /dev/null +++ b/src/auditordb/pg_update_closure_lags.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_closure_lags.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_closure_lags ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_closure_lags", + "UPDATE auditor_closure_lags SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_closure_lags", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_closure_lags.h b/src/auditordb/pg_update_closure_lags.h new file mode 100644 index 000000000..33581b94c --- /dev/null +++ b/src/auditordb/pg_update_closure_lags.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_CLOSURE_LAGS_H +#define SRC_PG_UPDATE_CLOSURE_LAGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_closure_lags ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_CLOSURE_LAGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_coin_inconsistency.c b/src/auditordb/pg_update_coin_inconsistency.c new file mode 100644 index 000000000..1f1d4e1b8 --- /dev/null +++ b/src/auditordb/pg_update_coin_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_coin_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_coin_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_coin_inconsistency", + "UPDATE auditor_coin_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_coin_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_coin_inconsistency.h b/src/auditordb/pg_update_coin_inconsistency.h new file mode 100644 index 000000000..37a2bfd3a --- /dev/null +++ b/src/auditordb/pg_update_coin_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_COIN_INCONSISTENCY_H +#define SRC_PG_UPDATE_COIN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_coin_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_COIN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c new file mode 100644 index 000000000..8ac44fa45 --- /dev/null +++ b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_denomination_key_validity_withdraw_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_denomination_key_validity_withdraw_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_denomination_key_validity_withdraw_inconsistency", + "UPDATE auditor_denomination_key_validity_withdraw_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_denomination_key_validity_withdraw_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h new file mode 100644 index 000000000..8b29209d9 --- /dev/null +++ b/src/auditordb/pg_update_denomination_key_validity_withdraw_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H +#define SRC_PG_UPDATE_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_denomination_key_validity_withdraw_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_DENOMINATION_KEY_VALIDITY_WITHDRAW_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denomination_pending.c b/src/auditordb/pg_update_denomination_pending.c new file mode 100644 index 000000000..a530951a3 --- /dev/null +++ b/src/auditordb/pg_update_denomination_pending.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_denomination_pending.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_denomination_pending ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_denomination_pending", + "UPDATE auditor_denomination_pending SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_denomination_pending", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denomination_pending.h b/src/auditordb/pg_update_denomination_pending.h new file mode 100644 index 000000000..773b5bac7 --- /dev/null +++ b/src/auditordb/pg_update_denomination_pending.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_DENOMINATION_PENDING_H +#define SRC_PG_UPDATE_DENOMINATION_PENDING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_denomination_pending ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_DENOMINATION_PENDING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denominations_without_sigs.c b/src/auditordb/pg_update_denominations_without_sigs.c new file mode 100644 index 000000000..009ab059a --- /dev/null +++ b/src/auditordb/pg_update_denominations_without_sigs.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_denominations_without_sigs.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_denominations_without_sigs ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_denominations_without_sigs", + "UPDATE auditor_denominations_without_sigs SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_denominations_without_sigs", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_denominations_without_sigs.h b/src/auditordb/pg_update_denominations_without_sigs.h new file mode 100644 index 000000000..9c185b89b --- /dev/null +++ b/src/auditordb/pg_update_denominations_without_sigs.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_DENOMINATIONS_WITHOUT_SIGS_H +#define SRC_PG_UPDATE_DENOMINATIONS_WITHOUT_SIGS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_denominations_without_sigs ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_DENOMINATIONS_WITHOUT_SIGS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_emergency.c b/src/auditordb/pg_update_emergency.c new file mode 100644 index 000000000..4f9d745d0 --- /dev/null +++ b/src/auditordb/pg_update_emergency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_emergency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_emergency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_emergency", + "UPDATE auditor_emergency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_emergency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_emergency.h b/src/auditordb/pg_update_emergency.h new file mode 100644 index 000000000..5af01fc7d --- /dev/null +++ b/src/auditordb/pg_update_emergency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_EMERGENCY_H +#define SRC_PG_UPDATE_EMERGENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_emergency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_EMERGENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_emergency_by_count.c b/src/auditordb/pg_update_emergency_by_count.c new file mode 100644 index 000000000..39c3bcbdf --- /dev/null +++ b/src/auditordb/pg_update_emergency_by_count.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_emergency_by_count.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_emergency_by_count ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_emergency_by_count", + "UPDATE auditor_emergency_by_count SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_emergency_by_count", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_emergency_by_count.h b/src/auditordb/pg_update_emergency_by_count.h new file mode 100644 index 000000000..1a8c0422b --- /dev/null +++ b/src/auditordb/pg_update_emergency_by_count.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_EMERGENCY_BY_COUNT_H +#define SRC_PG_UPDATE_EMERGENCY_BY_COUNT_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_emergency_by_count ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_EMERGENCY_BY_COUNT_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_exchange_signkeys.c b/src/auditordb/pg_update_exchange_signkeys.c new file mode 100644 index 000000000..4f6a7bfe8 --- /dev/null +++ b/src/auditordb/pg_update_exchange_signkeys.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_exchange_signkeys.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_exchange_signkeys ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_exchange_signkeys", + "UPDATE auditor_exchange_signkeys SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_exchange_signkeys", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_exchange_signkeys.h b/src/auditordb/pg_update_exchange_signkeys.h new file mode 100644 index 000000000..30a7ef1d4 --- /dev/null +++ b/src/auditordb/pg_update_exchange_signkeys.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_EXCHANGE_SIGNKEYS_H +#define SRC_PG_UPDATE_EXCHANGE_SIGNKEYS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_exchange_signkeys ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_EXCHANGE_SIGNKEYS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_historic_denomination_revenue.c b/src/auditordb/pg_update_historic_denomination_revenue.c new file mode 100644 index 000000000..1d812c0c3 --- /dev/null +++ b/src/auditordb/pg_update_historic_denomination_revenue.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_historic_denomination_revenue.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_historic_denomination_revenue ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_historic_denomination_revenue", + "UPDATE auditor_historic_denomination_revenue SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_historic_denomination_revenue", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_historic_denomination_revenue.h b/src/auditordb/pg_update_historic_denomination_revenue.h new file mode 100644 index 000000000..4579205d7 --- /dev/null +++ b/src/auditordb/pg_update_historic_denomination_revenue.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_HISTORIC_DENOMINATION_REVENUE_H +#define SRC_PG_UPDATE_HISTORIC_DENOMINATION_REVENUE_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_historic_denomination_revenue ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_HISTORIC_DENOMINATION_REVENUE_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_historic_reserve_summary.c b/src/auditordb/pg_update_historic_reserve_summary.c new file mode 100644 index 000000000..e9767285e --- /dev/null +++ b/src/auditordb/pg_update_historic_reserve_summary.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_historic_reserve_summary.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_historic_reserve_summary ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_historic_reserve_summary", + "UPDATE auditor_historic_reserve_summary SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_historic_reserve_summary", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_historic_reserve_summary.h b/src/auditordb/pg_update_historic_reserve_summary.h new file mode 100644 index 000000000..047dd57e7 --- /dev/null +++ b/src/auditordb/pg_update_historic_reserve_summary.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_HISTORIC_RESERVE_SUMMARY_H +#define SRC_PG_UPDATE_HISTORIC_RESERVE_SUMMARY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_historic_reserve_summary ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_HISTORIC_RESERVE_SUMMARY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_misattribution_in_inconsistency.c b/src/auditordb/pg_update_misattribution_in_inconsistency.c new file mode 100644 index 000000000..c45907b0f --- /dev/null +++ b/src/auditordb/pg_update_misattribution_in_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_misattribution_in_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_misattribution_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_misattribution_in_inconsistency", + "UPDATE auditor_misattribution_in_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_misattribution_in_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_misattribution_in_inconsistency.h b/src/auditordb/pg_update_misattribution_in_inconsistency.h new file mode 100644 index 000000000..158c8d6b9 --- /dev/null +++ b/src/auditordb/pg_update_misattribution_in_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_MISATTRIBUTION_IN_INCONSISTENCY_H +#define SRC_PG_UPDATE_MISATTRIBUTION_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_misattribution_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_MISATTRIBUTION_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_progress.c b/src/auditordb/pg_update_progress.c new file mode 100644 index 000000000..e079415c8 --- /dev/null +++ b/src/auditordb/pg_update_progress.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_progress.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_progress ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_progress", + "UPDATE auditor_progress SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_progress", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_progress.h b/src/auditordb/pg_update_progress.h new file mode 100644 index 000000000..22023464e --- /dev/null +++ b/src/auditordb/pg_update_progress.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_PROGRESS_H +#define SRC_PG_UPDATE_PROGRESS_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_progress ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_PROGRESS_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_purse_not_closed_inconsistencies.c b/src/auditordb/pg_update_purse_not_closed_inconsistencies.c new file mode 100644 index 000000000..3ff830204 --- /dev/null +++ b/src/auditordb/pg_update_purse_not_closed_inconsistencies.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_purse_not_closed_inconsistencies.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_purse_not_closed_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_purse_not_closed_inconsistencies", + "UPDATE auditor_purse_not_closed_inconsistencies SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_purse_not_closed_inconsistencies", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_purse_not_closed_inconsistencies.h b/src/auditordb/pg_update_purse_not_closed_inconsistencies.h new file mode 100644 index 000000000..528afd1cc --- /dev/null +++ b/src/auditordb/pg_update_purse_not_closed_inconsistencies.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H +#define SRC_PG_UPDATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_purse_not_closed_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_PURSE_NOT_CLOSED_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_purses.c b/src/auditordb/pg_update_purses.c new file mode 100644 index 000000000..68bc8a71e --- /dev/null +++ b/src/auditordb/pg_update_purses.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_purses.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_purses ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_purses", + "UPDATE auditor_purses SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_purses", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_purses.h b/src/auditordb/pg_update_purses.h new file mode 100644 index 000000000..52e8a6bcd --- /dev/null +++ b/src/auditordb/pg_update_purses.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_PURSES_H +#define SRC_PG_UPDATE_PURSES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_purses ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_PURSES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_refreshes_hanging.c b/src/auditordb/pg_update_refreshes_hanging.c new file mode 100644 index 000000000..f480c8ecd --- /dev/null +++ b/src/auditordb/pg_update_refreshes_hanging.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_refreshes_hanging.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_refreshes_hanging ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_refreshes_hanging", + "UPDATE auditor_refreshes_hanging SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_refreshes_hanging", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_refreshes_hanging.h b/src/auditordb/pg_update_refreshes_hanging.h new file mode 100644 index 000000000..927ddc551 --- /dev/null +++ b/src/auditordb/pg_update_refreshes_hanging.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_REFRESHES_HANGING_H +#define SRC_PG_UPDATE_REFRESHES_HANGING_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_refreshes_hanging ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_REFRESHES_HANGING_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c new file mode 100644 index 000000000..b220d8c94 --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserve_balance_insufficient_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_balance_insufficient_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserve_balance_insufficient_inconsistency", + "UPDATE auditor_reserve_balance_insufficient_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserve_balance_insufficient_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h new file mode 100644 index 000000000..4656f083b --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_insufficient_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H +#define SRC_PG_UPDATE_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_balance_insufficient_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c new file mode 100644 index 000000000..0ba78a03f --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserve_balance_summary_wrong_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_balance_summary_wrong_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserve_balance_summary_wrong_inconsistency", + "UPDATE auditor_reserve_balance_summary_wrong_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserve_balance_summary_wrong_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h new file mode 100644 index 000000000..846636338 --- /dev/null +++ b/src/auditordb/pg_update_reserve_balance_summary_wrong_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H +#define SRC_PG_UPDATE_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_balance_summary_wrong_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVE_BALANCE_SUMMARY_WRONG_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_in_inconsistency.c b/src/auditordb/pg_update_reserve_in_inconsistency.c new file mode 100644 index 000000000..d053a1270 --- /dev/null +++ b/src/auditordb/pg_update_reserve_in_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserve_in_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserve_in_inconsistency", + "UPDATE auditor_reserve_in_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserve_in_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_in_inconsistency.h b/src/auditordb/pg_update_reserve_in_inconsistency.h new file mode 100644 index 000000000..a826412e6 --- /dev/null +++ b/src/auditordb/pg_update_reserve_in_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVE_IN_INCONSISTENCY_H +#define SRC_PG_UPDATE_RESERVE_IN_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_in_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVE_IN_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_not_closed_inconsistency.c b/src/auditordb/pg_update_reserve_not_closed_inconsistency.c new file mode 100644 index 000000000..8951e04db --- /dev/null +++ b/src/auditordb/pg_update_reserve_not_closed_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserve_not_closed_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_not_closed_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserve_not_closed_inconsistency", + "UPDATE auditor_reserve_not_closed_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserve_not_closed_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserve_not_closed_inconsistency.h b/src/auditordb/pg_update_reserve_not_closed_inconsistency.h new file mode 100644 index 000000000..b7f73f369 --- /dev/null +++ b/src/auditordb/pg_update_reserve_not_closed_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVE_NOT_CLOSED_INCONSISTENCY_H +#define SRC_PG_UPDATE_RESERVE_NOT_CLOSED_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserve_not_closed_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVE_NOT_CLOSED_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserves.c b/src/auditordb/pg_update_reserves.c new file mode 100644 index 000000000..ed706d0c5 --- /dev/null +++ b/src/auditordb/pg_update_reserves.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_reserves.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserves ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_reserves", + "UPDATE auditor_reserves SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_reserves", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_reserves.h b/src/auditordb/pg_update_reserves.h new file mode 100644 index 000000000..d2316ab5d --- /dev/null +++ b/src/auditordb/pg_update_reserves.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_RESERVES_H +#define SRC_PG_UPDATE_RESERVES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_reserves ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_RESERVES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_row_inconsistency.c b/src/auditordb/pg_update_row_inconsistency.c new file mode 100644 index 000000000..3258e0f97 --- /dev/null +++ b/src/auditordb/pg_update_row_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_row_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_row_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_row_inconsistency", + "UPDATE auditor_row_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_row_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_row_inconsistency.h b/src/auditordb/pg_update_row_inconsistency.h new file mode 100644 index 000000000..42e9e8e07 --- /dev/null +++ b/src/auditordb/pg_update_row_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_ROW_INCONSISTENCY_H +#define SRC_PG_UPDATE_ROW_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_row_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_ROW_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_row_minor_inconsistencies.c b/src/auditordb/pg_update_row_minor_inconsistencies.c new file mode 100644 index 000000000..8d93558ff --- /dev/null +++ b/src/auditordb/pg_update_row_minor_inconsistencies.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_row_minor_inconsistencies.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_row_minor_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_row_minor_inconsistencies", + "UPDATE auditor_row_minor_inconsistencies SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_row_minor_inconsistencies", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_row_minor_inconsistencies.h b/src/auditordb/pg_update_row_minor_inconsistencies.h new file mode 100644 index 000000000..4c16bdfbf --- /dev/null +++ b/src/auditordb/pg_update_row_minor_inconsistencies.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_ROW_MINOR_INCONSISTENCIES_H +#define SRC_PG_UPDATE_ROW_MINOR_INCONSISTENCIES_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_row_minor_inconsistencies ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_ROW_MINOR_INCONSISTENCIES_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_wire_format_inconsistency.c b/src/auditordb/pg_update_wire_format_inconsistency.c new file mode 100644 index 000000000..381e35e77 --- /dev/null +++ b/src/auditordb/pg_update_wire_format_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_wire_format_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_wire_format_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_wire_format_inconsistency", + "UPDATE auditor_wire_format_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_wire_format_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_wire_format_inconsistency.h b/src/auditordb/pg_update_wire_format_inconsistency.h new file mode 100644 index 000000000..ddd306fdb --- /dev/null +++ b/src/auditordb/pg_update_wire_format_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_WIRE_FORMAT_INCONSISTENCY_H +#define SRC_PG_UPDATE_WIRE_FORMAT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_wire_format_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_WIRE_FORMAT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_wire_out_inconsistency.c b/src/auditordb/pg_update_wire_out_inconsistency.c new file mode 100644 index 000000000..9d2349ccb --- /dev/null +++ b/src/auditordb/pg_update_wire_out_inconsistency.c @@ -0,0 +1,54 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#include "platform.h" +#include "taler_pq_lib.h" +#include "pg_helper.h" + +#include "pg_update_wire_out_inconsistency.h" + +/* +Update a given resource – for now this only means suppressing +*/ +enum GNUNET_DB_QueryStatus +TAH_PG_update_wire_out_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&gu->row_id), + GNUNET_PQ_query_param_bool (gu->suppressed), + GNUNET_PQ_query_param_end + }; + + + PREPARE (pg, + "update_wire_out_inconsistency", + "UPDATE auditor_wire_out_inconsistency SET" + " suppressed=$2" + " WHERE row_id=$1"); + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "update_wire_out_inconsistency", + params); +} + + +
\ No newline at end of file diff --git a/src/auditordb/pg_update_wire_out_inconsistency.h b/src/auditordb/pg_update_wire_out_inconsistency.h new file mode 100644 index 000000000..d042e74bb --- /dev/null +++ b/src/auditordb/pg_update_wire_out_inconsistency.h @@ -0,0 +1,35 @@ + + + +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +#ifndef SRC_PG_UPDATE_WIRE_OUT_INCONSISTENCY_H +#define SRC_PG_UPDATE_WIRE_OUT_INCONSISTENCY_H + +#include "taler_util.h" +#include "taler_auditordb_plugin.h" + +enum GNUNET_DB_QueryStatus +TAH_PG_update_wire_out_inconsistency ( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *dc); + +#endif // SRC_PG_UPDATE_WIRE_OUT_INCONSISTENCY_H + + +
\ No newline at end of file diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 5060a016c..9eb5df7b4 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -59,9 +59,17 @@ #include "pg_get_amount_arithmetic_inconsistency.h" #include "pg_get_coin_inconsistency.h" #include "pg_get_row_inconsistency.h" - - -// MARK: CRUD +#include "pg_update_emergency_by_count.h" +#include "pg_update_row_inconsistency.h" +#include "pg_update_purse_not_closed_inconsistencies.h" +#include "pg_update_reserve_balance_insufficient_inconsistency.h" +#include "pg_update_coin_inconsistency.h" +#include "pg_update_progress.h" +#include "pg_update_denomination_key_validity_withdraw_inconsistency.h" +#include "pg_update_refreshes_hanging.h" +#include "pg_update_emergency.h" +#include "pg_update_closure_lags.h" +#include "pg_update_row_minor_inconsistencies.h" #include "pg_del_amount_arithmetic_inconsistency.h" #include "pg_del_coin_inconsistency.h" @@ -83,9 +91,7 @@ #include "pg_del_emergency.h" #include "pg_insert_emergency.h" -// #include "pg_get_auditor_progress.h" #include "pg_del_auditor_progress.h" -// #include "pg_insert_auditor_progress.h" #include "pg_get_bad_sig_losses.h" #include "pg_del_bad_sig_losses.h" @@ -112,6 +118,76 @@ #include "pg_del_reserve_balance_insufficient_inconsistency.h" #include "pg_insert_reserve_balance_insufficient_inconsistency.h" +#include "pg_get_reserve_in_inconsistency.h" +#include "pg_del_reserve_in_inconsistency.h" +#include "pg_insert_reserve_in_inconsistency.h" +#include "pg_update_reserve_in_inconsistency.h" + +#include "pg_get_reserve_not_closed_inconsistency.h" +#include "pg_del_reserve_not_closed_inconsistency.h" +#include "pg_insert_reserve_not_closed_inconsistency.h" +#include "pg_update_reserve_not_closed_inconsistency.h" + +#include "pg_get_denominations_without_sigs.h" +#include "pg_del_denominations_without_sigs.h" +#include "pg_insert_denominations_without_sigs.h" +#include "pg_update_denominations_without_sigs.h" + +#include "pg_get_misattribution_in_inconsistency.h" +#include "pg_del_misattribution_in_inconsistency.h" +#include "pg_insert_misattribution_in_inconsistency.h" +#include "pg_update_misattribution_in_inconsistency.h" + +#include "pg_get_reserves.h" +#include "pg_del_reserves.h" +#include "pg_insert_reserves.h" +#include "pg_update_reserves.h" + +#include "pg_get_purses.h" +#include "pg_del_purses.h" +#include "pg_insert_purses.h" +#include "pg_update_purses.h" + +#include "pg_get_historic_denomination_revenue.h" +#include "pg_del_historic_denomination_revenue.h" +#include "pg_insert_historic_denomination_revenue.h" +#include "pg_update_historic_denomination_revenue.h" + +#include "pg_get_denomination_pending.h" +#include "pg_del_denomination_pending.h" +#include "pg_insert_denomination_pending.h" +#include "pg_update_denomination_pending.h" + +#include "pg_get_historic_reserve_summary.h" +#include "pg_del_historic_reserve_summary.h" +#include "pg_insert_historic_reserve_summary.h" +#include "pg_update_historic_reserve_summary.h" + +#include "pg_get_exchange_signkeys.h" +#include "pg_del_exchange_signkeys.h" +#include "pg_insert_exchange_signkeys.h" +#include "pg_update_exchange_signkeys.h" + +#include "pg_get_wire_format_inconsistency.h" +#include "pg_del_wire_format_inconsistency.h" +#include "pg_insert_wire_format_inconsistency.h" +#include "pg_update_wire_format_inconsistency.h" + +#include "pg_get_wire_out_inconsistency.h" +#include "pg_del_wire_out_inconsistency.h" +#include "pg_insert_wire_out_inconsistency.h" +#include "pg_update_wire_out_inconsistency.h" + +#include "pg_get_reserve_balance_summary_wrong_inconsistency.h" +#include "pg_del_reserve_balance_summary_wrong_inconsistency.h" +#include "pg_insert_reserve_balance_summary_wrong_inconsistency.h" +#include "pg_update_reserve_balance_summary_wrong_inconsistency.h" + +#include "pg_get_row_minor_inconsistencies.h" +#include "pg_del_row_minor_inconsistencies.h" +#include "pg_insert_row_minor_inconsistencies.h" +#include "pg_update_row_minor_inconsistencies.h" + #define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", \ __VA_ARGS__) @@ -660,6 +736,100 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->insert_refreshes_hanging = &TAH_PG_insert_refreshes_hanging; plugin->get_refreshes_hanging = &TAH_PG_get_refreshes_hanging; + plugin->update_emergency_by_count = &TAH_PG_update_emergency_by_count; + plugin->update_row_inconsistency = &TAH_PG_update_row_inconsistency; + plugin->update_purse_not_closed_inconsistencies = &TAH_PG_update_purse_not_closed_inconsistencies; + plugin->update_reserve_balance_insufficient_inconsistency = &TAH_PG_update_reserve_balance_insufficient_inconsistency; + plugin->update_coin_inconsistency = &TAH_PG_update_coin_inconsistency; + plugin->update_progress = &TAH_PG_update_progress; + plugin->update_denomination_key_validity_withdraw_inconsistency = &TAH_PG_update_denomination_key_validity_withdraw_inconsistency; + plugin->update_refreshes_hanging = &TAH_PG_update_refreshes_hanging; + plugin->update_emergency = &TAH_PG_update_emergency; + plugin->update_closure_lags = &TAH_PG_update_closure_lags; + + + plugin->delete_reserve_in_inconsistency = &TAH_PG_del_reserve_in_inconsistency; + plugin->insert_reserve_in_inconsistency = &TAH_PG_insert_reserve_in_inconsistency; + plugin->get_reserve_in_inconsistency = &TAH_PG_get_reserve_in_inconsistency; + plugin->update_reserve_in_inconsistency = &TAH_PG_update_reserve_in_inconsistency; + + + plugin->delete_reserve_not_closed_inconsistency = &TAH_PG_del_reserve_not_closed_inconsistency; + plugin->insert_reserve_not_closed_inconsistency = &TAH_PG_insert_reserve_not_closed_inconsistency; + plugin->get_reserve_not_closed_inconsistency = &TAH_PG_get_reserve_not_closed_inconsistency; + plugin->update_reserve_not_closed_inconsistency = &TAH_PG_update_reserve_not_closed_inconsistency; + + + plugin->delete_denominations_without_sigs = &TAH_PG_del_denominations_without_sigs; + plugin->insert_denominations_without_sigs = &TAH_PG_insert_denominations_without_sigs; + plugin->get_denominations_without_sigs = &TAH_PG_get_denominations_without_sigs; + plugin->update_denominations_without_sigs = &TAH_PG_update_denominations_without_sigs; + + + plugin->delete_misattribution_in_inconsistency = &TAH_PG_del_misattribution_in_inconsistency; + plugin->insert_misattribution_in_inconsistency = &TAH_PG_insert_misattribution_in_inconsistency; + plugin->get_misattribution_in_inconsistency = &TAH_PG_get_misattribution_in_inconsistency; + plugin->update_misattribution_in_inconsistency = &TAH_PG_update_misattribution_in_inconsistency; + + + plugin->delete_reserves = &TAH_PG_del_reserves; + plugin->insert_reserves = &TAH_PG_insert_reserves; + plugin->get_reserves = &TAH_PG_get_reserves; + plugin->update_reserves = &TAH_PG_update_reserves; + + + plugin->delete_purses = &TAH_PG_del_purses; + plugin->insert_purses = &TAH_PG_insert_purses; + plugin->get_purses = &TAH_PG_get_purses; + plugin->update_purses = &TAH_PG_update_purses; + + + plugin->delete_historic_denomination_revenue = &TAH_PG_del_historic_denomination_revenue; + plugin->insert_historic_denomination_revenue = &TAH_PG_insert_historic_denomination_revenue; + plugin->get_historic_denomination_revenue = &TAH_PG_get_historic_denomination_revenue; + plugin->update_historic_denomination_revenue = &TAH_PG_update_historic_denomination_revenue; + + + plugin->delete_denomination_pending = &TAH_PG_del_denomination_pending; + plugin->insert_denomination_pending = &TAH_PG_insert_denomination_pending; + plugin->get_denomination_pending = &TAH_PG_get_denomination_pending; + plugin->update_denomination_pending = &TAH_PG_update_denomination_pending; + + + plugin->delete_historic_reserve_summary = &TAH_PG_del_historic_reserve_summary; + plugin->insert_historic_reserve_summary = &TAH_PG_insert_historic_reserve_summary; + plugin->get_historic_reserve_summary = &TAH_PG_get_historic_reserve_summary; + plugin->update_historic_reserve_summary = &TAH_PG_update_historic_reserve_summary; + + + plugin->delete_exchange_signkeys = &TAH_PG_del_exchange_signkeys; + plugin->insert_exchange_signkeys = &TAH_PG_insert_exchange_signkeys; + plugin->get_exchange_signkeys = &TAH_PG_get_exchange_signkeys; + plugin->update_exchange_signkeys = &TAH_PG_update_exchange_signkeys; + + + plugin->delete_wire_format_inconsistency = &TAH_PG_del_wire_format_inconsistency; + plugin->insert_wire_format_inconsistency = &TAH_PG_insert_wire_format_inconsistency; + plugin->get_wire_format_inconsistency = &TAH_PG_get_wire_format_inconsistency; + plugin->update_wire_format_inconsistency = &TAH_PG_update_wire_format_inconsistency; + + + plugin->delete_wire_out_inconsistency = &TAH_PG_del_wire_out_inconsistency; + plugin->insert_wire_out_inconsistency = &TAH_PG_insert_wire_out_inconsistency; + plugin->get_wire_out_inconsistency = &TAH_PG_get_wire_out_inconsistency; + plugin->update_wire_out_inconsistency = &TAH_PG_update_wire_out_inconsistency; + + + plugin->delete_reserve_balance_summary_wrong_inconsistency = &TAH_PG_del_reserve_balance_summary_wrong_inconsistency; + plugin->insert_reserve_balance_summary_wrong_inconsistency = &TAH_PG_insert_reserve_balance_summary_wrong_inconsistency; + plugin->get_reserve_balance_summary_wrong_inconsistency = &TAH_PG_get_reserve_balance_summary_wrong_inconsistency; + plugin->update_reserve_balance_summary_wrong_inconsistency = &TAH_PG_update_reserve_balance_summary_wrong_inconsistency; + + + plugin->delete_row_minor_inconsistencies = &TAH_PG_del_row_minor_inconsistencies; + plugin->insert_row_minor_inconsistencies = &TAH_PG_insert_row_minor_inconsistencies; + plugin->get_row_minor_inconsistencies = &TAH_PG_get_row_minor_inconsistencies; + plugin->update_row_minor_inconsistencies = &TAH_PG_update_row_minor_inconsistencies; return plugin; } diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index 818c72a95..fea1f85f4 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -225,7 +225,7 @@ struct TALER_AUDITORDB_AmountArithmeticInconsistency struct TALER_AUDITORDB_CoinInconsistency { unsigned int row_id; - char*operation; // TODO: change to string + char* operation; // TODO: change to string struct TALER_Amount exchange_amount; struct TALER_Amount auditor_amount; struct TALER_CoinSpendPublicKeyP coin_pub; @@ -359,8 +359,18 @@ struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency struct TALER_Amount inconsistency_amount; }; +struct TALER_AUDITORDB_ReserveInInconsistency +{ + unsigned int row_id; + struct TALER_Amount amount_exchange_expected; + struct TALER_Amount amount_wired; + struct TALER_ReservePublicKeyP reserve_pub; + int64_t timestamp; + char * account; + char * diagnostic; + bool suppressed; -// MARK: CRUD +}; /** * Function called with arithmetic inconsistencies stored in @@ -636,6 +646,152 @@ struct TALER_AUDITORDB_DenominationCirculationData uint64_t num_issued; }; +struct TALER_AUDITORDB_DenominationsWithoutSigs +{ + unsigned int row_id; + struct TALER_DenominationHashP denompub_h; + struct TALER_Amount value; + int64_t start_time; + int64_t end_time; + bool suppressed; + +}; + +struct TALER_AUDITORDB_MisattributionInInconsistency +{ + unsigned int row_id; + struct TALER_Amount amount; + int64_t bank_row; + struct TALER_ReservePublicKeyP reserve_pub; + bool suppressed; + +}; + +struct TALER_AUDITORDB_Reserves +{ + unsigned int row_id; + int64_t auditor_reserves_rowid; + struct TALER_ReservePublicKeyP reserve_pub; + struct TALER_Amount reserve_balance; + struct TALER_Amount reserve_loss; + struct TALER_Amount withdraw_fee_balance; + struct TALER_Amount close_fee_balance; + struct TALER_Amount purse_fee_balance; + struct TALER_Amount open_fee_balance; + struct TALER_Amount history_fee_balance; + int64_t expiration_date; + char * origin_account; + bool suppressed; + +}; + +struct TALER_AUDITORDB_Purses +{ + unsigned int row_id; + int64_t auditor_purses_rowid; + struct TALER_PurseContractPublicKeyP purse_pub; + struct TALER_Amount balance; + struct TALER_Amount target; + int64_t expiration_date; + bool suppressed; + +}; + +struct TALER_AUDITORDB_HistoricDenominationRevenue +{ + unsigned int row_id; + struct TALER_DenominationHashP denom_pub_hash; + int64_t revenue_timestamp; + struct TALER_Amount revenue_balance; + struct TALER_Amount loss_balance; + bool suppressed; + +}; + +struct TALER_AUDITORDB_DenominationPending +{ + unsigned int row_id; + struct TALER_DenominationHashP denom_pub_hash; + struct TALER_Amount denom_balance; + struct TALER_Amount denom_loss; + int64_t num_issued; + struct TALER_Amount denom_risk; + struct TALER_Amount recoup_loss; + bool suppressed; + +}; + +struct TALER_AUDITORDB_HistoricReserveSummary +{ + unsigned int row_id; + int64_t start_date; + int64_t end_date; + struct TALER_Amount reserve_profits; + bool suppressed; + +}; + +struct TALER_AUDITORDB_ExchangeSignkeys +{ + unsigned int row_id; + struct TALER_ExchangePublicKeyP exchange_pub; + struct TALER_MasterSignatureP master_sig; + int64_t ep_valid_from; + int64_t ep_expire_sign; + int64_t ep_expire_legal; + bool suppressed; + +}; + +struct TALER_AUDITORDB_WireFormatInconsistency +{ + unsigned int row_id; + struct TALER_Amount amount; + int64_t wire_offset; + char * diagnostic; + bool suppressed; + +}; + +struct TALER_AUDITORDB_WireOutInconsistency +{ + unsigned int row_id; + char * destination_account; + struct TALER_Amount expected; + struct TALER_Amount claimed; + bool suppressed; + +}; + +struct TALER_AUDITORDB_RowMinorInconsistencies +{ + unsigned int row_id; + char * row_table; + char * diagnostic; + bool suppressed; + +}; + +struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency +{ + unsigned int row_id; + struct TALER_ReservePublicKeyP reserve_pub; + struct TALER_Amount exchange_amount; + struct TALER_Amount auditor_amount; + bool suppressed; + +}; + +struct TALER_AUDITORDB_ReserveNotClosedInconsistency +{ + unsigned int row_id; + struct TALER_ReservePublicKeyP reserve_pub; + struct TALER_Amount balance; + int64_t expiration_time; + char * diagnostic; + bool suppressed; + +}; /** * Function called with deposit confirmations stored in @@ -689,6 +845,92 @@ typedef enum GNUNET_GenericReturnValue struct GNUNET_TIME_Timestamp expiration_date); +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_ReserveInInconsistencyCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_ReserveInInconsistency *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_DenominationsWithoutSigsCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc); + + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_MisattributionInInconsistencyCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_MisattributionInInconsistency *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_ReservesCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_Reserves *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_PursesCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_Purses *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_HistoricDenominationRevenueCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_DenominationPendingCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_DenominationPending *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_HistoricReserveSummaryCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_HistoricReserveSummary *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_ExchangeSignkeysCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_ExchangeSignkeys *dc); + + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_WireFormatInconsistencyCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_WireFormatInconsistency *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_WireOutInconsistencyCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_WireOutInconsistency *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc); + +typedef enum GNUNET_GenericReturnValue +(*TALER_AUDITORDB_RowMinorInconsistenciesCallback)( + void *cls, + uint64_t serial_id, + const struct TALER_AUDITORDB_RowMinorInconsistencies *dc); + /** * @brief The plugin API, returned from the plugin's "init" function. * The argument given to "init" is simply a configuration handle. @@ -1012,7 +1254,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_amount_arithmetic_inconsistency)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, void *cb_cls); @@ -1020,7 +1263,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_coin_inconsistency)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_CoinInconsistencyCallback cb, void *cb_cls); @@ -1028,7 +1272,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_row_inconsistency)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_RowInconsistencyCallback cb, void *cb_cls); @@ -1036,7 +1281,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_emergency)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_EmergencyCallback cb, void *cb_cls); @@ -1044,7 +1290,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_emergency_by_count)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_EmergenciesByCountCallback cb, void *cb_cls); @@ -1052,7 +1299,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_denomination_key_validity_withdraw_inconsistency)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback cb, void *cb_cls); @@ -1060,7 +1308,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_purse_not_closed_inconsistencies)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback cb, void *cb_cls); @@ -1068,7 +1317,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_reserve_balance_insufficient_inconsistency)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback cb, void *cb_cls); @@ -1085,7 +1335,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_auditor_closure_lags)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_ClosureLagsCallback cb, void *cb_cls); @@ -1093,7 +1344,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_progress)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_ProgressCallback cb, void *cb_cls); @@ -1101,7 +1353,8 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_refreshes_hanging)( void *cls, - uint64_t start_id, + int64_t limit, + uint64_t offset, bool return_suppressed, TALER_AUDITORDB_RefreshesHangingCallback cb, void *cb_cls); @@ -1249,6 +1502,529 @@ struct TALER_AUDITORDB_Plugin const struct TALER_AUDITORDB_Generic_Update *gu); + + enum GNUNET_DB_QueryStatus + (*update_emergency_by_count)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + enum GNUNET_DB_QueryStatus + (*update_row_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + enum GNUNET_DB_QueryStatus + (*update_purse_not_closed_inconsistencies)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + enum GNUNET_DB_QueryStatus + (*update_reserve_balance_insufficient_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + enum GNUNET_DB_QueryStatus + (*update_coin_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + enum GNUNET_DB_QueryStatus + (*update_progress)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + enum GNUNET_DB_QueryStatus + (*update_denomination_key_validity_withdraw_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + enum GNUNET_DB_QueryStatus + (*update_refreshes_hanging)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + enum GNUNET_DB_QueryStatus + (*update_emergency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + enum GNUNET_DB_QueryStatus + (*update_closure_lags)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_reserve_in_inconsistency)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveInInconsistencyCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_reserve_in_inconsistency)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_reserve_in_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_ReserveInInconsistency *dc); + + + enum GNUNET_DB_QueryStatus + (*update_reserve_in_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_reserve_not_closed_inconsistency)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_reserve_not_closed_inconsistency)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_reserve_not_closed_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc); + + + enum GNUNET_DB_QueryStatus + (*update_reserve_not_closed_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_denominations_without_sigs)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_DenominationsWithoutSigsCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_denominations_without_sigs)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_denominations_without_sigs)( + void *cls, + const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc); + + + enum GNUNET_DB_QueryStatus + (*update_denominations_without_sigs)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_misattribution_in_inconsistency)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_MisattributionInInconsistencyCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_misattribution_in_inconsistency)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_misattribution_in_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_MisattributionInInconsistency *dc); + + + enum GNUNET_DB_QueryStatus + (*update_misattribution_in_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + enum GNUNET_DB_QueryStatus + (*get_reserves)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReservesCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_reserves)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_reserves)( + void *cls, + const struct TALER_AUDITORDB_Reserves *dc); + + + enum GNUNET_DB_QueryStatus + (*update_reserves)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_purses)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_PursesCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_purses)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_purses)( + void *cls, + const struct TALER_AUDITORDB_Purses *dc); + + + enum GNUNET_DB_QueryStatus + (*update_purses)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_historic_denomination_revenue)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_HistoricDenominationRevenueCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_historic_denomination_revenue)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_historic_denomination_revenue)( + void *cls, + const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc); + + + enum GNUNET_DB_QueryStatus + (*update_historic_denomination_revenue)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + enum GNUNET_DB_QueryStatus + (*get_denomination_pending)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_DenominationPendingCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_denomination_pending)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_denomination_pending)( + void *cls, + const struct TALER_AUDITORDB_DenominationPending *dc); + + + enum GNUNET_DB_QueryStatus + (*update_denomination_pending)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_historic_reserve_summary)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_HistoricReserveSummaryCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_historic_reserve_summary)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_historic_reserve_summary)( + void *cls, + const struct TALER_AUDITORDB_HistoricReserveSummary *dc); + + + enum GNUNET_DB_QueryStatus + (*update_historic_reserve_summary)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_exchange_signkeys)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ExchangeSignkeysCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_exchange_signkeys)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_exchange_signkeys)( + void *cls, + const struct TALER_AUDITORDB_ExchangeSignkeys *dc); + + + enum GNUNET_DB_QueryStatus + (*update_exchange_signkeys)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_wire_format_inconsistency)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_WireFormatInconsistencyCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_wire_format_inconsistency)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_wire_format_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_WireFormatInconsistency *dc); + + + enum GNUNET_DB_QueryStatus + (*update_wire_format_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + enum GNUNET_DB_QueryStatus + (*get_wire_out_inconsistency)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_WireOutInconsistencyCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_wire_out_inconsistency)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_wire_out_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_WireOutInconsistency *dc); + + + enum GNUNET_DB_QueryStatus + (*update_wire_out_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_reserve_balance_summary_wrong_inconsistency)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_reserve_balance_summary_wrong_inconsistency)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_reserve_balance_summary_wrong_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc); + + + enum GNUNET_DB_QueryStatus + (*update_reserve_balance_summary_wrong_inconsistency)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + + + + + + + + enum GNUNET_DB_QueryStatus + (*get_row_minor_inconsistencies)( + void *cls, + int64_t limit, + uint64_t offset, + bool return_suppressed, + TALER_AUDITORDB_RowMinorInconsistenciesCallback cb, + void *cb_cls); + + + enum GNUNET_DB_QueryStatus + (*delete_row_minor_inconsistencies)( + void *cls, + uint64_t row_id); + + + enum GNUNET_DB_QueryStatus + (*insert_row_minor_inconsistencies)( + void *cls, + const struct TALER_AUDITORDB_RowMinorInconsistencies *dc); + + + enum GNUNET_DB_QueryStatus + (*update_row_minor_inconsistencies)( + void *cls, + const struct TALER_AUDITORDB_Generic_Update *gu); + + /** * Insert information about a reserve. There must not be an * existing record for the reserve. |