summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_responses.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-05-25 21:34:18 +0200
committerChristian Grothoff <christian@grothoff.org>2021-05-25 21:34:18 +0200
commit068068f40fc97f09525aaccf560a1be352abd159 (patch)
treeb4331505e2c538d591a755352aaeee912d6cac6f /src/exchange/taler-exchange-httpd_responses.c
parent0d1ab614c06f60f79de75a0f2ec30c33a69820dd (diff)
downloadexchange-068068f40fc97f09525aaccf560a1be352abd159.tar.gz
exchange-068068f40fc97f09525aaccf560a1be352abd159.tar.bz2
exchange-068068f40fc97f09525aaccf560a1be352abd159.zip
return signed error message with HTTP_GONE status if denomination is not currently valid for specified operation (#6889)
Diffstat (limited to 'src/exchange/taler-exchange-httpd_responses.c')
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 23407474..4bb3ffd4 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -466,6 +466,58 @@ TEH_RESPONSE_reply_unknown_denom_pub_hash (
}
+MHD_RESULT
+TEH_RESPONSE_reply_expired_denom_pub_hash (
+ struct MHD_Connection *connection,
+ const struct GNUNET_HashCode *dph,
+ struct GNUNET_TIME_Absolute now,
+ enum TALER_ErrorCode ec,
+ const char *oper)
+{
+ struct TALER_ExchangePublicKeyP epub;
+ struct TALER_ExchangeSignatureP esig;
+ enum TALER_ErrorCode ecr;
+ struct TALER_DenominationExpiredAffirmationPS dua = {
+ .purpose.size = htonl (sizeof (dua)),
+ .purpose.purpose = htonl (
+ TALER_SIGNATURE_EXCHANGE_AFFIRM_DENOM_EXPIRED),
+ .timestamp = GNUNET_TIME_absolute_hton (now),
+ .h_denom_pub = *dph,
+ };
+
+ strncpy (dua.operation,
+ oper,
+ sizeof (dua.operation));
+ ecr = TEH_keys_exchange_sign (&dua,
+ &epub,
+ &esig);
+ if (TALER_EC_NONE != ecr)
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ ec,
+ NULL);
+ }
+ return TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_GONE,
+ "{s:I,s:s,s:o,s:o,s:o,s:o}",
+ "code",
+ ec,
+ "oper",
+ oper,
+ "timestamp",
+ GNUNET_JSON_from_time_abs (now),
+ "exchange_pub",
+ GNUNET_JSON_from_data_auto (&epub),
+ "exchange_sig",
+ GNUNET_JSON_from_data_auto (&esig),
+ "h_denom_pub",
+ GNUNET_JSON_from_data_auto (dph));
+}
+
+
/**
* Send proof that a request is invalid to client because of
* insufficient funds. This function will create a message with all