commit 22f5536757abeabaec7ff24e2075321827919666
parent 7c46fcf009916f48677ef418abc5b180bac68135
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 2 Jun 2026 19:33:13 +0200
misc minor bugfixes
Diffstat:
7 files changed, 82 insertions(+), 19 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
@@ -319,6 +319,7 @@ start:
GNUNET_break (0);
free_bkps (num_bkps,
bkps);
+ json_decref (blind_signatures);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
@@ -365,11 +366,48 @@ start:
GNUNET_break_op (0);
free_bkps (num_bkps,
bkps);
+ json_decref (blind_signatures);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_DONAU_GENERIC_DONATION_UNIT_UNKNOWN,
NULL);
}
+ if (dk->validity_year <
+ GNUNET_TIME_get_current_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_GONE,
+ TALER_EC_DONAU_GENERIC_DONATION_UNIT_EXPIRED,
+ year_str);
+ }
+ if (dk->validity_year >
+ GNUNET_TIME_get_current_year ())
+ {
+ char year_str[20];
+
+ GNUNET_break_op (0);
+ GNUNET_snprintf (year_str,
+ sizeof (year_str),
+ "%llu",
+ (unsigned long long) dk->validity_year);
+ free_bkps (num_bkps,
+ bkps);
+ json_decref (blind_signatures);
+ return TALER_MHD_reply_with_error (rc->connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_DONAU_GENERIC_DONATION_UNIT_TOO_EARLY,
+ year_str);
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"public key value: %s\n",
TALER_amount2s (&dk->value));
@@ -399,6 +437,7 @@ start:
GNUNET_break_op (0);
free_bkps (num_bkps,
bkps);
+ json_decref (blind_signatures);
return TALER_MHD_reply_with_ec (rc->connection,
batch_sign_ec,
NULL);
@@ -422,6 +461,7 @@ start:
GNUNET_break (0);
free_bkps (num_bkps,
bkps);
+ json_decref (blind_signatures);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
@@ -436,6 +476,7 @@ start:
GNUNET_break_op (0);
free_bkps (num_bkps,
bkps);
+ json_decref (blind_signatures);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DONAU_EXCEEDING_DONATION_LIMIT,
diff --git a/src/donau/donau-httpd_post-batch-submit.c b/src/donau/donau-httpd_post-batch-submit.c
@@ -234,11 +234,11 @@ DH_handler_post_batch_submit (struct DH_RequestContext *rc,
GNUNET_break (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- NULL);
+ TALER_EC_GENERIC_DB_STORE_FAILED,
+ "insert_submitted_receipts");
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"submitted receipts inserted!\n");
return TALER_MHD_reply_static (
diff --git a/src/donau/donau-httpd_post-charities.c b/src/donau/donau-httpd_post-charities.c
@@ -92,7 +92,6 @@ DH_handler_post_charities (struct DH_RequestContext *rc,
TALER_EC_GENERIC_DB_STORE_FAILED,
"insert_charity");
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- GNUNET_break (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_CONFLICT,
TALER_EC_DONAU_CHARITY_PUB_EXISTS,
diff --git a/src/donaudb/donau_do_insert_issued_receipts.sql b/src/donaudb/donau_do_insert_issued_receipts.sql
@@ -14,11 +14,13 @@
-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
--
-CREATE OR REPLACE FUNCTION do_insert_issued_receipts (
- IN in_charity_id BIGINT -- charity id which made the issue receitps request
+DROP FUNCTION IF EXISTS do_insert_issued_receipts;
+CREATE FUNCTION do_insert_issued_receipts (
+ IN in_charity_id BIGINT -- charity id which made the issue receipts request
,IN in_blinded_sig BYTEA[] -- blinded signatures
,IN in_receipt_hash BYTEA -- hash over all budi key pairs (primary key)
,IN in_amount taler_amount -- total amount of the requested receipts
+ ,IN in_year INT4
,OUT out_smaller_than_max_per_year BOOLEAN
)
LANGUAGE plpgsql
@@ -27,6 +29,7 @@ DECLARE
old_receipts_to_date taler_amount;
new_receipts_to_date taler_amount;
max_per_year taler_amount;
+ my_year INT4;
BEGIN
-- Get charity values
SELECT
@@ -34,13 +37,23 @@ BEGIN
,(chari.receipts_to_date).frac
,(chari.max_per_year).val
,(chari.max_per_year).frac
+ ,current_year
INTO
old_receipts_to_date.val
,old_receipts_to_date.frac
,max_per_year.val
,max_per_year.frac
+ ,my_year
FROM charities chari
WHERE charity_id=in_charity_id;
+
+ IF (my_year < in_year)
+ THEN
+ -- bump current year
+ old_receipts_to_date.val = 0;
+ old_receipts_to_date.frac = 0;
+ END IF;
+
-- calculate sum of the recent amount of receipts and the issued amount
SELECT *
FROM amount_add(old_receipts_to_date, in_amount)
@@ -52,10 +65,20 @@ BEGIN
THEN
out_smaller_than_max_per_year=TRUE;
UPDATE charities
- SET receipts_to_date=new_receipts_to_date
- WHERE charity_id=in_charity_id;
- INSERT INTO receipts_issued (blinded_sig, charity_id, receipt_hash, amount)
- VALUES (in_blinded_sig, in_charity_id, in_receipt_hash, in_amount);
+ SET receipts_to_date=new_receipts_to_date,
+ current_year=in_year
+ WHERE charity_id=in_charity_id;
+ INSERT INTO receipts_issued (
+ blinded_sig
+ ,charity_id
+ ,receipt_hash
+ ,amount
+ ) VALUES (
+ in_blinded_sig
+ ,in_charity_id
+ ,in_receipt_hash
+ ,in_amount
+ );
ELSE
out_smaller_than_max_per_year=FALSE;
END IF;
diff --git a/src/donaudb/insert_issued_receipt.c b/src/donaudb/insert_issued_receipt.c
@@ -39,12 +39,7 @@ DONAUDB_insert_issued_receipt (
const struct TALER_Amount *amount_receipts_request,
bool *smaller_than_max_per_year)
{
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_bool ("smaller_than_max_per_year",
- smaller_than_max_per_year),
- GNUNET_PQ_result_spec_end
- };
-
+ 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,
@@ -53,11 +48,16 @@ DONAUDB_insert_issued_receipt (
GNUNET_PQ_query_param_auto_from_type (&h_receipt->hash),
TALER_PQ_query_param_amount (ctx->conn,
amount_receipts_request),
+ GNUNET_PQ_query_param_uint32 (&year),
GNUNET_PQ_query_param_end
};
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_bool ("smaller_than_max_per_year",
+ smaller_than_max_per_year),
+ GNUNET_PQ_result_spec_end
+ };
enum GNUNET_DB_QueryStatus qs;
-
PREPARE (ctx,
"insert_issued_receipts_request",
"SELECT "
diff --git a/src/include/donau_signatures.h b/src/include/donau_signatures.h
@@ -27,7 +27,7 @@
/**
- * The signature is done by the Donau. The Donau signs over the total amount of the corresponding year, the corresponding year and the donation identifier of a specific donor. The statement confirms that the donor made this total in donations for the given year.
+ * The signature is done by the Donau. The Donau signes over the total amount of the corresponding year, the corresponding year and the donation identifier of a specific donor. The statement confirms that the donor made this total in donations for the given year.
*/
#define DONAU_SIGNATURE_DONAU_DONATION_STATEMENT 1500
diff --git a/src/lib/donau_api_csr_post.c b/src/lib/donau_api_csr_post.c
@@ -95,7 +95,7 @@ handle_csr_issue_post_finished (void *cls,
{
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_exchange_blinding_values (
- "ewv",
+ "r_pubs",
(struct TALER_ExchangeBlindingValues *) &csrresp.details.ok.alg_values
),
GNUNET_JSON_spec_end ()