commit 376dc1548dbc1cfde90c100bd55abf1de84973a8
parent 1a5f1cbdb517dc3b570f28fdedf2f136fbb0f2a8
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 27 May 2026 17:25:56 +0200
allow exchange selection to fail if the payment amount is zero
Diffstat:
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/backend/taler-merchant-httpd_post-private-orders.c b/src/backend/taler-merchant-httpd_post-private-orders.c
@@ -2322,6 +2322,26 @@ phase_select_wire_method (struct OrderContext *oc)
struct WireMethodCandidate *best = NULL;
unsigned int max_choices = 0;
unsigned int want_choices = 0;
+ bool zero_amount = false;
+
+ switch (oc->parse_order.order->base->version)
+ {
+ case TALER_MERCHANT_CONTRACT_VERSION_0:
+ ea = &oc->parse_order.order->details.v0.brutto;
+ if (TALER_amount_is_zero (ea))
+ zero_amount = true;
+ break;
+ case TALER_MERCHANT_CONTRACT_VERSION_1:
+ for (unsigned int i = 0; i<oc->parse_choices.choices_len; i++)
+ {
+ ea = &oc->parse_choices.choices[i].amount;
+ if (TALER_amount_is_zero (ea))
+ zero_amount = true;
+ }
+ break;
+ default:
+ GNUNET_assert (0);
+ }
for (struct WireMethodCandidate *wmc = oc->add_payment_details.wmc_head;
NULL != wmc;
@@ -2379,6 +2399,7 @@ phase_select_wire_method (struct OrderContext *oc)
}
if ( (NULL == best) &&
+ (! zero_amount) &&
(NULL != oc->parse_request.payment_target) )
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2392,7 +2413,8 @@ phase_select_wire_method (struct OrderContext *oc)
return;
}
- if (NULL == best)
+ if ( (NULL == best) &&
+ (! zero_amount) )
{
enum MHD_Result mret;