commit fee49e7f4eda1c19e4609b0a0fca16e45af2c623 parent b69e82095deb7a1d85eccdcd05e2203207da252d Author: Florian Dold <dold@taler.net> Date: Mon, 17 Aug 2026 15:35:40 +0200 merchant: allow indefinite token-family validity Diffstat:
6 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_get-config.c b/src/backend/taler-merchant-httpd_get-config.c @@ -44,7 +44,7 @@ * #MERCHANT_PROTOCOL_CURRENT and #MERCHANT_PROTOCOL_AGE in * merchant_api_get_config.c! */ -#define MERCHANT_PROTOCOL_VERSION "35:0:23" +#define MERCHANT_PROTOCOL_VERSION "36:0:24" /** diff --git a/src/backend/taler-merchant-httpd_patch-private-tokenfamilies-TOKEN_FAMILY_SLUG.c b/src/backend/taler-merchant-httpd_patch-private-tokenfamilies-TOKEN_FAMILY_SLUG.c @@ -50,7 +50,9 @@ TMH_private_patch_token_family_SLUG (const struct TMH_RequestHandler *rh, { struct TMH_MerchantInstance *mi = hc->instance; const char *slug = hc->infix; - struct TALER_MERCHANTDB_TokenFamilyDetails details = {0}; + struct TALER_MERCHANTDB_TokenFamilyDetails details = { + .valid_before = GNUNET_TIME_UNIT_FOREVER_TS + }; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("name", (const char **) &details.name), @@ -66,8 +68,10 @@ TMH_private_patch_token_family_SLUG (const struct TMH_RequestHandler *rh, NULL), GNUNET_JSON_spec_timestamp ("valid_after", &details.valid_after), - GNUNET_JSON_spec_timestamp ("valid_before", - &details.valid_before), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_timestamp ("valid_before", + &details.valid_before), + NULL), GNUNET_JSON_spec_end () }; diff --git a/src/backend/taler-merchant-httpd_post-private-tokenfamilies.c b/src/backend/taler-merchant-httpd_post-private-tokenfamilies.c @@ -90,7 +90,9 @@ TMH_private_post_token_families (const struct TMH_RequestHandler *rh, struct TMH_HandlerContext *hc) { struct TMH_MerchantInstance *mi = hc->instance; - struct TALER_MERCHANTDB_TokenFamilyDetails details = { 0 }; + struct TALER_MERCHANTDB_TokenFamilyDetails details = { + .valid_before = GNUNET_TIME_UNIT_FOREVER_TS + }; const char *kind = NULL; bool no_valid_after = false; enum GNUNET_DB_QueryStatus qs; @@ -113,8 +115,10 @@ TMH_private_post_token_families (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_timestamp ("valid_after", &details.valid_after), &no_valid_after), - GNUNET_JSON_spec_timestamp ("valid_before", - &details.valid_before), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_timestamp ("valid_before", + &details.valid_before), + NULL), GNUNET_JSON_spec_relative_time ("duration", &details.duration), GNUNET_JSON_spec_relative_time ("validity_granularity", diff --git a/src/include/taler/merchant/post-private-tokenfamilies.h b/src/include/taler/merchant/post-private-tokenfamilies.h @@ -188,7 +188,8 @@ TALER_MERCHANT_post_private_tokenfamilies_set_options_ ( * @param name human-readable name * @param description human-readable description * @param valid_after start of validity period - * @param valid_before end of validity period + * @param valid_before end of validity period; + * #GNUNET_TIME_UNIT_FOREVER_TS to omit the field and use no end time * @param duration duration of individual token validity * @param validity_granularity granularity for validity alignment * @param start_offset offset from purchase to start of validity diff --git a/src/lib/merchant_api_get-config.c b/src/lib/merchant_api_get-config.c @@ -34,12 +34,12 @@ * Which version of the Taler protocol is implemented * by this library? Used to determine compatibility. */ -#define MERCHANT_PROTOCOL_CURRENT 35 +#define MERCHANT_PROTOCOL_CURRENT 36 /** * How many configs are we backwards-compatible with? */ -#define MERCHANT_PROTOCOL_AGE 11 +#define MERCHANT_PROTOCOL_AGE 12 /** * How many exchanges do we allow at most per merchant? diff --git a/src/lib/merchant_api_post-private-tokenfamilies.c b/src/lib/merchant_api_post-private-tokenfamilies.c @@ -299,8 +299,12 @@ TALER_MERCHANT_post_private_tokenfamilies_start ( GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_timestamp ("valid_after", ptfh->valid_after)), - GNUNET_JSON_pack_timestamp ("valid_before", - ptfh->valid_before), + GNUNET_JSON_pack_conditional ( + GNUNET_TIME_timestamp_cmp (ptfh->valid_before, + !=, + GNUNET_TIME_UNIT_FOREVER_TS), + GNUNET_JSON_pack_timestamp ("valid_before", + ptfh->valid_before)), GNUNET_JSON_pack_time_rel ("duration", ptfh->duration), GNUNET_JSON_pack_time_rel ("validity_granularity",