commit 4b77ed9f39cd0512735dee9f4f9daeb80f4c1f97
parent 26e4d3e24ff5f567bde3905a5185c54ccc6553c4
Author: Sebastian <sebasjm@gmail.com>
Date: Wed, 11 May 2022 15:47:00 -0300
fix: should calculate contract hash when was not send as req param
used in lookup_refunds_detailed
Diffstat:
1 file changed, 42 insertions(+), 22 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -1052,33 +1052,53 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
/* Check if client provided the right hash code of the contract terms */
if (NULL != god->contract_terms)
{
- struct TALER_PrivateContractHashP h;
-
contract_available = true;
- if (GNUNET_OK !=
- TALER_JSON_contract_hash (god->contract_terms,
- &h))
+
+ if (GNUNET_YES == GNUNET_is_zero (&god->h_contract_terms))
{
- GNUNET_break (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH,
- "contract terms");
+
+ if (GNUNET_OK !=
+ TALER_JSON_contract_hash (god->contract_terms,
+ &god->h_contract_terms))
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH,
+ "contract terms");
+ }
+
}
- contract_match = (0 ==
- GNUNET_memcmp (&h,
- &god->h_contract_terms));
- if ( (GNUNET_NO ==
- GNUNET_is_zero (&god->h_contract_terms)) &&
- (! contract_match) )
+ else
{
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (
- connection,
- MHD_HTTP_FORBIDDEN,
- TALER_EC_MERCHANT_GENERIC_CONTRACT_HASH_DOES_NOT_MATCH_ORDER,
- NULL);
+
+ struct TALER_PrivateContractHashP h;
+
+ if (GNUNET_OK !=
+ TALER_JSON_contract_hash (god->contract_terms,
+ &h))
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH,
+ "contract terms");
+ }
+ contract_match = (0 ==
+ GNUNET_memcmp (&h,
+ &god->h_contract_terms));
+ if ( !contract_match )
+ {
+ GNUNET_break_op (0);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_FORBIDDEN,
+ TALER_EC_MERCHANT_GENERIC_CONTRACT_HASH_DOES_NOT_MATCH_ORDER,
+ NULL);
+ }
+
}
+
}
if (contract_available)