From fb23045fe1d062cd4f26f3265ac94ded47660abd Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 24 Jul 2021 09:12:52 +0200 Subject: implement #6939 transformation --- src/backend/taler-merchant-httpd_helper.c | 4 +- .../taler-merchant-httpd_post-orders-ID-abort.c | 1 + .../taler-merchant-httpd_post-orders-ID-pay.c | 18 ++----- .../taler-merchant-httpd_private-get-orders-ID.c | 14 +----- .../taler-merchant-httpd_private-get-orders.c | 29 +++++------ ...ler-merchant-httpd_private-patch-instances-ID.c | 15 +----- ...aler-merchant-httpd_private-patch-products-ID.c | 12 +---- .../taler-merchant-httpd_private-post-instances.c | 16 +------ ...-merchant-httpd_private-post-orders-ID-refund.c | 7 ++- .../taler-merchant-httpd_private-post-orders.c | 56 ++++------------------ .../taler-merchant-httpd_private-post-products.c | 12 +---- ...-httpd_private-post-reserves-ID-authorize-tip.c | 22 +++------ .../taler-merchant-httpd_private-post-reserves.c | 12 +---- .../taler-merchant-httpd_private-post-transfers.c | 12 +---- src/lib/merchant_api_get_instance.c | 4 +- src/lib/merchant_api_get_orders.c | 2 +- src/lib/merchant_api_get_product.c | 2 +- src/lib/merchant_api_get_reserve.c | 10 ++-- src/lib/merchant_api_get_reserves.c | 8 ++-- src/lib/merchant_api_get_tips.c | 2 +- src/lib/merchant_api_get_transfers.c | 2 +- src/lib/merchant_api_merchant_get_order.c | 10 ++-- src/lib/merchant_api_merchant_get_tip.c | 6 +-- src/lib/merchant_api_post_transfers.c | 8 ++-- src/lib/merchant_api_wallet_get_order.c | 2 +- src/lib/merchant_api_wallet_get_tip.c | 2 +- src/lib/merchant_api_wallet_post_order_refund.c | 6 +-- src/testing/testing_api_cmd_abort_order.c | 4 +- src/testing/testing_api_cmd_get_orders.c | 4 +- src/testing/testing_api_cmd_pay_order.c | 8 ++-- 30 files changed, 92 insertions(+), 218 deletions(-) (limited to 'src') diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c index b869770f..0120b7b3 100644 --- a/src/backend/taler-merchant-httpd_helper.c +++ b/src/backend/taler-merchant-httpd_helper.c @@ -129,8 +129,8 @@ TMH_taxes_array_valid (const json_t *taxes) struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("name", &name), - TALER_JSON_spec_amount ("tax", - &amount), + TALER_JSON_spec_amount_any ("tax", + &amount), GNUNET_JSON_spec_end () }; enum GNUNET_GenericReturnValue res; diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c index 50e6ccd5..759c3ba5 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c @@ -925,6 +925,7 @@ parse_abort (struct MHD_Connection *connection, const char *exchange_url; struct GNUNET_JSON_Specification ispec[] = { TALER_JSON_spec_amount ("contribution", + TMH_currency, &rd->amount_with_fee), GNUNET_JSON_spec_string ("exchange_url", &exchange_url), 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 74c7dd89..7e7642f0 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -1668,6 +1668,7 @@ parse_pay (struct MHD_Connection *connection, GNUNET_JSON_spec_fixed_auto ("h_denom", &dc->h_denom), TALER_JSON_spec_amount ("contribution", + TMH_currency, &dc->amount_with_fee), GNUNET_JSON_spec_string ("exchange_url", &exchange_url), @@ -1797,13 +1798,16 @@ parse_pay (struct MHD_Connection *connection, const char *fulfillment_url = NULL; struct GNUNET_JSON_Specification espec[] = { TALER_JSON_spec_amount ("amount", + TMH_currency, &pc->amount), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("fulfillment_url", &fulfillment_url)), TALER_JSON_spec_amount ("max_fee", + TMH_currency, &pc->max_fee), TALER_JSON_spec_amount ("max_wire_fee", + TMH_currency, &pc->max_wire_fee), GNUNET_JSON_spec_uint32 ("wire_fee_amortization", &pc->wire_fee_amortization), @@ -1832,20 +1836,6 @@ parse_pay (struct MHD_Connection *connection, GNUNET_break (0); return res; } - - if ((0 != strcasecmp (pc->amount.currency, - TMH_currency)) || - ((0 != strcasecmp (pc->max_fee.currency, - TMH_currency)) || - (0 != strcasecmp (pc->max_wire_fee.currency, - TMH_currency)))) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } } if (pc->wire_transfer_deadline.abs_value_us < 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 bf5e2f65..ed162826 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -911,6 +911,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, { struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("amount", + TMH_currency, &gorc->contract_amount), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("fulfillment_url", @@ -934,19 +935,6 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID, hc->infix); } - if (0 != - strcasecmp (TMH_currency, - gorc->contract_amount.currency)) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Currency `%s' of contract does not match our configuration!\n", - gorc->contract_amount.currency); - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID, - gorc->contract_amount.currency); - } } if (! order_only) { diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c index 509a5b60..3504105c 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders.c +++ b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -118,7 +118,7 @@ TMH_force_get_orders_resume (struct TMH_MerchantInstance *mi) while (NULL != (po = mi->po_head)) { - GNUNET_assert(po->in_dll); + GNUNET_assert (po->in_dll); GNUNET_CONTAINER_DLL_remove (mi->po_head, mi->po_tail, po); @@ -173,7 +173,7 @@ order_timeout (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Resuming long polled job due to timeout\n"); mi = po->mi; - GNUNET_assert(po->in_dll); + GNUNET_assert (po->in_dll); GNUNET_CONTAINER_DLL_remove (mi->po_head, mi->po_tail, po); @@ -199,7 +199,7 @@ cleanup (void *ctx) struct TMH_PendingOrder *po = ctx; if (po->in_dll) - { + { struct TMH_MerchantInstance *mi = po->mi; GNUNET_CONTAINER_DLL_remove (mi->po_head, @@ -321,6 +321,7 @@ add_order (void *cls, struct GNUNET_TIME_Absolute rd; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("amount", + TMH_currency, &order_amount), GNUNET_JSON_spec_absolute_time ("refund_deadline", &rd), @@ -338,7 +339,7 @@ add_order (void *cls, return; } - if (GNUNET_TIME_absolute_is_future(rd) && + if (GNUNET_TIME_absolute_is_future (rd) && paid) { struct TALER_Amount refund_amount; @@ -444,7 +445,7 @@ TMH_notify_order_change (struct TMH_MerchantInstance *mi, order_id, order_serial_id, date); - GNUNET_assert(po->in_dll); + GNUNET_assert (po->in_dll); GNUNET_CONTAINER_DLL_remove (mi->po_head, mi->po_tail, po); @@ -537,7 +538,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, &ll, &dummy)) { - GNUNET_break_op (0); + GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, @@ -547,7 +548,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, if ( (-MAX_DELTA > of.delta) || (of.delta > MAX_DELTA) ) { - GNUNET_break_op (0); + GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, @@ -586,8 +587,8 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, "date_ms"); } - of.date = GNUNET_TIME_absolute_from_ms(ll); - if (GNUNET_TIME_absolute_is_never(of.date)) + of.date = GNUNET_TIME_absolute_from_ms (ll); + if (GNUNET_TIME_absolute_is_never (of.date)) { GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, @@ -627,7 +628,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, of.start_row = (uint64_t) ull; if (INT64_MAX < of.start_row) { - GNUNET_break_op (0); + GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, @@ -661,7 +662,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, "timeout_ms"); of.timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, ull); - if (GNUNET_TIME_relative_is_forever(of.timeout)) + if (GNUNET_TIME_relative_is_forever (of.timeout)) { GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, @@ -672,7 +673,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, } if ( (0 >= of.delta) && - (! GNUNET_TIME_relative_is_zero(of.timeout)) ) + (! GNUNET_TIME_relative_is_zero (of.timeout)) ) { GNUNET_break_op (0); of.timeout = GNUNET_TIME_UNIT_ZERO; @@ -706,7 +707,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, NULL); } if ( (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) && - (! GNUNET_TIME_relative_is_zero(of.timeout)) ) + (! GNUNET_TIME_relative_is_zero (of.timeout)) ) { struct TMH_MerchantInstance *mi = hc->instance; @@ -722,7 +723,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, GNUNET_CONTAINER_DLL_insert (mi->po_head, mi->po_tail, po); - po->in_dll=true; + po->in_dll = true; MHD_suspend_connection (connection); { struct TMH_PendingOrder *pot; diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c index bafccb59..65f1760f 100644 --- a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c @@ -76,10 +76,12 @@ patch_instances_ID (struct TMH_MerchantInstance *mi, GNUNET_JSON_spec_json ("jurisdiction", &is.jurisdiction), TALER_JSON_spec_amount ("default_max_wire_fee", + TMH_currency, &is.default_max_wire_fee), GNUNET_JSON_spec_uint32 ("default_wire_fee_amortization", &is.default_wire_fee_amortization), TALER_JSON_spec_amount ("default_max_deposit_fee", + TMH_currency, &is.default_max_deposit_fee), TALER_JSON_spec_relative_time ("default_wire_transfer_delay", &is.default_wire_transfer_delay), @@ -102,19 +104,6 @@ patch_instances_ID (struct TMH_MerchantInstance *mi, ? MHD_YES : MHD_NO; } - if ((0 != strcasecmp (is.default_max_deposit_fee.currency, - TMH_currency)) || - (0 != strcasecmp (is.default_max_wire_fee.currency, - TMH_currency))) - { - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - NULL); - } - if (! TMH_location_object_valid (is.address)) { GNUNET_break_op (0); 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 46436d06..7b568094 100644 --- a/src/backend/taler-merchant-httpd_private-patch-products-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-products-ID.c @@ -125,6 +125,7 @@ TMH_private_patch_products_ID (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_string ("unit", (const char **) &pd.unit), TALER_JSON_spec_amount ("price", + TMH_currency, &pd.price), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("image", @@ -160,17 +161,6 @@ TMH_private_patch_products_ID (const struct TMH_RequestHandler *rh, ? MHD_YES : MHD_NO; } - if (0 != - strcasecmp (pd.price.currency, - TMH_currency)) - { - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } if (total_stock < -1) { GNUNET_break_op (0); diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c index c6471571..2d3f660c 100644 --- a/src/backend/taler-merchant-httpd_private-post-instances.c +++ b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -164,10 +164,12 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_json ("jurisdiction", &is.jurisdiction), TALER_JSON_spec_amount ("default_max_wire_fee", + TMH_currency, &is.default_max_wire_fee), GNUNET_JSON_spec_uint32 ("default_wire_fee_amortization", &is.default_wire_fee_amortization), TALER_JSON_spec_amount ("default_max_deposit_fee", + TMH_currency, &is.default_max_deposit_fee), TALER_JSON_spec_relative_time ("default_wire_transfer_delay", &is.default_wire_transfer_delay), @@ -250,20 +252,6 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, "jurisdiction"); } - /* Check currency of client matches our own currency */ - if ( (0 != strcasecmp (is.default_max_deposit_fee.currency, - TMH_currency)) || - (0 != strcasecmp (is.default_max_wire_fee.currency, - TMH_currency)) ) - { - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } - { /* Test if an instance of this id is known */ struct TMH_MerchantInstance *mi; 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 4300c607..c0e4afb5 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 @@ -108,8 +108,11 @@ 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", &refund), - GNUNET_JSON_spec_string ("reason", &reason), + TALER_JSON_spec_amount ("refund", + TMH_currency, + &refund), + GNUNET_JSON_spec_string ("reason", + &reason), GNUNET_JSON_spec_end () }; enum TALER_MERCHANTDB_RefundStatus rs; diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index 63eff40e..8a0ca347 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -335,6 +335,7 @@ execute_order (struct MHD_Connection *connection, struct GNUNET_TIME_Absolute pay_deadline; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("amount", + TMH_currency, &total), GNUNET_JSON_spec_string ("order_id", &order_id), @@ -375,18 +376,6 @@ execute_order (struct MHD_Connection *connection, : MHD_NO; } } - if (0 != - strcasecmp (total.currency, - TMH_currency)) - { - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } /* check product list in contract is well-formed */ if (GNUNET_OK != check_products (products)) @@ -671,9 +660,11 @@ patch_order (struct MHD_Connection *connection, &wire_deadline)), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_amount ("max_fee", + TMH_currency, &max_fee)), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_amount ("max_wire_fee", + TMH_currency, &max_wire_fee)), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_uint32 ("wire_fee_amortization", @@ -888,24 +879,10 @@ patch_order (struct MHD_Connection *connection, TALER_amount_is_valid (&max_wire_fee)) { GNUNET_assert (0 == - json_object_set_new (order, - "max_wire_fee", - TALER_JSON_from_amount - (&settings->default_max_wire_fee))); - } - else - { - if (0 != - strcasecmp (max_wire_fee.currency, - TMH_currency)) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } + json_object_set_new ( + order, + "max_wire_fee", + TALER_JSON_from_amount (&settings->default_max_wire_fee))); } if (GNUNET_OK != @@ -918,29 +895,14 @@ patch_order (struct MHD_Connection *connection, TALER_JSON_from_amount (&settings->default_max_deposit_fee))); } - else - { - if (0 != - strcasecmp (max_fee.currency, - TMH_currency)) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } - } - if (0 == wire_fee_amortization) { GNUNET_assert (0 == json_object_set_new ( order, "wire_fee_amortization", - json_integer - ((json_int_t) settings->default_wire_fee_amortization))); + json_integer ( + (json_int_t) settings->default_wire_fee_amortization))); } if (NULL == merchant_base_url) { diff --git a/src/backend/taler-merchant-httpd_private-post-products.c b/src/backend/taler-merchant-httpd_private-post-products.c index 4cf97fd0..4227c826 100644 --- a/src/backend/taler-merchant-httpd_private-post-products.c +++ b/src/backend/taler-merchant-httpd_private-post-products.c @@ -91,6 +91,7 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_string ("unit", (const char **) &pd.unit), TALER_JSON_spec_amount ("price", + TMH_currency, &pd.price), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("image", @@ -124,17 +125,6 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh, : MHD_NO; } } - if (0 != - strcasecmp (pd.price.currency, - TMH_currency)) - { - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } if (total_stock < -1) { GNUNET_break_op (0); diff --git a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c index 73afdfba..f49b9b1d 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c @@ -51,9 +51,13 @@ authorize_tip (const struct TMH_RequestHandler *rh, struct TALER_Amount amount; { struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_amount ("amount", &amount), - GNUNET_JSON_spec_string ("justification", &justification), - GNUNET_JSON_spec_string ("next_url", &next_url), + TALER_JSON_spec_amount ("amount", + TMH_currency, + &amount), + GNUNET_JSON_spec_string ("justification", + &justification), + GNUNET_JSON_spec_string ("next_url", + &next_url), GNUNET_JSON_spec_end () }; enum GNUNET_GenericReturnValue res; @@ -69,18 +73,6 @@ authorize_tip (const struct TMH_RequestHandler *rh, : MHD_NO; } } - - if (0 != - strcasecmp (amount.currency, - TMH_currency)) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } - TMH_db->preflight (TMH_db->cls); ec = TMH_db->authorize_tip (TMH_db->cls, hc->instance->settings.id, diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c b/src/backend/taler-merchant-httpd_private-post-reserves.c index f4f10973..a720f6c6 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves.c @@ -313,6 +313,7 @@ TMH_private_post_reserves (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_string ("wire_method", &wire_method), TALER_JSON_spec_amount ("initial_balance", + TMH_currency, &rc->initial_balance), GNUNET_JSON_spec_end () }; @@ -324,17 +325,6 @@ TMH_private_post_reserves (const struct TMH_RequestHandler *rh, ? MHD_YES : MHD_NO; } - if (0 != - strcasecmp (rc->initial_balance.currency, - TMH_currency)) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } rc->fo = TMH_EXCHANGES_find_exchange (rc->exchange_url, wire_method, GNUNET_NO, diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c index 0e3f798e..a9a0da75 100644 --- a/src/backend/taler-merchant-httpd_private-post-transfers.c +++ b/src/backend/taler-merchant-httpd_private-post-transfers.c @@ -959,6 +959,7 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, /* First request, parse it! */ struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("credit_amount", + TMH_currency, &ptc->amount), GNUNET_JSON_spec_fixed_auto ("wtid", &ptc->wtid), @@ -977,17 +978,6 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, return (GNUNET_NO == res) ? MHD_YES : MHD_NO; - if (0 != - strcasecmp (ptc->amount.currency, - TMH_currency)) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error ( - connection, - MHD_HTTP_CONFLICT, - TALER_EC_GENERIC_CURRENCY_MISMATCH, - TMH_currency); - } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New inbound wire transfer over %s to %s from %s\n", TALER_amount2s (&ptc->amount), diff --git a/src/lib/merchant_api_get_instance.c b/src/lib/merchant_api_get_instance.c index 696bb964..64ee331e 100644 --- a/src/lib/merchant_api_get_instance.c +++ b/src/lib/merchant_api_get_instance.c @@ -112,11 +112,11 @@ handle_get_instance_finished (void *cls, &address), GNUNET_JSON_spec_json ("jurisdiction", &jurisdiction), - TALER_JSON_spec_amount ("default_max_wire_fee", + TALER_JSON_spec_amount_any ("default_max_wire_fee", &default_max_wire_fee), GNUNET_JSON_spec_uint32 ("default_wire_fee_amortization", &default_wire_fee_amortization), - TALER_JSON_spec_amount ("default_max_deposit_fee", + TALER_JSON_spec_amount_any ("default_max_deposit_fee", &default_max_deposit_fee), TALER_JSON_spec_relative_time ("default_wire_transfer_delay", &default_wire_transfer_delay), diff --git a/src/lib/merchant_api_get_orders.c b/src/lib/merchant_api_get_orders.c index ddf9cdd2..441b5ff8 100644 --- a/src/lib/merchant_api_get_orders.c +++ b/src/lib/merchant_api_get_orders.c @@ -90,7 +90,7 @@ parse_orders (const json_t *ia, &ie->timestamp), GNUNET_JSON_spec_uint64 ("row_id", &ie->order_serial), - TALER_JSON_spec_amount ("amount", + TALER_JSON_spec_amount_any ("amount", &ie->amount), GNUNET_JSON_spec_string ("summary", &ie->summary), diff --git a/src/lib/merchant_api_get_product.c b/src/lib/merchant_api_get_product.c index 9e0f9114..7fe053d7 100644 --- a/src/lib/merchant_api_get_product.c +++ b/src/lib/merchant_api_get_product.c @@ -110,7 +110,7 @@ handle_get_product_finished (void *cls, &description_i18n), GNUNET_JSON_spec_string ("unit", &unit), - TALER_JSON_spec_amount ("price", + TALER_JSON_spec_amount_any ("price", &price), GNUNET_JSON_spec_string ("image", &image), diff --git a/src/lib/merchant_api_get_reserve.c b/src/lib/merchant_api_get_reserve.c index 79a3fb32..591e0226 100644 --- a/src/lib/merchant_api_get_reserve.c +++ b/src/lib/merchant_api_get_reserve.c @@ -110,13 +110,13 @@ handle_reserve_get_finished (void *cls, GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("payto_uri", &payto_uri)), - TALER_JSON_spec_amount ("merchant_initial_amount", + TALER_JSON_spec_amount_any ("merchant_initial_amount", &rs.merchant_initial_amount), - TALER_JSON_spec_amount ("exchange_initial_amount", + TALER_JSON_spec_amount_any ("exchange_initial_amount", &rs.exchange_initial_amount), - TALER_JSON_spec_amount ("pickup_amount", + TALER_JSON_spec_amount_any ("pickup_amount", &rs.pickup_amount), - TALER_JSON_spec_amount ("committed_amount", + TALER_JSON_spec_amount_any ("committed_amount", &rs.committed_amount), GNUNET_JSON_spec_end () }; @@ -171,7 +171,7 @@ handle_reserve_get_finished (void *cls, struct GNUNET_JSON_Specification ispec[] = { GNUNET_JSON_spec_fixed_auto ("tip_id", &td->tip_id), - TALER_JSON_spec_amount ("total_amount", + TALER_JSON_spec_amount_any ("total_amount", &td->amount), GNUNET_JSON_spec_string ("reason", &td->reason), diff --git a/src/lib/merchant_api_get_reserves.c b/src/lib/merchant_api_get_reserves.c index 32455a57..fc518839 100644 --- a/src/lib/merchant_api_get_reserves.c +++ b/src/lib/merchant_api_get_reserves.c @@ -138,13 +138,13 @@ handle_reserves_get_finished (void *cls, &rd->creation_time), TALER_JSON_spec_absolute_time ("expiration_time", &rd->expiration_time), - TALER_JSON_spec_amount ("merchant_initial_amount", + TALER_JSON_spec_amount_any ("merchant_initial_amount", &rd->merchant_initial_amount), - TALER_JSON_spec_amount ("exchange_initial_amount", + TALER_JSON_spec_amount_any ("exchange_initial_amount", &rd->exchange_initial_amount), - TALER_JSON_spec_amount ("pickup_amount", + TALER_JSON_spec_amount_any ("pickup_amount", &rd->pickup_amount), - TALER_JSON_spec_amount ("committed_amount", + TALER_JSON_spec_amount_any ("committed_amount", &rd->committed_amount), GNUNET_JSON_spec_bool ("active", &rd->active), diff --git a/src/lib/merchant_api_get_tips.c b/src/lib/merchant_api_get_tips.c index fd3dfdae..516ca591 100644 --- a/src/lib/merchant_api_get_tips.c +++ b/src/lib/merchant_api_get_tips.c @@ -88,7 +88,7 @@ parse_tips (const json_t *ia, &ie->row_id), GNUNET_JSON_spec_fixed_auto ("tip_id", &ie->tip_id), - TALER_JSON_spec_amount ("tip_amount", + TALER_JSON_spec_amount_any ("tip_amount", &ie->tip_amount), GNUNET_JSON_spec_end () }; diff --git a/src/lib/merchant_api_get_transfers.c b/src/lib/merchant_api_get_transfers.c index e31fb38f..f89215fc 100644 --- a/src/lib/merchant_api_get_transfers.c +++ b/src/lib/merchant_api_get_transfers.c @@ -132,7 +132,7 @@ handle_transfers_get_finished (void *cls, json_array_foreach (transfers, i, transfer) { struct TALER_MERCHANT_TransferData *td = &tds[i]; struct GNUNET_JSON_Specification ispec[] = { - TALER_JSON_spec_amount ("credit_amount", + TALER_JSON_spec_amount_any ("credit_amount", &td->credit_amount), GNUNET_JSON_spec_fixed_auto ("wtid", &td->wtid), diff --git a/src/lib/merchant_api_merchant_get_order.c b/src/lib/merchant_api_merchant_get_order.c index 025460c2..f4dc8131 100644 --- a/src/lib/merchant_api_merchant_get_order.c +++ b/src/lib/merchant_api_merchant_get_order.c @@ -81,7 +81,7 @@ handle_unpaid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, .status = TALER_MERCHANT_OSC_UNPAID }; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_amount ("total_amount", + TALER_JSON_spec_amount_any ("total_amount", &osr.details.unpaid.contract_amount), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("already_paid_order_id", @@ -182,13 +182,13 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, &osr.details.paid.refund_pending), GNUNET_JSON_spec_bool ("wired", &osr.details.paid.wired), - TALER_JSON_spec_amount ("deposit_total", + TALER_JSON_spec_amount_any ("deposit_total", &osr.details.paid.deposit_total), GNUNET_JSON_spec_uint32 ("exchange_ec", &ec32), GNUNET_JSON_spec_uint32 ("exchange_hc", &hc32), - TALER_JSON_spec_amount ("refund_amount", + TALER_JSON_spec_amount_any ("refund_amount", &osr.details.paid.refund_amount), GNUNET_JSON_spec_json ("contract_terms", (json_t **) &osr.details.paid.contract_terms), @@ -250,7 +250,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, &wt->wtid), TALER_JSON_spec_absolute_time ("execution_time", &wt->execution_time), - TALER_JSON_spec_amount ("amount", + TALER_JSON_spec_amount_any ("amount", &wt->total_amount), GNUNET_JSON_spec_bool ("confirmed", &wt->confirmed), @@ -319,7 +319,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, const json_t *w = json_array_get (refund_details, i); struct GNUNET_JSON_Specification ispec[] = { - TALER_JSON_spec_amount ("amount", + TALER_JSON_spec_amount_any ("amount", &ro->refund_amount), GNUNET_JSON_spec_string ("reason", &ro->reason), diff --git a/src/lib/merchant_api_merchant_get_tip.c b/src/lib/merchant_api_merchant_get_tip.c index aad72584..2ee5a56c 100644 --- a/src/lib/merchant_api_merchant_get_tip.c +++ b/src/lib/merchant_api_merchant_get_tip.c @@ -82,7 +82,7 @@ parse_pickups (const json_t *pa, &pickup->pickup_id), GNUNET_JSON_spec_uint64 ("num_planchets", &pickup->num_planchets), - TALER_JSON_spec_amount ("requested_amount", + TALER_JSON_spec_amount_any ("requested_amount", &pickup->requested_amount), GNUNET_JSON_spec_end () }; @@ -152,9 +152,9 @@ handle_merchant_tip_get_finished (void *cls, struct GNUNET_TIME_Absolute expiration; struct TALER_ReservePublicKeyP reserve_pub; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_amount ("total_authorized", + TALER_JSON_spec_amount_any ("total_authorized", &total_authorized), - TALER_JSON_spec_amount ("total_picked_up", + TALER_JSON_spec_amount_any ("total_picked_up", &total_picked_up), GNUNET_JSON_spec_string ("reason", &reason), diff --git a/src/lib/merchant_api_post_transfers.c b/src/lib/merchant_api_post_transfers.c index a9eaf288..3e1a55d5 100644 --- a/src/lib/merchant_api_post_transfers.c +++ b/src/lib/merchant_api_post_transfers.c @@ -103,9 +103,9 @@ handle_post_transfers_finished (void *cls, struct GNUNET_TIME_Absolute execution_time; json_t *deposit_sums; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_amount ("total", + TALER_JSON_spec_amount_any ("total", &total), - TALER_JSON_spec_amount ("wire_fee", + TALER_JSON_spec_amount_any ("wire_fee", &wire_fee), TALER_JSON_spec_absolute_time ("execution_time", &execution_time), @@ -148,9 +148,9 @@ handle_post_transfers_finished (void *cls, struct GNUNET_JSON_Specification ispec[] = { GNUNET_JSON_spec_string ("order_id", &d->order_id), - TALER_JSON_spec_amount ("deposit_value", + TALER_JSON_spec_amount_any ("deposit_value", &d->deposit_value), - TALER_JSON_spec_amount ("deposit_fee", + TALER_JSON_spec_amount_any ("deposit_fee", &d->deposit_fee), GNUNET_JSON_spec_end () }; diff --git a/src/lib/merchant_api_wallet_get_order.c b/src/lib/merchant_api_wallet_get_order.c index 0452d70d..08a91ef7 100644 --- a/src/lib/merchant_api_wallet_get_order.c +++ b/src/lib/merchant_api_wallet_get_order.c @@ -122,7 +122,7 @@ handle_wallet_get_order_finished (void *cls, &refunded), GNUNET_JSON_spec_bool ("refund_pending", &refund_pending), - TALER_JSON_spec_amount ("refund_amount", + TALER_JSON_spec_amount_any ("refund_amount", &refund_amount), GNUNET_JSON_spec_end () }; diff --git a/src/lib/merchant_api_wallet_get_tip.c b/src/lib/merchant_api_wallet_get_tip.c index c6a6039d..d1343f9d 100644 --- a/src/lib/merchant_api_wallet_get_tip.c +++ b/src/lib/merchant_api_wallet_get_tip.c @@ -100,7 +100,7 @@ handle_wallet_tip_get_finished (void *cls, &expiration), GNUNET_JSON_spec_string ("exchange_url", &exchange_url), - TALER_JSON_spec_amount ("tip_amount", + TALER_JSON_spec_amount_any ("tip_amount", &amount_remaining), GNUNET_JSON_spec_end () }; diff --git a/src/lib/merchant_api_wallet_post_order_refund.c b/src/lib/merchant_api_wallet_post_order_refund.c index c527696b..ff19b09e 100644 --- a/src/lib/merchant_api_wallet_post_order_refund.c +++ b/src/lib/merchant_api_wallet_post_order_refund.c @@ -134,7 +134,7 @@ handle_refund_finished (void *cls, struct TALER_MerchantPublicKeyP merchant_pub; unsigned int refund_len; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_amount ("refund_amount", + TALER_JSON_spec_amount_any ("refund_amount", &refund_amount), GNUNET_JSON_spec_json ("refunds", &refunds), @@ -214,7 +214,7 @@ handle_refund_finished (void *cls, &rd->rtransaction_id), GNUNET_JSON_spec_fixed_auto ("coin_pub", &rd->coin_pub), - TALER_JSON_spec_amount ("refund_amount", + TALER_JSON_spec_amount_any ("refund_amount", &rd->refund_amount), GNUNET_JSON_spec_end () }; @@ -241,7 +241,7 @@ handle_refund_finished (void *cls, &rd->coin_pub), GNUNET_JSON_spec_uint64 ("rtransaction_id", &rd->rtransaction_id), - TALER_JSON_spec_amount ("refund_amount", + TALER_JSON_spec_amount_any ("refund_amount", &rd->refund_amount), GNUNET_JSON_spec_end () }; diff --git a/src/testing/testing_api_cmd_abort_order.c b/src/testing/testing_api_cmd_abort_order.c index 4942fab4..d515a361 100644 --- a/src/testing/testing_api_cmd_abort_order.c +++ b/src/testing/testing_api_cmd_abort_order.c @@ -286,8 +286,8 @@ abort_run (void *cls, &order_id), GNUNET_JSON_spec_fixed_auto ("merchant_pub", &merchant_pub), - TALER_JSON_spec_amount ("amount", - &total_amount), + TALER_JSON_spec_amount_any ("amount", + &total_amount), GNUNET_JSON_spec_end () }; diff --git a/src/testing/testing_api_cmd_get_orders.c b/src/testing/testing_api_cmd_get_orders.c index 51292c3c..dbf647c1 100644 --- a/src/testing/testing_api_cmd_get_orders.c +++ b/src/testing/testing_api_cmd_get_orders.c @@ -140,8 +140,8 @@ get_orders_cb (void *cls, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("summary", &summary), - TALER_JSON_spec_amount ("amount", - &amount), + TALER_JSON_spec_amount_any ("amount", + &amount), GNUNET_JSON_spec_end () }; diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c index a3f1ff49..05776afa 100644 --- a/src/testing/testing_api_cmd_pay_order.c +++ b/src/testing/testing_api_cmd_pay_order.c @@ -299,10 +299,10 @@ pay_run (void *cls, &merchant_pub), GNUNET_JSON_spec_fixed_auto ("h_wire", &h_wire), - TALER_JSON_spec_amount ("amount", - &total_amount), - TALER_JSON_spec_amount ("max_fee", - &max_fee), + TALER_JSON_spec_amount_any ("amount", + &total_amount), + TALER_JSON_spec_amount_any ("max_fee", + &max_fee), GNUNET_JSON_spec_end () }; -- cgit v1.2.3