merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 9f89147e2f5d8f1af7106b8eae2326cec38d0c96
parent f8a783870bf0262efc056b93b7b31eb98dbe5a43
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  9 Oct 2026 22:49:55 +0200

preserve minimum_age in templates as per spec

Diffstat:
Msrc/backend/taler-merchant-httpd_post-templates-TEMPLATE_ID.c | 15++++++++++++---
Msrc/util/template_parse.c | 12++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-templates-TEMPLATE_ID.c b/src/backend/taler-merchant-httpd_post-templates-TEMPLATE_ID.c @@ -2187,6 +2187,15 @@ handle_phase_create_order (struct UseContext *uc) order = json_object_get (uc->ihc.request_body, "order"); GNUNET_assert (json_is_object (order)); + if (0 != uc->template_contract.minimum_age) + { + GNUNET_assert ( + 0 == + json_object_set_new ( + order, + "minimum_age", + json_integer ((json_int_t) uc->template_contract.minimum_age))); + } if (! GNUNET_TIME_relative_is_forever ( uc->template_contract.max_pickup_duration)) { @@ -2231,9 +2240,9 @@ handle_phase_create_order (struct UseContext *uc) GNUNET_assert (0 == json_object_set_new ( uc->ihc.request_body, - "challenge", - GNUNET_JSON_from_data_auto ( - &uc->parse_request.challenge))); + "challenge", + GNUNET_JSON_from_data_auto ( + &uc->parse_request.challenge))); } uc->phase++; } diff --git a/src/util/template_parse.c b/src/util/template_parse.c @@ -405,6 +405,18 @@ TALER_MERCHANT_template_contract_parse ( *error_name = en; return GNUNET_SYSERR; } + if (out->minimum_age > UINT8_MAX) + { + /* Orders only support ages up to UINT8_MAX, see the "minimum_age" + field of the contract base terms. */ + GNUNET_break_op (0); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Invalid minimum_age %u in template\n", + (unsigned int) out->minimum_age); + if (NULL != error_name) + *error_name = "minimum_age"; + return GNUNET_SYSERR; + } if (GNUNET_OK != check_amount_limits (out, error_name))