commit 0c3f574d65c55e34ddbbdc1576c754fa42c7b464
parent 22d64ba319681fe76d92a3686f3064c8ae788412
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 4 Apr 2026 10:18:07 +0200
return details on conflict with insufficient funds to client
Diffstat:
2 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/src/include/taler/taler-exchange/post-withdraw_blinded.h b/src/include/taler/taler-exchange/post-withdraw_blinded.h
@@ -276,6 +276,38 @@ struct TALER_EXCHANGE_PostWithdrawBlindedResponse
struct TALER_EXCHANGE_WithdrawCreated created;
/**
+ * Details if the status is #MHD_HTTP_CONFLICT.
+ */
+ struct
+ {
+ /**
+ * Details depending on the EC.
+ */
+ union
+ {
+
+ /**
+ * Further details if the EC is
+ * #TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS.
+ */
+ struct
+ {
+ /**
+ * Balance of the reserve.
+ */
+ struct TALER_Amount balance;
+
+ /**
+ * Amount that was requested.
+ */
+ struct TALER_Amount requested_amount;
+ } generic_insufficient_funds;
+
+ } details;
+
+ } conflict;
+
+ /**
* Details if the status is #MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS.
*/
struct TALER_EXCHANGE_KycNeededRedirect unavailable_for_legal_reasons;
diff --git a/src/lib/exchange_api_post-withdraw_blinded.c b/src/lib/exchange_api_post-withdraw_blinded.c
@@ -396,9 +396,33 @@ handle_withdraw_blinded_finished (
wbr.hr.hint = TALER_JSON_get_error_hint (j_response);
break;
case MHD_HTTP_CONFLICT:
- /* The age requirements might not have been met */
wbr.hr.ec = TALER_JSON_get_error_code (j_response);
wbr.hr.hint = TALER_JSON_get_error_hint (j_response);
+ if (TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS ==
+ wbr.hr.ec)
+ {
+ struct GNUNET_JSON_Specification spec[] = {
+ TALER_JSON_spec_amount_any (
+ "balance",
+ &wbr.details.conflict.details.generic_insufficient_funds.balance),
+ TALER_JSON_spec_amount_any (
+ "requested_amount",
+ &wbr.details.conflict.details.generic_insufficient_funds.
+ requested_amount),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (j_response,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ wbr.hr.http_status = 0;
+ wbr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ break;
+ }
+ }
break;
case MHD_HTTP_GONE:
/* could happen if denomination was revoked */