diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2023-12-13 14:33:23 +0100 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2023-12-13 14:33:23 +0100 |
commit | 227dc29fcd78f0cd6b394ff2716c548f9be2adb6 (patch) | |
tree | ce8a2ab1513b940ae3aa9fd368adcc9c321231be /src/exchange/taler-exchange-httpd_responses.c | |
parent | d3ed984b0ffa6e0ffad4193f4e881db53ac75565 (diff) | |
download | exchange-227dc29fcd78f0cd6b394ff2716c548f9be2adb6.tar.gz exchange-227dc29fcd78f0cd6b394ff2716c548f9be2adb6.tar.bz2 exchange-227dc29fcd78f0cd6b394ff2716c548f9be2adb6.zip |
[wip, #7267] more refined age commitment conflict response during deposit
Distinguish between and communicate:
a) null hash value expected, got non-null
b) non-null hash value expected, got null
c) hash value of known coin differ from given
Diffstat (limited to 'src/exchange/taler-exchange-httpd_responses.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index c1aa9db6f..2d8dede51 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -23,9 +23,11 @@ * @author Christian Grothoff */ #include "platform.h" +#include <gnunet/gnunet_json_lib.h> #include <microhttpd.h> #include <zlib.h> #include "taler-exchange-httpd_responses.h" +#include "taler_exchangedb_plugin.h" #include "taler_util.h" #include "taler_json_lib.h" #include "taler_mhd_lib.h" @@ -181,10 +183,31 @@ MHD_RESULT TEH_RESPONSE_reply_coin_age_commitment_conflict ( struct MHD_Connection *connection, enum TALER_ErrorCode ec, + enum TALER_EXCHANGEDB_CoinKnownStatus status, const struct TALER_DenominationHashP *h_denom_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_AgeCommitmentHash *h_age_commitment_hash) + const struct TALER_AgeCommitmentHash *h_age_commitment) { + const struct TALER_AgeCommitmentHash *hac = h_age_commitment; + const char *conflict_detail; + + switch (status) + { + + case TALER_EXCHANGEDB_CKS_AGE_CONFLICT_EXPECTED_NULL: + conflict_detail = "expected NULL age commitment hash"; + hac = NULL; + break; + case TALER_EXCHANGEDB_CKS_AGE_CONFLICT_EXPECTED_NON_NULL: + conflict_detail = "unexpected NULL age commitment hash"; + break; + case TALER_EXCHANGEDB_CKS_AGE_CONFLICT_VALUE_DIFFERS: + conflict_detail = "expected age commitment hash differs"; + break; + default: + GNUNET_assert (0); + } + return TALER_MHD_REPLY_JSON_PACK ( connection, TALER_ErrorCode_get_http_status_safe (ec), @@ -193,8 +216,11 @@ TEH_RESPONSE_reply_coin_age_commitment_conflict ( coin_pub), GNUNET_JSON_pack_data_auto ("h_denom_pub", h_denom_pub), - GNUNET_JSON_pack_data_auto ("h_age_commitment_hash", - h_age_commitment_hash) + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_data_auto ("expected_age_commitment_hash", + hac)), + GNUNET_JSON_pack_string ("conflict_detail", + conflict_detail) ); } |