diff options
Diffstat (limited to 'src/backend')
14 files changed, 52 insertions, 178 deletions
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), |