commit 6b74255281f87487c4ff1012374d9ef621cb3d55
parent 87e64b29f4905ccb8b24308decebbbd894e85aad
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 2 Jun 2026 20:48:39 +0200
use year from client
Diffstat:
4 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/src/donau/donau-httpd_post-batch-issue-CHARITY_ID.c b/src/donau/donau-httpd_post-batch-issue-CHARITY_ID.c
@@ -373,8 +373,25 @@ start:
TALER_EC_DONAU_GENERIC_DONATION_UNIT_UNKNOWN,
NULL);
}
- if (dk->validity_year <
- GNUNET_TIME_get_current_year ())
+ if (dk->validity_year != year)
+ {
+ char year_str[20];
+
+ GNUNET_break_op (0);
+ free_bkps (num_bkps,
+ bkps);
+ GNUNET_snprintf (year_str,
+ sizeof (year_str),
+ "%llu",
+ (unsigned long long) dk->validity_year);
+ json_decref (blind_signatures);
+ return TALER_MHD_reply_with_error (rc->connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_DONAU_GENERIC_DONATION_UNIT_WRONG_YEAR,
+ year_str);
+ }
+ year = GNUNET_TIME_get_current_year ();
+ if (dk->validity_year < year)
{
char year_str[20];
@@ -391,8 +408,7 @@ start:
TALER_EC_DONAU_GENERIC_DONATION_UNIT_EXPIRED,
year_str);
}
- if (dk->validity_year >
- GNUNET_TIME_get_current_year ())
+ if (dk->validity_year > year)
{
char year_str[20];
@@ -449,6 +465,7 @@ start:
/* save new receipts to date and save receipts Request (blinded signatures,
* charity id, amount, hash over bkps) to make it idempotent*/
qs_insert_ir = DONAUDB_insert_issued_receipt (DH_context,
+ (uint32_t) year,
num_bkps,
du_sigs,
(uint64_t) charity_id,
diff --git a/src/donaudb/insert_issued_receipt.c b/src/donaudb/insert_issued_receipt.c
@@ -32,14 +32,14 @@
enum GNUNET_DB_QueryStatus
DONAUDB_insert_issued_receipt (
struct DONAUDB_PostgresContext *ctx,
- const size_t num_blinded_sig,
+ uint32_t year,
+ size_t num_blinded_sig,
const struct DONAU_BlindedDonationUnitSignature signatures[num_blinded_sig],
- const uint64_t charity_id,
+ uint64_t charity_id,
const struct DONAU_DonationReceiptHashP *h_receipt,
const struct TALER_Amount *amount_receipts_request,
bool *smaller_than_max_per_year)
{
- uint32_t year = GNUNET_TIME_get_current_year ();
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&charity_id),
DONAU_PQ_query_param_array_blinded_donation_unit_sig (num_blinded_sig,
diff --git a/src/donaudb/test_donaudb.c b/src/donaudb/test_donaudb.c
@@ -395,6 +395,7 @@ run (void *cls)
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
DONAUDB_insert_issued_receipt (ctx,
+ GNUNET_TIME_get_current_year (),
num_b_sigs,
du_sigs,
charity_id,
diff --git a/src/include/donau-database/insert_issued_receipt.h b/src/include/donau-database/insert_issued_receipt.h
@@ -28,6 +28,7 @@
* Insert issued blinded donation receipt to the charity.
*
* @param ctx closure
+ * @param year the current year
* @param num_blinded_sig
* @param signatures blinded signatures
* @param charity_id identifier of the charity
@@ -39,9 +40,10 @@
enum GNUNET_DB_QueryStatus
DONAUDB_insert_issued_receipt (
struct DONAUDB_PostgresContext *ctx,
- const size_t num_blinded_sig,
+ uint32_t year,
+ size_t num_blinded_sig,
const struct DONAU_BlindedDonationUnitSignature signatures[num_blinded_sig],
- const uint64_t charity_id,
+ uint64_t charity_id,
const struct DONAU_DonationReceiptHashP *h_receipt,
const struct TALER_Amount *amount_receipts_request,
bool *smaller_than_max_per_year);