exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit ea40014ff62602b0c2c3264d7d42723bbc1b0303
parent 5b32c04efdb739126682b153e55593dd1036b5d4
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 11 Oct 2026 14:16:39 +0200

use 412 for too early, not 410

Diffstat:
Msrc/exchange/taler-exchange-httpd_responses.c | 8+++++++-
Msrc/exchange/taler-exchange-httpd_responses.h | 4++++
Msrc/lib/exchange_api_post-batch-deposit.c | 6++++++
Msrc/lib/exchange_api_post-blinding-prepare.c | 7+++++++
Msrc/lib/exchange_api_post-purses-PURSE_PUB-create.c | 6++++++
Msrc/lib/exchange_api_post-purses-PURSE_PUB-deposit.c | 5+++++
6 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c @@ -84,6 +84,12 @@ TEH_RESPONSE_reply_expired_denom_pub_hash ( enum TALER_ErrorCode ecr; struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); + /* A denomination that is not yet valid will become usable later, so + it must not be reported as permanently gone. */ + unsigned int http_status + = (TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE == ec) + ? MHD_HTTP_PRECONDITION_FAILED + : MHD_HTTP_GONE; GNUNET_assert (NULL != oper); ecr = TALER_exchange_online_denomination_expired_sign ( @@ -103,7 +109,7 @@ TEH_RESPONSE_reply_expired_denom_pub_hash ( } return TALER_MHD_REPLY_JSON_PACK ( connection, - MHD_HTTP_GONE, + http_status, TALER_JSON_pack_ec (ec), GNUNET_JSON_pack_string ("oper", oper), diff --git a/src/exchange/taler-exchange-httpd_responses.h b/src/exchange/taler-exchange-httpd_responses.h @@ -107,6 +107,10 @@ TEH_RESPONSE_reply_kyc_required ( /** * Send assertion that the given denomination key hash * is not usable (typically expired) at this time. + * The HTTP status is 412 Precondition Failed if @a ec is + * #TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE + * (the denomination will become usable later), and + * 410 Gone otherwise (expired, revoked, not eligible). * * @param connection connection to the client * @param dph denomination public key hash diff --git a/src/lib/exchange_api_post-batch-deposit.c b/src/lib/exchange_api_post-batch-deposit.c @@ -574,6 +574,12 @@ handle_deposit_finished (void *cls, dr->hr.ec = TALER_JSON_get_error_code (j); dr->hr.hint = TALER_JSON_get_error_hint (j); break; + case MHD_HTTP_PRECONDITION_FAILED: + /* could happen if we were too early and the denomination + is not yet valid */ + dr->hr.ec = TALER_JSON_get_error_code (j); + dr->hr.hint = TALER_JSON_get_error_hint (j); + break; case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: dr->hr.ec = TALER_JSON_get_error_code (j); dr->hr.hint = TALER_JSON_get_error_hint (j); diff --git a/src/lib/exchange_api_post-blinding-prepare.c b/src/lib/exchange_api_post-blinding-prepare.c @@ -278,6 +278,13 @@ handle_blinding_prepare_finished (void *cls, bpr.hr.hint = TALER_JSON_get_error_hint (j_response); break; + case MHD_HTTP_PRECONDITION_FAILED: + /* could happen if we were too early and the denomination + is not yet valid */ + bpr.hr.ec = TALER_JSON_get_error_code (j_response); + bpr.hr.hint = TALER_JSON_get_error_hint (j_response); + break; + case MHD_HTTP_INTERNAL_SERVER_ERROR: /* Server had an internal issue; we should retry, but this API leaves this to the application */ diff --git a/src/lib/exchange_api_post-purses-PURSE_PUB-create.c b/src/lib/exchange_api_post-purses-PURSE_PUB-create.c @@ -476,6 +476,12 @@ handle_purse_create_deposit_finished (void *cls, dr.hr.ec = TALER_JSON_get_error_code (j); dr.hr.hint = TALER_JSON_get_error_hint (j); break; + case MHD_HTTP_PRECONDITION_FAILED: + /* could happen if we were too early and the denomination + is not yet valid */ + dr.hr.ec = TALER_JSON_get_error_code (j); + dr.hr.hint = TALER_JSON_get_error_hint (j); + break; case MHD_HTTP_INTERNAL_SERVER_ERROR: dr.hr.ec = TALER_JSON_get_error_code (j); dr.hr.hint = TALER_JSON_get_error_hint (j); diff --git a/src/lib/exchange_api_post-purses-PURSE_PUB-deposit.c b/src/lib/exchange_api_post-purses-PURSE_PUB-deposit.c @@ -370,6 +370,11 @@ handle_purse_deposit_finished (void *cls, is outdated => left to clients */ dr.hr.ec = TALER_JSON_get_error_code (j); break; + case MHD_HTTP_PRECONDITION_FAILED: + /* could happen if we were too early and the denomination + is not yet valid */ + dr.hr.ec = TALER_JSON_get_error_code (j); + break; case MHD_HTTP_INTERNAL_SERVER_ERROR: dr.hr.ec = TALER_JSON_get_error_code (j); /* Server had an internal issue; we should retry, but this API