summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/taler-merchant-httpd_exchanges.c22
-rw-r--r--src/backend/taler-merchant-httpd_helper.c13
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-pay.c44
-rw-r--r--src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c54
-rw-r--r--src/backend/taler-merchant-httpd_post-using-templates.c13
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders-ID.c8
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders.c8
-rw-r--r--src/backend/taler-merchant-httpd_private-get-rewards-ID.c22
-rw-r--r--src/backend/taler-merchant-httpd_private-patch-products-ID.c5
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c25
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c15
-rw-r--r--src/backend/taler-merchant-httpd_private-post-products.c5
-rw-r--r--src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-reward.c5
-rw-r--r--src/backend/taler-merchant-httpd_private-post-reserves.c5
-rw-r--r--src/backend/taler-merchant-httpd_private-post-transfers.c5
-rw-r--r--src/backenddb/pg_authorize_reward.c21
-rw-r--r--src/backenddb/pg_increase_refund.c1
17 files changed, 139 insertions, 132 deletions
diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c
index 22eb0f40..9b41e230 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -1274,7 +1274,6 @@ accept_exchanges (void *cls,
char *url;
char *mks;
struct TMH_Exchange *exchange;
- char *currency;
if (GNUNET_SYSERR == trusted_exchange_count)
return;
@@ -1285,27 +1284,6 @@ accept_exchanges (void *cls,
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
section,
- "CURRENCY",
- &currency))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- section,
- "CURRENCY");
- return;
- }
- if (0 != strcasecmp (currency,
- TMH_currency))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Exchange given in section `%s' is for another currency. Skipping.\n",
- section);
- GNUNET_free (currency);
- return;
- }
- GNUNET_free (currency);
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- section,
"EXCHANGE_BASE_URL",
&url))
{
diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c
index 172cb0a1..53b4fe89 100644
--- a/src/backend/taler-merchant-httpd_helper.c
+++ b/src/backend/taler-merchant-httpd_helper.c
@@ -328,9 +328,8 @@ TMH_products_array_valid (const json_t *products)
&unit),
NULL),
GNUNET_JSON_spec_mark_optional (
- TALER_JSON_spec_amount ("price",
- TMH_currency,
- &price),
+ TALER_JSON_spec_amount_any ("price",
+ &price),
NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("image",
@@ -422,10 +421,12 @@ TMH_template_contract_valid (const json_t *template_contract)
GNUNET_JSON_spec_string ("summary",
&summary),
NULL),
+ /* FIXME: #7951: may want to allow the template to only
+ fix the currency but not the amount; current approach
+ does not allow this! */
GNUNET_JSON_spec_mark_optional (
- TALER_JSON_spec_amount ("amount",
- TMH_currency,
- &amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &amount),
NULL),
GNUNET_JSON_spec_uint32 ("minimum_age",
&minimum_age),
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index c99a6c64..d17e98c8 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -925,6 +925,7 @@ batch_deposit_transaction (const struct ExchangeGroup *eg,
continue;
if (dc->found_in_db)
continue;
+ /* FIXME: #7951 */
GNUNET_assert (0 <=
TALER_amount_subtract (&amount_without_fees,
&dc->cdd.amount,
@@ -936,6 +937,7 @@ batch_deposit_transaction (const struct ExchangeGroup *eg,
}
else
{
+ /* FIXME: #7951 */
GNUNET_assert (
0 <=
TALER_amount_add (&total_without_fees,
@@ -1594,13 +1596,14 @@ check_coin_paid (void *cls,
(0 !=
strcmp (exchange_url,
dc->exchange_url)) ||
+ /* FIXME: #7951 */
(0 != TALER_amount_cmp (amount_with_fee,
&dc->cdd.amount)) )
continue; /* does not match, skip */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deposit of coin `%s' already in our DB.\n",
TALER_B2S (coin_pub));
-
+ /* FIXME: #7951 */
GNUNET_assert (0 <=
TALER_amount_add (&pc->total_paid,
&pc->total_paid,
@@ -1651,6 +1654,7 @@ check_coin_refunded (void *cls,
if (0 != GNUNET_memcmp (coin_pub,
&dc->cdd.coin_pub))
continue;
+ /* FIXME: #7951 */
GNUNET_assert (0 <=
TALER_amount_add (&pc->total_refunded,
&pc->total_refunded,
@@ -1685,6 +1689,7 @@ check_payment_sufficient (struct PayContext *pc)
total_wire_fee = pc->egs[0]->wire_fee;
for (unsigned int i = 1; i < pc->num_exchanges; i++)
{
+ /* FIXME: #7951 */
if (GNUNET_OK !=
TALER_amount_cmp_currency (&total_wire_fee,
&pc->egs[i]->wire_fee))
@@ -1695,6 +1700,7 @@ check_payment_sufficient (struct PayContext *pc)
total_wire_fee.currency);
return false;
}
+ /* FIXME: #7951 */
if (0 >
TALER_amount_add (&total_wire_fee,
&total_wire_fee,
@@ -1720,6 +1726,7 @@ check_payment_sufficient (struct PayContext *pc)
struct DepositConfirmation *dc = &pc->dc[i];
GNUNET_assert (dc->found_in_db);
+ /* FIXME: #7951 */
if ( (0 >
TALER_amount_add (&acc_fee,
&dc->deposit_fee,
@@ -1736,6 +1743,7 @@ check_payment_sufficient (struct PayContext *pc)
"Overflow adding up amounts");
return false;
}
+ /* FIXME: #7951 */
if (1 ==
TALER_amount_cmp (&dc->deposit_fee,
&dc->cdd.amount))
@@ -1780,6 +1788,7 @@ check_payment_sufficient (struct PayContext *pc)
/* add wire fee to the total fees */
+ /* FIXME: #7951 */
if (0 >
TALER_amount_add (&acc_fee,
&acc_fee,
@@ -1791,6 +1800,7 @@ check_payment_sufficient (struct PayContext *pc)
"Overflow adding up amounts");
return false;
}
+ /* FIXME: #7951 */
if (-1 == TALER_amount_cmp (&pc->max_fee,
&acc_fee))
{
@@ -2256,9 +2266,8 @@ parse_pay (struct PayContext *pc)
&dc->cdd.denom_sig),
GNUNET_JSON_spec_fixed_auto ("h_denom",
&dc->cdd.h_denom_pub),
- TALER_JSON_spec_amount ("contribution",
- TMH_currency,
- &dc->cdd.amount),
+ TALER_JSON_spec_amount_any ("contribution",
+ &dc->cdd.amount),
GNUNET_JSON_spec_string ("exchange_url",
&exchange_url),
/* if a minimum age was required, the minimum_age_sig and
@@ -2312,20 +2321,6 @@ parse_pay (struct PayContext *pc)
dc->index = coins_index;
dc->pc = pc;
- if (0 !=
- strcasecmp (dc->cdd.amount.currency,
- TMH_currency))
- {
- GNUNET_break_op (0);
- return (MHD_YES ==
- TALER_MHD_reply_with_error (pc->connection,
- MHD_HTTP_CONFLICT,
- TALER_EC_GENERIC_CURRENCY_MISMATCH,
- TMH_currency))
- ? GNUNET_NO
- : GNUNET_SYSERR;
- }
-
/* Check the consistency of the (potential) age restriction
* information. */
if (dc->no_age_commitment != dc->no_minimum_age_sig)
@@ -2405,6 +2400,9 @@ deposit_paid_check (
(0 ==
strcmp (dci->exchange_url,
exchange_url)) &&
+ (GNUNET_YES ==
+ TALER_amount_cmp_currency (&dci->cdd.amount,
+ amount_with_fee)) &&
(0 ==
TALER_amount_cmp (&dci->cdd.amount,
amount_with_fee)) )
@@ -2620,16 +2618,14 @@ check_contract (struct PayContext *pc)
{
const char *fulfillment_url = NULL;
struct GNUNET_JSON_Specification espec[] = {
- TALER_JSON_spec_amount ("amount",
- TMH_currency,
- &pc->amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &pc->amount),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("fulfillment_url",
&fulfillment_url),
NULL),
- TALER_JSON_spec_amount ("max_fee",
- TMH_currency,
- &pc->max_fee),
+ TALER_JSON_spec_amount_any ("max_fee",
+ &pc->max_fee),
GNUNET_JSON_spec_timestamp ("timestamp",
&pc->timestamp),
GNUNET_JSON_spec_timestamp ("refund_deadline",
diff --git a/src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c b/src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c
index 05347c9f..16bd5940 100644
--- a/src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c
+++ b/src/backend/taler-merchant-httpd_post-rewards-ID-pickup.c
@@ -496,6 +496,7 @@ compute_total_requested (void *cls,
struct TMH_Exchange *exchange)
{
struct PickupContext *pc = cls;
+ bool have_request = false;
(void) exchange;
pc->fo = NULL;
@@ -510,9 +511,6 @@ compute_total_requested (void *cls,
TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
return;
}
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TMH_currency,
- &pc->total_requested));
for (unsigned int i = 0; i<pc->planchets_length; i++)
{
struct TALER_PlanchetDetail *pd = &pc->planchets[i];
@@ -531,24 +529,50 @@ compute_total_requested (void *cls,
TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
return;
}
-
- if ( (GNUNET_YES !=
+ if (have_request)
+ {
+ if (GNUNET_YES !=
TALER_amount_cmp_currency (&pc->total_requested,
- &dpk->value)) ||
- (0 >
+ &dpk->value))
+ {
+ pc->http_status = MHD_HTTP_BAD_REQUEST;
+ pc->response =
+ TALER_MHD_make_error (TALER_EC_GENERIC_CURRENCY_MISMATCH,
+ "Must not mix currencies when picking up rewards");
+ MHD_resume_connection (pc->connection);
+ TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
+ return;
+ }
+ if (0 >
TALER_amount_add (&pc->total_requested,
&pc->total_requested,
- &dpk->value)) )
+ &dpk->value))
+ {
+ pc->http_status = MHD_HTTP_BAD_REQUEST;
+ pc->response =
+ TALER_MHD_make_error (TALER_EC_MERCHANT_REWARD_PICKUP_SUMMATION_FAILED,
+ "Could not add up values to compute pickup total");
+ MHD_resume_connection (pc->connection);
+ TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
+ return;
+ }
+ }
+ else
{
- pc->http_status = MHD_HTTP_BAD_REQUEST;
- pc->response =
- TALER_MHD_make_error (TALER_EC_MERCHANT_REWARD_PICKUP_SUMMATION_FAILED,
- "Could not add up values to compute pickup total");
- MHD_resume_connection (pc->connection);
- TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
- return;
+ pc->total_requested = dpk->value;
+ have_request = true;
}
}
+ if (! have_request)
+ {
+ pc->http_status = MHD_HTTP_BAD_REQUEST;
+ pc->response =
+ TALER_MHD_make_error (TALER_EC_MERCHANT_REWARD_PICKUP_SUMMATION_FAILED,
+ "Empty request array not allowed");
+ MHD_resume_connection (pc->connection);
+ TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
+ return;
+ }
pc->tr_initialized = true;
MHD_resume_connection (pc->connection);
TALER_MHD_daemon_trigger (); /* we resumed, kick MHD */
diff --git a/src/backend/taler-merchant-httpd_post-using-templates.c b/src/backend/taler-merchant-httpd_post-using-templates.c
index 67fc4b1e..9be6e46b 100644
--- a/src/backend/taler-merchant-httpd_post-using-templates.c
+++ b/src/backend/taler-merchant-httpd_post-using-templates.c
@@ -87,9 +87,8 @@ TMH_post_using_templates_ID (const struct TMH_RequestHandler *rh,
&summary),
NULL),
GNUNET_JSON_spec_mark_optional (
- TALER_JSON_spec_amount ("amount",
- TMH_currency,
- &amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &amount),
&no_amount),
GNUNET_JSON_spec_end ()
};
@@ -171,10 +170,12 @@ TMH_post_using_templates_ID (const struct TMH_RequestHandler *rh,
GNUNET_JSON_spec_string ("summary",
&tsummary),
NULL),
+ /* FIXME: #7951: may want to allow the template to only
+ fix the currency but not the amount; current approach
+ does not allow this! */
GNUNET_JSON_spec_mark_optional (
- TALER_JSON_spec_amount ("amount",
- TMH_currency,
- &tamount),
+ TALER_JSON_spec_amount_any ("amount",
+ &tamount),
&no_tamount),
GNUNET_JSON_spec_uint32 ("minimum_age",
&min_age),
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
index 20ed5fa7..14e71762 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -1039,9 +1039,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
from the contract terms! */
{
struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_amount ("amount",
- TMH_currency,
- &gorc->contract_amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &gorc->contract_amount),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("fulfillment_url",
&gorc->fulfillment_url),
@@ -1234,6 +1233,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
{
/* suspend connection, wait for exchange to check wire transfer status there */
gorc->transfer_status_requested = false; /* only try ONCE */
+ /* FIXME: #7951 */
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TMH_currency,
&gorc->deposits_total));
@@ -1316,6 +1316,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
GNUNET_assert (paid);
/* Accumulate refunds, if any. */
{
+ /* FIXME: #7951 */
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TMH_currency,
&gorc->refund_amount));
@@ -1339,6 +1340,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh,
MHD_RESULT ret;
char *order_status_url;
+ /* FIXME: #7951 */
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TMH_currency,
&gorc->deposits_total));
diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c
index 4998c029..3b8f8c34 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders.c
@@ -361,9 +361,8 @@ add_order (void *cls,
{
struct GNUNET_TIME_Timestamp rd;
struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_amount ("amount",
- TMH_currency,
- &order_amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &order_amount),
GNUNET_JSON_spec_timestamp ("refund_deadline",
&rd),
GNUNET_JSON_spec_string ("summary",
@@ -388,8 +387,9 @@ add_order (void *cls,
{
struct TALER_Amount refund_amount;
+ /* FIXME: #7951 */
GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TMH_currency,
+ TALER_amount_set_zero (order_amount.currency,
&refund_amount));
qs = TMH_db->lookup_refunds_detailed (TMH_db->cls,
po->instance_id,
diff --git a/src/backend/taler-merchant-httpd_private-get-rewards-ID.c b/src/backend/taler-merchant-httpd_private-get-rewards-ID.c
index 78b6c2d0..a20be319 100644
--- a/src/backend/taler-merchant-httpd_private-get-rewards-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-rewards-ID.c
@@ -93,6 +93,10 @@ struct RewardContext
*/
bool fpu;
+ /**
+ * True if @e min_amount was provided.
+ */
+ bool have_min_amount;
};
@@ -230,9 +234,6 @@ TMH_private_get_rewards_ID (const struct TMH_RequestHandler *rh,
? 0 == strcasecmp (pstr, "yes")
: false;
}
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TMH_currency,
- &tc->min_amount));
{
const char *min_amount;
@@ -251,16 +252,7 @@ TMH_private_get_rewards_ID (const struct TMH_RequestHandler *rh,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"min_amount");
}
- if (0 !=
- strcasecmp (tc->min_amount.currency,
- TMH_currency))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_CURRENCY_MISMATCH,
- TMH_currency);
- }
+ tc->have_min_amount = true;
}
}
TALER_MHD_parse_request_timeout (connection,
@@ -336,6 +328,10 @@ TMH_private_get_rewards_ID (const struct TMH_RequestHandler *rh,
expiration.abs_time);
if ( (NULL != tc->eh) &&
(GNUNET_TIME_absolute_is_future (tc->timeout)) &&
+ (tc->have_min_amount) &&
+ (GNUNET_YES ==
+ TALER_amount_cmp_currency (&tc->min_amount,
+ &total_picked_up)) &&
(1 == TALER_amount_cmp (&tc->min_amount,
&total_picked_up)) )
{
diff --git a/src/backend/taler-merchant-httpd_private-patch-products-ID.c b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
index c4ba755b..7bc327cd 100644
--- a/src/backend/taler-merchant-httpd_private-patch-products-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
@@ -125,9 +125,8 @@ TMH_private_patch_products_ID (const struct TMH_RequestHandler *rh,
NULL),
GNUNET_JSON_spec_string ("unit",
(const char **) &pd.unit),
- TALER_JSON_spec_amount ("price",
- TMH_currency,
- &pd.price),
+ TALER_JSON_spec_amount_any ("price",
+ &pd.price),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("image",
(const char **) &pd.image),
diff --git a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
index fa98fc1a..1b2aa460 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
@@ -121,9 +121,8 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
struct TALER_Amount refund;
const char *reason;
struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_amount ("refund",
- TMH_currency,
- &refund),
+ TALER_JSON_spec_amount_any ("refund",
+ &refund),
GNUNET_JSON_spec_string ("reason",
&reason),
GNUNET_JSON_spec_end ()
@@ -309,17 +308,15 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
TALER_EC_GENERIC_DB_COMMIT_FAILED,
NULL);
case TALER_MERCHANTDB_RS_NO_SUCH_ORDER:
- {
- /* We know the order exists from the
- "lookup_contract_terms" at the beginning;
- so if we get 'no such order' here, it
- must be read as "no PAID order" */
- return TALER_MHD_reply_with_error (
- connection,
- MHD_HTTP_CONFLICT,
- TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_ORDER_UNPAID,
- hc->infix);
- }
+ /* We know the order exists from the
+ "lookup_contract_terms" at the beginning;
+ so if we get 'no such order' here, it
+ must be read as "no PAID order" */
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_ORDER_UNPAID,
+ hc->infix);
case TALER_MERCHANTDB_RS_SUCCESS:
{
enum GNUNET_DB_QueryStatus qs;
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
index 17ddab67..61051b9a 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -883,8 +883,6 @@ update_stefan (struct OrderContext *oc,
{
struct TALER_Amount net;
- if (0 == keys->num_denom_keys)
- sleep (600);
if (GNUNET_SYSERR !=
TALER_EXCHANGE_keys_stefan_b2n (keys,
&oc->brutto,
@@ -1078,7 +1076,7 @@ set_max_fee (struct OrderContext *oc)
stefan = oc->max_stefan_fee;
else
GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TMH_currency,
+ TALER_amount_set_zero (oc->brutto.currency,
&stefan));
GNUNET_assert (0 ==
json_object_set_new (
@@ -1086,7 +1084,6 @@ set_max_fee (struct OrderContext *oc)
"max_fee",
TALER_JSON_from_amount (&stefan)));
}
-
oc->phase++;
}
@@ -1198,9 +1195,8 @@ patch_order (struct OrderContext *oc)
GNUNET_JSON_spec_string ("order_id",
&order_id),
NULL),
- TALER_JSON_spec_amount ("amount",
- TMH_currency,
- &oc->brutto),
+ TALER_JSON_spec_amount_any ("amount",
+ &oc->brutto),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("fulfillment_url",
&fulfillment_url),
@@ -1222,9 +1218,8 @@ patch_order (struct OrderContext *oc)
&wire_deadline),
NULL),
GNUNET_JSON_spec_mark_optional (
- TALER_JSON_spec_amount ("max_fee",
- TMH_currency,
- &oc->max_fee),
+ TALER_JSON_spec_amount_any ("max_fee",
+ &oc->max_fee),
NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_timestamp ("delivery_date",
diff --git a/src/backend/taler-merchant-httpd_private-post-products.c b/src/backend/taler-merchant-httpd_private-post-products.c
index 0c20cdac..3cad91a9 100644
--- a/src/backend/taler-merchant-httpd_private-post-products.c
+++ b/src/backend/taler-merchant-httpd_private-post-products.c
@@ -93,9 +93,8 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh,
NULL),
GNUNET_JSON_spec_string ("unit",
(const char **) &pd.unit),
- TALER_JSON_spec_amount ("price",
- TMH_currency,
- &pd.price),
+ TALER_JSON_spec_amount_any ("price",
+ &pd.price),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("image",
(const char **) &pd.image),
diff --git a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-reward.c b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-reward.c
index a859ece8..0d102a2b 100644
--- a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-reward.c
+++ b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-reward.c
@@ -51,9 +51,8 @@ authorize_reward (const struct TMH_RequestHandler *rh,
struct TALER_Amount amount;
{
struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_amount ("amount",
- TMH_currency,
- &amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &amount),
GNUNET_JSON_spec_string ("justification",
&justification),
GNUNET_JSON_spec_string ("next_url",
diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c b/src/backend/taler-merchant-httpd_private-post-reserves.c
index db40b017..027e2996 100644
--- a/src/backend/taler-merchant-httpd_private-post-reserves.c
+++ b/src/backend/taler-merchant-httpd_private-post-reserves.c
@@ -309,9 +309,8 @@ TMH_private_post_reserves (const struct TMH_RequestHandler *rh,
&rc->exchange_url),
GNUNET_JSON_spec_string ("wire_method",
&rc->wire_method),
- TALER_JSON_spec_amount ("initial_balance",
- TMH_currency,
- &rc->initial_balance),
+ TALER_JSON_spec_amount_any ("initial_balance",
+ &rc->initial_balance),
GNUNET_JSON_spec_end ()
};
enum GNUNET_GenericReturnValue res;
diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c
index 2d99f35e..11f76e29 100644
--- a/src/backend/taler-merchant-httpd_private-post-transfers.c
+++ b/src/backend/taler-merchant-httpd_private-post-transfers.c
@@ -45,9 +45,8 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh,
struct TALER_WireTransferIdentifierRawP wtid;
struct TALER_Amount amount;
struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_amount ("credit_amount",
- TMH_currency,
- &amount),
+ TALER_JSON_spec_amount_any ("credit_amount",
+ &amount),
GNUNET_JSON_spec_fixed_auto ("wtid",
&wtid),
GNUNET_JSON_spec_string ("payto_uri",
diff --git a/src/backenddb/pg_authorize_reward.c b/src/backenddb/pg_authorize_reward.c
index 6ebf4796..336112cb 100644
--- a/src/backenddb/pg_authorize_reward.c
+++ b/src/backenddb/pg_authorize_reward.c
@@ -120,6 +120,19 @@ lookup_reserve_for_reward_cb (void *cls,
lac->ec = TALER_EC_GENERIC_DB_FETCH_FAILED;
return;
}
+ if ( (GNUNET_YES !=
+ TALER_amount_cmp_currency (&initial_balance,
+ &committed_amount)) ||
+ (GNUNET_YES !=
+ TALER_amount_cmp_currency (&initial_balance,
+ &lac->required_amount)) )
+ {
+ /* insufficient balance */
+ if (lac->ok)
+ continue; /* got another reserve */
+ lac->ec = TALER_EC_GENERIC_CURRENCY_MISMATCH;
+ continue;
+ }
if (0 >
TALER_amount_subtract (&remaining,
&initial_balance,
@@ -342,6 +355,14 @@ RETRY:
TMH_PG_rollback (pg);
return TALER_EC_GENERIC_DB_INVARIANT_FAILURE;
}
+ if (GNUNET_YES !=
+ TALER_amount_cmp_currency (&remaining,
+ amount))
+ {
+ TMH_PG_rollback (pg);
+ return TALER_EC_GENERIC_CURRENCY_MISMATCH;
+ }
+
if (0 >
TALER_amount_cmp (&remaining,
amount))
diff --git a/src/backenddb/pg_increase_refund.c b/src/backenddb/pg_increase_refund.c
index d274b1e9..f1813e9b 100644
--- a/src/backenddb/pg_increase_refund.c
+++ b/src/backenddb/pg_increase_refund.c
@@ -91,6 +91,7 @@ process_refund_cb (void *cls,
ictx->err = true;
return;
}
+ /* FIXME: #7951 */
if (0 >
TALER_amount_add (&ictx->refunded_amount,
&ictx->refunded_amount,