diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-05-01 19:22:32 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-05-01 19:22:32 +0200 |
commit | e9c62a69dc1bf591716c143d5594ef9c24307fbb (patch) | |
tree | 35b13bd4e1d861c62c99f9b32dc812420eb00c1a | |
parent | e72d9f8bb9eef79cbff4b4a6189b769a6fa81f3b (diff) | |
download | exchange-e9c62a69dc1bf591716c143d5594ef9c24307fbb.tar.gz exchange-e9c62a69dc1bf591716c143d5594ef9c24307fbb.zip |
fix status code
-rw-r--r-- | src/auditor/taler-helper-auditor-coins.c | 1 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-reserves.c | 1 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_deposit.c | 30 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_refund.c | 99 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 2 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_withdraw.c | 4 | ||||
-rw-r--r-- | src/include/taler_error_codes.h | 2 | ||||
-rw-r--r-- | src/include/taler_exchange_service.h | 4 | ||||
-rw-r--r-- | src/include/taler_signatures.h | 24 | ||||
-rw-r--r-- | src/include/taler_testing_lib.h | 4 | ||||
-rw-r--r-- | src/lib/exchange_api_common.c | 34 | ||||
-rw-r--r-- | src/lib/exchange_api_deposit.c | 4 | ||||
-rw-r--r-- | src/lib/exchange_api_handle.c | 2 | ||||
-rw-r--r-- | src/lib/exchange_api_refund.c | 21 | ||||
-rw-r--r-- | src/lib/exchange_api_withdraw2.c | 2 | ||||
-rw-r--r-- | src/testing/test_auditor_api.c | 1 | ||||
-rw-r--r-- | src/testing/test_exchange_api.c | 5 | ||||
-rw-r--r-- | src/testing/test_exchange_api_twisted.c | 10 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_refund.c | 26 |
19 files changed, 68 insertions, 208 deletions
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index 9d5e66706..2e32c5698 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c | |||
@@ -1802,7 +1802,6 @@ refund_cb (void *cls, | |||
1802 | .coin_pub = *coin_pub, | 1802 | .coin_pub = *coin_pub, |
1803 | .merchant = *merchant_pub, | 1803 | .merchant = *merchant_pub, |
1804 | .rtransaction_id = GNUNET_htonll (rtransaction_id), | 1804 | .rtransaction_id = GNUNET_htonll (rtransaction_id), |
1805 | .refund_fee = issue->fee_refund | ||
1806 | }; | 1805 | }; |
1807 | 1806 | ||
1808 | TALER_amount_hton (&rr.refund_amount, | 1807 | TALER_amount_hton (&rr.refund_amount, |
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index 8879d4950..3460515a2 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c | |||
@@ -550,7 +550,6 @@ handle_reserve_out (void *cls, | |||
550 | } | 550 | } |
551 | 551 | ||
552 | /* check reserve_sig (first: setup remaining members of wsrd) */ | 552 | /* check reserve_sig (first: setup remaining members of wsrd) */ |
553 | wsrd.withdraw_fee = issue->fee_withdraw; | ||
554 | TALER_amount_hton (&wsrd.amount_with_fee, | 553 | TALER_amount_hton (&wsrd.amount_with_fee, |
555 | amount_with_fee); | 554 | amount_with_fee); |
556 | if (GNUNET_OK != | 555 | if (GNUNET_OK != |
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 3f895857b..65251863a 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c | |||
@@ -90,10 +90,11 @@ reply_deposit_success (struct MHD_Connection *connection, | |||
90 | } | 90 | } |
91 | return TALER_MHD_reply_json_pack (connection, | 91 | return TALER_MHD_reply_json_pack (connection, |
92 | MHD_HTTP_OK, | 92 | MHD_HTTP_OK, |
93 | "{s:s, s:o, s:o}", | 93 | "{s:o, s:o}", |
94 | "status", "DEPOSIT_OK", | 94 | "exchange_sig", |
95 | "sig", GNUNET_JSON_from_data_auto (&sig), | 95 | GNUNET_JSON_from_data_auto (&sig), |
96 | "pub", GNUNET_JSON_from_data_auto (&pub)); | 96 | "exchange_pub", |
97 | GNUNET_JSON_from_data_auto (&pub)); | ||
97 | } | 98 | } |
98 | 99 | ||
99 | 100 | ||
@@ -312,15 +313,22 @@ TEH_handler_deposit (struct MHD_Connection *connection, | |||
312 | struct GNUNET_HashCode my_h_wire; | 313 | struct GNUNET_HashCode my_h_wire; |
313 | struct GNUNET_JSON_Specification spec[] = { | 314 | struct GNUNET_JSON_Specification spec[] = { |
314 | GNUNET_JSON_spec_json ("wire", &wire), | 315 | GNUNET_JSON_spec_json ("wire", &wire), |
315 | TALER_JSON_spec_amount ("contribution", &deposit.amount_with_fee), | 316 | TALER_JSON_spec_amount ("contribution", |
317 | &deposit.amount_with_fee), | ||
316 | GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", | 318 | GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", |
317 | &deposit.coin.denom_pub_hash), | 319 | &deposit.coin.denom_pub_hash), |
318 | TALER_JSON_spec_denomination_signature ("ub_sig", &deposit.coin.denom_sig), | 320 | TALER_JSON_spec_denomination_signature ("ub_sig", |
319 | GNUNET_JSON_spec_fixed_auto ("merchant_pub", &deposit.merchant_pub), | 321 | &deposit.coin.denom_sig), |
320 | GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &deposit.h_contract_terms), | 322 | GNUNET_JSON_spec_fixed_auto ("merchant_pub", |
321 | GNUNET_JSON_spec_fixed_auto ("h_wire", &deposit.h_wire), | 323 | &deposit.merchant_pub), |
322 | GNUNET_JSON_spec_fixed_auto ("coin_sig", &deposit.csig), | 324 | GNUNET_JSON_spec_fixed_auto ("h_contract_terms", |
323 | GNUNET_JSON_spec_absolute_time ("timestamp", &deposit.timestamp), | 325 | &deposit.h_contract_terms), |
326 | GNUNET_JSON_spec_fixed_auto ("h_wire", | ||
327 | &deposit.h_wire), | ||
328 | GNUNET_JSON_spec_fixed_auto ("coin_sig", | ||
329 | &deposit.csig), | ||
330 | GNUNET_JSON_spec_absolute_time ("timestamp", | ||
331 | &deposit.timestamp), | ||
324 | GNUNET_JSON_spec_absolute_time ("refund_deadline", | 332 | GNUNET_JSON_spec_absolute_time ("refund_deadline", |
325 | &deposit.refund_deadline), | 333 | &deposit.refund_deadline), |
326 | GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline", | 334 | GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline", |
diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index 7c2b149f2..a6a2c3d6f 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c | |||
@@ -73,12 +73,13 @@ reply_refund_success (struct MHD_Connection *connection, | |||
73 | TALER_EC_EXCHANGE_BAD_CONFIGURATION, | 73 | TALER_EC_EXCHANGE_BAD_CONFIGURATION, |
74 | "no online signing key"); | 74 | "no online signing key"); |
75 | } | 75 | } |
76 | return TALER_MHD_reply_json_pack (connection, | 76 | return TALER_MHD_reply_json_pack ( |
77 | MHD_HTTP_OK, | 77 | connection, |
78 | "{s:s, s:o, s:o}", | 78 | MHD_HTTP_OK, |
79 | "status", "REFUND_OK", | 79 | "{s:o, s:o, s:o}", |
80 | "sig", GNUNET_JSON_from_data_auto (&sig), | 80 | "refund_fee", TALER_JSON_from_amount (&refund->refund_fee), |
81 | "pub", GNUNET_JSON_from_data_auto (&pub)); | 81 | "exchange_sig", GNUNET_JSON_from_data_auto (&sig), |
82 | "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); | ||
82 | } | 83 | } |
83 | 84 | ||
84 | 85 | ||
@@ -246,18 +247,15 @@ refund_transaction (void *cls, | |||
246 | } | 247 | } |
247 | 248 | ||
248 | /* check currency is compatible */ | 249 | /* check currency is compatible */ |
249 | if ( (GNUNET_YES != | 250 | if (GNUNET_YES != |
250 | TALER_amount_cmp_currency (&refund->details.refund_amount, | 251 | TALER_amount_cmp_currency (&refund->details.refund_amount, |
251 | &dep->amount_with_fee)) || | 252 | &dep->amount_with_fee)) |
252 | (GNUNET_YES != | ||
253 | TALER_amount_cmp_currency (&refund->details.refund_fee, | ||
254 | &dep->deposit_fee)) ) | ||
255 | { | 253 | { |
256 | GNUNET_break_op (0); /* currency mismatch */ | 254 | GNUNET_break_op (0); /* currency mismatch */ |
257 | TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, | 255 | TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, |
258 | tl); | 256 | tl); |
259 | *mhd_ret = TALER_MHD_reply_with_error (connection, | 257 | *mhd_ret = TALER_MHD_reply_with_error (connection, |
260 | MHD_HTTP_PRECONDITION_FAILED, | 258 | MHD_HTTP_BAD_REQUEST, |
261 | TALER_EC_REFUND_CURRENCY_MISMATCH, | 259 | TALER_EC_REFUND_CURRENCY_MISMATCH, |
262 | "currencies involved do not match"); | 260 | "currencies involved do not match"); |
263 | return GNUNET_DB_STATUS_HARD_ERROR; | 261 | return GNUNET_DB_STATUS_HARD_ERROR; |
@@ -339,15 +337,14 @@ refund_transaction (void *cls, | |||
339 | * the fee structure, so this is not done here. | 337 | * the fee structure, so this is not done here. |
340 | * | 338 | * |
341 | * @param connection the MHD connection to handle | 339 | * @param connection the MHD connection to handle |
342 | * @param refund information about the refund | 340 | * @param[in,out] refund information about the refund |
343 | * @return MHD result code | 341 | * @return MHD result code |
344 | */ | 342 | */ |
345 | static MHD_RESULT | 343 | static MHD_RESULT |
346 | verify_and_execute_refund (struct MHD_Connection *connection, | 344 | verify_and_execute_refund (struct MHD_Connection *connection, |
347 | const struct TALER_EXCHANGEDB_Refund *refund) | 345 | struct TALER_EXCHANGEDB_Refund *refund) |
348 | { | 346 | { |
349 | struct GNUNET_HashCode denom_hash; | 347 | struct GNUNET_HashCode denom_hash; |
350 | struct TALER_Amount expect_fee; | ||
351 | 348 | ||
352 | { | 349 | { |
353 | struct TALER_RefundRequestPS rr = { | 350 | struct TALER_RefundRequestPS rr = { |
@@ -361,8 +358,6 @@ verify_and_execute_refund (struct MHD_Connection *connection, | |||
361 | 358 | ||
362 | TALER_amount_hton (&rr.refund_amount, | 359 | TALER_amount_hton (&rr.refund_amount, |
363 | &refund->details.refund_amount); | 360 | &refund->details.refund_amount); |
364 | TALER_amount_hton (&rr.refund_fee, | ||
365 | &refund->details.refund_fee); | ||
366 | if (GNUNET_OK != | 361 | if (GNUNET_OK != |
367 | GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND, | 362 | GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND, |
368 | &rr, | 363 | &rr, |
@@ -429,43 +424,12 @@ verify_and_execute_refund (struct MHD_Connection *connection, | |||
429 | ec, | 424 | ec, |
430 | "denomination not found, but coin known"); | 425 | "denomination not found, but coin known"); |
431 | } | 426 | } |
432 | TALER_amount_ntoh (&expect_fee, | 427 | TALER_amount_ntoh (&refund->details.refund_fee, |
433 | &dki->issue.properties.fee_refund); | 428 | &dki->issue.properties.fee_refund); |
434 | } | 429 | } |
435 | TEH_KS_release (key_state); | 430 | TEH_KS_release (key_state); |
436 | } | 431 | } |
437 | 432 | ||
438 | /* Check refund fee matches fee of denomination key! */ | ||
439 | if (GNUNET_YES != | ||
440 | TALER_amount_cmp_currency (&expect_fee, | ||
441 | &refund->details.refund_fee) ) | ||
442 | { | ||
443 | GNUNET_break_op (0); | ||
444 | return TALER_MHD_reply_with_error (connection, | ||
445 | MHD_HTTP_BAD_REQUEST, | ||
446 | TALER_EC_REFUND_FEE_CURRENCY_MISMATCH, | ||
447 | "refund_fee"); | ||
448 | } | ||
449 | { | ||
450 | int fee_cmp; | ||
451 | |||
452 | fee_cmp = TALER_amount_cmp (&refund->details.refund_fee, | ||
453 | &expect_fee); | ||
454 | if (-1 == fee_cmp) | ||
455 | { | ||
456 | return TALER_MHD_reply_with_error (connection, | ||
457 | MHD_HTTP_BAD_REQUEST, | ||
458 | TALER_EC_REFUND_FEE_TOO_LOW, | ||
459 | "refund_fee"); | ||
460 | } | ||
461 | if (1 == fee_cmp) | ||
462 | { | ||
463 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
464 | "Refund fee proposed by merchant is higher than necessary.\n"); | ||
465 | } | ||
466 | } | ||
467 | |||
468 | |||
469 | /* Finally run the actual transaction logic */ | 433 | /* Finally run the actual transaction logic */ |
470 | { | 434 | { |
471 | MHD_RESULT mhd_ret; | 435 | MHD_RESULT mhd_ret; |
@@ -502,16 +466,20 @@ TEH_handler_refund (struct MHD_Connection *connection, | |||
502 | const struct TALER_CoinSpendPublicKeyP *coin_pub, | 466 | const struct TALER_CoinSpendPublicKeyP *coin_pub, |
503 | const json_t *root) | 467 | const json_t *root) |
504 | { | 468 | { |
505 | struct TALER_EXCHANGEDB_Refund refund; | 469 | struct TALER_EXCHANGEDB_Refund refund = { |
470 | .details.refund_fee.currency = {0} /* set to invalid, just to be sure */ | ||
471 | }; | ||
506 | struct GNUNET_JSON_Specification spec[] = { | 472 | struct GNUNET_JSON_Specification spec[] = { |
507 | TALER_JSON_spec_amount ("refund_amount", &refund.details.refund_amount), | 473 | TALER_JSON_spec_amount ("refund_amount", |
508 | TALER_JSON_spec_amount ("refund_fee", &refund.details.refund_fee), | 474 | &refund.details.refund_amount), |
509 | GNUNET_JSON_spec_fixed_auto ("h_contract_terms", | 475 | GNUNET_JSON_spec_fixed_auto ("h_contract_terms", |
510 | &refund.details.h_contract_terms), | 476 | &refund.details.h_contract_terms), |
511 | GNUNET_JSON_spec_fixed_auto ("merchant_pub", &refund.details.merchant_pub), | 477 | GNUNET_JSON_spec_fixed_auto ("merchant_pub", |
478 | &refund.details.merchant_pub), | ||
512 | GNUNET_JSON_spec_uint64 ("rtransaction_id", | 479 | GNUNET_JSON_spec_uint64 ("rtransaction_id", |
513 | &refund.details.rtransaction_id), | 480 | &refund.details.rtransaction_id), |
514 | GNUNET_JSON_spec_fixed_auto ("merchant_sig", &refund.details.merchant_sig), | 481 | GNUNET_JSON_spec_fixed_auto ("merchant_sig", |
482 | &refund.details.merchant_sig), | ||
515 | GNUNET_JSON_spec_end () | 483 | GNUNET_JSON_spec_end () |
516 | }; | 484 | }; |
517 | 485 | ||
@@ -527,27 +495,6 @@ TEH_handler_refund (struct MHD_Connection *connection, | |||
527 | if (GNUNET_NO == res) | 495 | if (GNUNET_NO == res) |
528 | return MHD_YES; /* failure */ | 496 | return MHD_YES; /* failure */ |
529 | } | 497 | } |
530 | if (GNUNET_YES != | ||
531 | TALER_amount_cmp_currency (&refund.details.refund_amount, | ||
532 | &refund.details.refund_fee) ) | ||
533 | { | ||
534 | GNUNET_break_op (0); | ||
535 | GNUNET_JSON_parse_free (spec); | ||
536 | return TALER_MHD_reply_with_error (connection, | ||
537 | MHD_HTTP_BAD_REQUEST, | ||
538 | TALER_EC_REFUND_FEE_CURRENCY_MISMATCH, | ||
539 | "refund_amount or refund_fee"); | ||
540 | } | ||
541 | if (-1 == TALER_amount_cmp (&refund.details.refund_amount, | ||
542 | &refund.details.refund_fee) ) | ||
543 | { | ||
544 | GNUNET_break_op (0); | ||
545 | GNUNET_JSON_parse_free (spec); | ||
546 | return TALER_MHD_reply_with_error (connection, | ||
547 | MHD_HTTP_BAD_REQUEST, | ||
548 | TALER_EC_REFUND_FEE_ABOVE_AMOUNT, | ||
549 | "refund_amount"); | ||
550 | } | ||
551 | { | 498 | { |
552 | MHD_RESULT res; | 499 | MHD_RESULT res; |
553 | 500 | ||
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 06673afc1..7924ad54c 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c | |||
@@ -185,8 +185,6 @@ TEH_RESPONSE_compile_transaction_history ( | |||
185 | 185 | ||
186 | TALER_amount_hton (&rr.refund_amount, | 186 | TALER_amount_hton (&rr.refund_amount, |
187 | &refund->refund_amount); | 187 | &refund->refund_amount); |
188 | TALER_amount_hton (&rr.refund_fee, | ||
189 | &refund->refund_fee); | ||
190 | #if ENABLE_SANITY_CHECKS | 188 | #if ENABLE_SANITY_CHECKS |
191 | /* internal sanity check before we hand out a bogus sig... */ | 189 | /* internal sanity check before we hand out a bogus sig... */ |
192 | if (GNUNET_OK != | 190 | if (GNUNET_OK != |
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index 4d662e712..c4c72d6a4 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c | |||
@@ -306,8 +306,6 @@ withdraw_transaction (void *cls, | |||
306 | #endif | 306 | #endif |
307 | wc->collectable.denom_pub_hash = wc->denom_pub_hash; | 307 | wc->collectable.denom_pub_hash = wc->denom_pub_hash; |
308 | wc->collectable.amount_with_fee = wc->amount_required; | 308 | wc->collectable.amount_with_fee = wc->amount_required; |
309 | TALER_amount_ntoh (&wc->collectable.withdraw_fee, | ||
310 | &wc->dki->issue.properties.fee_withdraw); | ||
311 | wc->collectable.reserve_pub = wc->wsrd.reserve_pub; | 309 | wc->collectable.reserve_pub = wc->wsrd.reserve_pub; |
312 | wc->collectable.h_coin_envelope = wc->wsrd.h_coin_envelope; | 310 | wc->collectable.h_coin_envelope = wc->wsrd.h_coin_envelope; |
313 | wc->collectable.reserve_sig = wc->signature; | 311 | wc->collectable.reserve_sig = wc->signature; |
@@ -436,8 +434,6 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh, | |||
436 | } | 434 | } |
437 | TALER_amount_hton (&wc.wsrd.amount_with_fee, | 435 | TALER_amount_hton (&wc.wsrd.amount_with_fee, |
438 | &wc.amount_required); | 436 | &wc.amount_required); |
439 | TALER_amount_hton (&wc.wsrd.withdraw_fee, | ||
440 | &fee_withdraw); | ||
441 | } | 437 | } |
442 | 438 | ||
443 | /* verify signature! */ | 439 | /* verify signature! */ |
diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h index b3be7dc43..bbdd7a4ac 100644 --- a/src/include/taler_error_codes.h +++ b/src/include/taler_error_codes.h | |||
@@ -844,7 +844,7 @@ enum TALER_ErrorCode | |||
844 | /** | 844 | /** |
845 | * The currency specified for the refund is different from the | 845 | * The currency specified for the refund is different from the |
846 | * currency of the coin. This response is provided with HTTP status | 846 | * currency of the coin. This response is provided with HTTP status |
847 | * code #MHD_HTTP_PRECONDITION_FAILED. | 847 | * code #MHD_HTTP_BAD_REQUEST. |
848 | */ | 848 | */ |
849 | TALER_EC_REFUND_CURRENCY_MISMATCH = 1504, | 849 | TALER_EC_REFUND_CURRENCY_MISMATCH = 1504, |
850 | 850 | ||
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index f7fa71443..a57a2655a 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h | |||
@@ -878,7 +878,6 @@ typedef void | |||
878 | * @param amount the amount to be refunded; must be larger than the refund fee | 878 | * @param amount the amount to be refunded; must be larger than the refund fee |
879 | * (as that fee is still being subtracted), and smaller than the amount | 879 | * (as that fee is still being subtracted), and smaller than the amount |
880 | * (with deposit fee) of the original deposit contribution of this coin | 880 | * (with deposit fee) of the original deposit contribution of this coin |
881 | * @param refund_fee fee applicable to this coin for the refund | ||
882 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded | 881 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded |
883 | * @param coin_pub coin’s public key of the coin from the original deposit operation | 882 | * @param coin_pub coin’s public key of the coin from the original deposit operation |
884 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); | 883 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); |
@@ -894,7 +893,6 @@ typedef void | |||
894 | struct TALER_EXCHANGE_RefundHandle * | 893 | struct TALER_EXCHANGE_RefundHandle * |
895 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | 894 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, |
896 | const struct TALER_Amount *amount, | 895 | const struct TALER_Amount *amount, |
897 | const struct TALER_Amount *refund_fee, | ||
898 | const struct GNUNET_HashCode *h_contract_terms, | 896 | const struct GNUNET_HashCode *h_contract_terms, |
899 | const struct TALER_CoinSpendPublicKeyP *coin_pub, | 897 | const struct TALER_CoinSpendPublicKeyP *coin_pub, |
900 | uint64_t rtransaction_id, | 898 | uint64_t rtransaction_id, |
@@ -922,7 +920,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
922 | * @param amount the amount to be refunded; must be larger than the refund fee | 920 | * @param amount the amount to be refunded; must be larger than the refund fee |
923 | * (as that fee is still being subtracted), and smaller than the amount | 921 | * (as that fee is still being subtracted), and smaller than the amount |
924 | * (with deposit fee) of the original deposit contribution of this coin | 922 | * (with deposit fee) of the original deposit contribution of this coin |
925 | * @param refund_fee fee applicable to this coin for the refund | ||
926 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded | 923 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded |
927 | * @param coin_pub coin’s public key of the coin from the original deposit operation | 924 | * @param coin_pub coin’s public key of the coin from the original deposit operation |
928 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); | 925 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); |
@@ -939,7 +936,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
939 | struct TALER_EXCHANGE_RefundHandle * | 936 | struct TALER_EXCHANGE_RefundHandle * |
940 | TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, | 937 | TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, |
941 | const struct TALER_Amount *amount, | 938 | const struct TALER_Amount *amount, |
942 | const struct TALER_Amount *refund_fee, | ||
943 | const struct GNUNET_HashCode *h_contract_terms, | 939 | const struct GNUNET_HashCode *h_contract_terms, |
944 | const struct TALER_CoinSpendPublicKeyP *coin_pub, | 940 | const struct TALER_CoinSpendPublicKeyP *coin_pub, |
945 | uint64_t rtransaction_id, | 941 | uint64_t rtransaction_id, |
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index f55f0c2e4..c346a6cee 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h | |||
@@ -317,19 +317,6 @@ struct TALER_WithdrawRequestPS | |||
317 | struct TALER_AmountNBO amount_with_fee; | 317 | struct TALER_AmountNBO amount_with_fee; |
318 | 318 | ||
319 | /** | 319 | /** |
320 | * Withdrawal fee charged by the exchange. This must match the Exchange's | ||
321 | * denomination key's withdrawal fee. If the client puts in an | ||
322 | * invalid withdrawal fee (too high or too low) that does not match | ||
323 | * the Exchange's denomination key, the withdraw operation is invalid | ||
324 | * and will be rejected by the exchange. The @e amount_with_fee minus | ||
325 | * the @e withdraw_fee is must match the value of the generated | ||
326 | * coin. We include this in what is being signed so that we can | ||
327 | * verify a exchange's accounting without needing to access the | ||
328 | * respective denomination key information each time. | ||
329 | */ | ||
330 | struct TALER_AmountNBO withdraw_fee; | ||
331 | |||
332 | /** | ||
333 | * Hash of the denomination public key for the coin that is withdrawn. | 320 | * Hash of the denomination public key for the coin that is withdrawn. |
334 | */ | 321 | */ |
335 | struct GNUNET_HashCode h_denomination_pub GNUNET_PACKED; | 322 | struct GNUNET_HashCode h_denomination_pub GNUNET_PACKED; |
@@ -517,17 +504,6 @@ struct TALER_RefundRequestPS | |||
517 | */ | 504 | */ |
518 | struct TALER_AmountNBO refund_amount; | 505 | struct TALER_AmountNBO refund_amount; |
519 | 506 | ||
520 | /** | ||
521 | * Refund fee charged by the exchange. This must match the | ||
522 | * Exchange's denomination key's refund fee. If the client puts in | ||
523 | * an invalid refund fee (too high or too low) that does not match | ||
524 | * the Exchange's denomination key, the refund operation is invalid | ||
525 | * and will be rejected by the exchange. The @e amount_with_fee | ||
526 | * minus the @e refund_fee is the amount that will be credited to | ||
527 | * the original coin. | ||
528 | */ | ||
529 | struct TALER_AmountNBO refund_fee; | ||
530 | |||
531 | }; | 507 | }; |
532 | 508 | ||
533 | 509 | ||
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 1194cb4b4..acc218ac5 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h | |||
@@ -1656,7 +1656,6 @@ TALER_TESTING_cmd_check_bank_empty (const char *label); | |||
1656 | * @param label command label. | 1656 | * @param label command label. |
1657 | * @param expected_response_code expected HTTP status code. | 1657 | * @param expected_response_code expected HTTP status code. |
1658 | * @param refund_amount the amount to ask a refund for. | 1658 | * @param refund_amount the amount to ask a refund for. |
1659 | * @param refund_fee expected refund fee. | ||
1660 | * @param coin_reference reference to a command that can | 1659 | * @param coin_reference reference to a command that can |
1661 | * provide a coin to be refunded. | 1660 | * provide a coin to be refunded. |
1662 | * @param refund_transaction_id transaction id to use | 1661 | * @param refund_transaction_id transaction id to use |
@@ -1668,7 +1667,6 @@ struct TALER_TESTING_Command | |||
1668 | TALER_TESTING_cmd_refund_with_id (const char *label, | 1667 | TALER_TESTING_cmd_refund_with_id (const char *label, |
1669 | unsigned int expected_response_code, | 1668 | unsigned int expected_response_code, |
1670 | const char *refund_amount, | 1669 | const char *refund_amount, |
1671 | const char *refund_fee, | ||
1672 | const char *deposit_reference, | 1670 | const char *deposit_reference, |
1673 | uint64_t refund_transaction_id); | 1671 | uint64_t refund_transaction_id); |
1674 | 1672 | ||
@@ -1679,7 +1677,6 @@ TALER_TESTING_cmd_refund_with_id (const char *label, | |||
1679 | * @param label command label. | 1677 | * @param label command label. |
1680 | * @param expected_response_code expected HTTP status code. | 1678 | * @param expected_response_code expected HTTP status code. |
1681 | * @param refund_amount the amount to ask a refund for. | 1679 | * @param refund_amount the amount to ask a refund for. |
1682 | * @param refund_fee expected refund fee. | ||
1683 | * @param coin_reference reference to a command that can | 1680 | * @param coin_reference reference to a command that can |
1684 | * provide a coin to be refunded. | 1681 | * provide a coin to be refunded. |
1685 | * | 1682 | * |
@@ -1689,7 +1686,6 @@ struct TALER_TESTING_Command | |||
1689 | TALER_TESTING_cmd_refund (const char *label, | 1686 | TALER_TESTING_cmd_refund (const char *label, |
1690 | unsigned int expected_response_code, | 1687 | unsigned int expected_response_code, |
1691 | const char *refund_amount, | 1688 | const char *refund_amount, |
1692 | const char *refund_fee, | ||
1693 | const char *deposit_reference); | 1689 | const char *deposit_reference); |
1694 | 1690 | ||
1695 | 1691 | ||
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 07f5e1873..dc44291d0 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c | |||
@@ -146,11 +146,12 @@ TALER_EXCHANGE_parse_reserve_history ( | |||
146 | { | 146 | { |
147 | struct TALER_ReserveSignatureP sig; | 147 | struct TALER_ReserveSignatureP sig; |
148 | struct TALER_WithdrawRequestPS withdraw_purpose; | 148 | struct TALER_WithdrawRequestPS withdraw_purpose; |
149 | struct TALER_Amount withdraw_fee; | ||
149 | struct GNUNET_JSON_Specification withdraw_spec[] = { | 150 | struct GNUNET_JSON_Specification withdraw_spec[] = { |
150 | GNUNET_JSON_spec_fixed_auto ("reserve_sig", | 151 | GNUNET_JSON_spec_fixed_auto ("reserve_sig", |
151 | &sig), | 152 | &sig), |
152 | TALER_JSON_spec_amount_nbo ("withdraw_fee", | 153 | TALER_JSON_spec_amount ("withdraw_fee", |
153 | &withdraw_purpose.withdraw_fee), | 154 | &withdraw_fee), |
154 | GNUNET_JSON_spec_fixed_auto ("h_denom_pub", | 155 | GNUNET_JSON_spec_fixed_auto ("h_denom_pub", |
155 | &withdraw_purpose.h_denomination_pub), | 156 | &withdraw_purpose.h_denomination_pub), |
156 | GNUNET_JSON_spec_fixed_auto ("h_coin_envelope", | 157 | GNUNET_JSON_spec_fixed_auto ("h_coin_envelope", |
@@ -189,26 +190,23 @@ TALER_EXCHANGE_parse_reserve_history ( | |||
189 | { | 190 | { |
190 | const struct TALER_EXCHANGE_Keys *key_state; | 191 | const struct TALER_EXCHANGE_Keys *key_state; |
191 | const struct TALER_EXCHANGE_DenomPublicKey *dki; | 192 | const struct TALER_EXCHANGE_DenomPublicKey *dki; |
192 | struct TALER_Amount fee; | ||
193 | 193 | ||
194 | key_state = TALER_EXCHANGE_get_keys (exchange); | 194 | key_state = TALER_EXCHANGE_get_keys (exchange); |
195 | dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state, | 195 | dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state, |
196 | &withdraw_purpose. | 196 | &withdraw_purpose. |
197 | h_denomination_pub); | 197 | h_denomination_pub); |
198 | TALER_amount_ntoh (&fee, | ||
199 | &withdraw_purpose.withdraw_fee); | ||
200 | if ( (GNUNET_YES != | 198 | if ( (GNUNET_YES != |
201 | TALER_amount_cmp_currency (&fee, | 199 | TALER_amount_cmp_currency (&withdraw_fee, |
202 | &dki->fee_withdraw)) || | 200 | &dki->fee_withdraw)) || |
203 | (0 != | 201 | (0 != |
204 | TALER_amount_cmp (&fee, | 202 | TALER_amount_cmp (&withdraw_fee, |
205 | &dki->fee_withdraw)) ) | 203 | &dki->fee_withdraw)) ) |
206 | { | 204 | { |
207 | GNUNET_break_op (0); | 205 | GNUNET_break_op (0); |
208 | GNUNET_JSON_parse_free (withdraw_spec); | 206 | GNUNET_JSON_parse_free (withdraw_spec); |
209 | return GNUNET_SYSERR; | 207 | return GNUNET_SYSERR; |
210 | } | 208 | } |
211 | rh->details.withdraw.fee = fee; | 209 | rh->details.withdraw.fee = withdraw_fee; |
212 | } | 210 | } |
213 | rh->details.withdraw.out_authorization_sig | 211 | rh->details.withdraw.out_authorization_sig |
214 | = json_object_get (transaction, | 212 | = json_object_get (transaction, |
@@ -634,9 +632,16 @@ TALER_EXCHANGE_verify_coin_history ( | |||
634 | else if (0 == strcasecmp (type, | 632 | else if (0 == strcasecmp (type, |
635 | "REFUND")) | 633 | "REFUND")) |
636 | { | 634 | { |
637 | struct TALER_RefundRequestPS rr; | ||
638 | struct TALER_MerchantSignatureP sig; | 635 | struct TALER_MerchantSignatureP sig; |
636 | struct TALER_Amount refund_fee; | ||
637 | struct TALER_RefundRequestPS rr = { | ||
638 | .purpose.size = htonl (sizeof (rr)), | ||
639 | .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND), | ||
640 | .coin_pub = *coin_pub | ||
641 | }; | ||
639 | struct GNUNET_JSON_Specification spec[] = { | 642 | struct GNUNET_JSON_Specification spec[] = { |
643 | TALER_JSON_spec_amount ("refund_fee", | ||
644 | &refund_fee), | ||
640 | GNUNET_JSON_spec_fixed_auto ("merchant_sig", | 645 | GNUNET_JSON_spec_fixed_auto ("merchant_sig", |
641 | &sig), | 646 | &sig), |
642 | GNUNET_JSON_spec_fixed_auto ("h_contract_terms", | 647 | GNUNET_JSON_spec_fixed_auto ("h_contract_terms", |
@@ -645,8 +650,6 @@ TALER_EXCHANGE_verify_coin_history ( | |||
645 | &rr.merchant), | 650 | &rr.merchant), |
646 | GNUNET_JSON_spec_uint64 ("rtransaction_id", | 651 | GNUNET_JSON_spec_uint64 ("rtransaction_id", |
647 | &rr.rtransaction_id), | 652 | &rr.rtransaction_id), |
648 | TALER_JSON_spec_amount_nbo ("refund_fee", | ||
649 | &rr.refund_fee), | ||
650 | GNUNET_JSON_spec_end () | 653 | GNUNET_JSON_spec_end () |
651 | }; | 654 | }; |
652 | 655 | ||
@@ -658,9 +661,6 @@ TALER_EXCHANGE_verify_coin_history ( | |||
658 | GNUNET_break_op (0); | 661 | GNUNET_break_op (0); |
659 | return GNUNET_SYSERR; | 662 | return GNUNET_SYSERR; |
660 | } | 663 | } |
661 | rr.purpose.size = htonl (sizeof (rr)); | ||
662 | rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND); | ||
663 | rr.coin_pub = *coin_pub; | ||
664 | TALER_amount_hton (&rr.refund_amount, | 664 | TALER_amount_hton (&rr.refund_amount, |
665 | &amount); | 665 | &amount); |
666 | if (GNUNET_OK != | 666 | if (GNUNET_OK != |
@@ -683,13 +683,11 @@ TALER_EXCHANGE_verify_coin_history ( | |||
683 | /* check that refund fee matches our expectations from /keys! */ | 683 | /* check that refund fee matches our expectations from /keys! */ |
684 | if (NULL != dk) | 684 | if (NULL != dk) |
685 | { | 685 | { |
686 | TALER_amount_ntoh (&fee, | ||
687 | &rr.refund_fee); | ||
688 | if ( (GNUNET_YES != | 686 | if ( (GNUNET_YES != |
689 | TALER_amount_cmp_currency (&fee, | 687 | TALER_amount_cmp_currency (&refund_fee, |
690 | &dk->fee_refund)) || | 688 | &dk->fee_refund)) || |
691 | (0 != | 689 | (0 != |
692 | TALER_amount_cmp (&fee, | 690 | TALER_amount_cmp (&refund_fee, |
693 | &dk->fee_refund)) ) | 691 | &dk->fee_refund)) ) |
694 | { | 692 | { |
695 | GNUNET_break_op (0); | 693 | GNUNET_break_op (0); |
diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c index 5f3749931..a5cf6c36a 100644 --- a/src/lib/exchange_api_deposit.c +++ b/src/lib/exchange_api_deposit.c | |||
@@ -196,8 +196,8 @@ verify_deposit_signature_ok (struct TALER_EXCHANGE_DepositHandle *dh, | |||
196 | { | 196 | { |
197 | const struct TALER_EXCHANGE_Keys *key_state; | 197 | const struct TALER_EXCHANGE_Keys *key_state; |
198 | struct GNUNET_JSON_Specification spec[] = { | 198 | struct GNUNET_JSON_Specification spec[] = { |
199 | GNUNET_JSON_spec_fixed_auto ("sig", exchange_sig), | 199 | GNUNET_JSON_spec_fixed_auto ("exchange_sig", exchange_sig), |
200 | GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub), | 200 | GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub), |
201 | GNUNET_JSON_spec_end () | 201 | GNUNET_JSON_spec_end () |
202 | }; | 202 | }; |
203 | 203 | ||
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index c3ae16633..c9c1b09bd 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c | |||
@@ -39,7 +39,7 @@ | |||
39 | * Which version of the Taler protocol is implemented | 39 | * Which version of the Taler protocol is implemented |
40 | * by this library? Used to determine compatibility. | 40 | * by this library? Used to determine compatibility. |
41 | */ | 41 | */ |
42 | #define EXCHANGE_PROTOCOL_CURRENT 7 | 42 | #define EXCHANGE_PROTOCOL_CURRENT 8 |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * How many versions are we backwards compatible with? | 45 | * How many versions are we backwards compatible with? |
diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index c64dcc97a..9cb8794d3 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c | |||
@@ -81,14 +81,14 @@ struct TALER_EXCHANGE_RefundHandle | |||
81 | * Verify that the signature on the "200 OK" response | 81 | * Verify that the signature on the "200 OK" response |
82 | * from the exchange is valid. | 82 | * from the exchange is valid. |
83 | * | 83 | * |
84 | * @param rh refund handle | 84 | * @param[in,out] rh refund handle (refund fee added) |
85 | * @param json json reply with the signature | 85 | * @param json json reply with the signature |
86 | * @param[out] exchange_pub set to the exchange's public key | 86 | * @param[out] exchange_pub set to the exchange's public key |
87 | * @param[out] exchange_sig set to the exchange's signature | 87 | * @param[out] exchange_sig set to the exchange's signature |
88 | * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not | 88 | * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not |
89 | */ | 89 | */ |
90 | static int | 90 | static int |
91 | verify_refund_signature_ok (const struct TALER_EXCHANGE_RefundHandle *rh, | 91 | verify_refund_signature_ok (struct TALER_EXCHANGE_RefundHandle *rh, |
92 | const json_t *json, | 92 | const json_t *json, |
93 | struct TALER_ExchangePublicKeyP *exchange_pub, | 93 | struct TALER_ExchangePublicKeyP *exchange_pub, |
94 | struct TALER_ExchangeSignatureP *exchange_sig) | 94 | struct TALER_ExchangeSignatureP *exchange_sig) |
@@ -96,8 +96,9 @@ verify_refund_signature_ok (const struct TALER_EXCHANGE_RefundHandle *rh, | |||
96 | { | 96 | { |
97 | const struct TALER_EXCHANGE_Keys *key_state; | 97 | const struct TALER_EXCHANGE_Keys *key_state; |
98 | struct GNUNET_JSON_Specification spec[] = { | 98 | struct GNUNET_JSON_Specification spec[] = { |
99 | GNUNET_JSON_spec_fixed_auto ("sig", exchange_sig), | 99 | GNUNET_JSON_spec_fixed_auto ("exchange_sig", exchange_sig), |
100 | GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub), | 100 | GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub), |
101 | TALER_JSON_spec_amount_nbo ("refund_fee", &rh->depconf.refund_fee), | ||
101 | GNUNET_JSON_spec_end () | 102 | GNUNET_JSON_spec_end () |
102 | }; | 103 | }; |
103 | 104 | ||
@@ -256,7 +257,6 @@ handle_refund_finished (void *cls, | |||
256 | * @param amount the amount to be refunded; must be larger than the refund fee | 257 | * @param amount the amount to be refunded; must be larger than the refund fee |
257 | * (as that fee is still being subtracted), and smaller than the amount | 258 | * (as that fee is still being subtracted), and smaller than the amount |
258 | * (with deposit fee) of the original deposit contribution of this coin | 259 | * (with deposit fee) of the original deposit contribution of this coin |
259 | * @param refund_fee fee applicable to this coin for the refund | ||
260 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded | 260 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded |
261 | * @param coin_pub coin’s public key of the coin from the original deposit operation | 261 | * @param coin_pub coin’s public key of the coin from the original deposit operation |
262 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); | 262 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); |
@@ -272,7 +272,6 @@ handle_refund_finished (void *cls, | |||
272 | struct TALER_EXCHANGE_RefundHandle * | 272 | struct TALER_EXCHANGE_RefundHandle * |
273 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | 273 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, |
274 | const struct TALER_Amount *amount, | 274 | const struct TALER_Amount *amount, |
275 | const struct TALER_Amount *refund_fee, | ||
276 | const struct GNUNET_HashCode *h_contract_terms, | 275 | const struct GNUNET_HashCode *h_contract_terms, |
277 | const struct TALER_CoinSpendPublicKeyP *coin_pub, | 276 | const struct TALER_CoinSpendPublicKeyP *coin_pub, |
278 | uint64_t rtransaction_id, | 277 | uint64_t rtransaction_id, |
@@ -294,14 +293,11 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
294 | rr.rtransaction_id = GNUNET_htonll (rtransaction_id); | 293 | rr.rtransaction_id = GNUNET_htonll (rtransaction_id); |
295 | TALER_amount_hton (&rr.refund_amount, | 294 | TALER_amount_hton (&rr.refund_amount, |
296 | amount); | 295 | amount); |
297 | TALER_amount_hton (&rr.refund_fee, | ||
298 | refund_fee); | ||
299 | GNUNET_CRYPTO_eddsa_sign (&merchant_priv->eddsa_priv, | 296 | GNUNET_CRYPTO_eddsa_sign (&merchant_priv->eddsa_priv, |
300 | &rr, | 297 | &rr, |
301 | &merchant_sig.eddsa_sig); | 298 | &merchant_sig.eddsa_sig); |
302 | return TALER_EXCHANGE_refund2 (exchange, | 299 | return TALER_EXCHANGE_refund2 (exchange, |
303 | amount, | 300 | amount, |
304 | refund_fee, | ||
305 | h_contract_terms, | 301 | h_contract_terms, |
306 | coin_pub, | 302 | coin_pub, |
307 | rtransaction_id, | 303 | rtransaction_id, |
@@ -329,7 +325,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
329 | * @param amount the amount to be refunded; must be larger than the refund fee | 325 | * @param amount the amount to be refunded; must be larger than the refund fee |
330 | * (as that fee is still being subtracted), and smaller than the amount | 326 | * (as that fee is still being subtracted), and smaller than the amount |
331 | * (with deposit fee) of the original deposit contribution of this coin | 327 | * (with deposit fee) of the original deposit contribution of this coin |
332 | * @param refund_fee fee applicable to this coin for the refund | ||
333 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded | 328 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded |
334 | * @param coin_pub coin’s public key of the coin from the original deposit operation | 329 | * @param coin_pub coin’s public key of the coin from the original deposit operation |
335 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); | 330 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); |
@@ -346,7 +341,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
346 | struct TALER_EXCHANGE_RefundHandle * | 341 | struct TALER_EXCHANGE_RefundHandle * |
347 | TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, | 342 | TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, |
348 | const struct TALER_Amount *amount, | 343 | const struct TALER_Amount *amount, |
349 | const struct TALER_Amount *refund_fee, | ||
350 | const struct GNUNET_HashCode *h_contract_terms, | 344 | const struct GNUNET_HashCode *h_contract_terms, |
351 | const struct TALER_CoinSpendPublicKeyP *coin_pub, | 345 | const struct TALER_CoinSpendPublicKeyP *coin_pub, |
352 | uint64_t rtransaction_id, | 346 | uint64_t rtransaction_id, |
@@ -376,12 +370,11 @@ TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, | |||
376 | "/coins/%s/refund", | 370 | "/coins/%s/refund", |
377 | pub_str); | 371 | pub_str); |
378 | } | 372 | } |
379 | refund_obj = json_pack ("{s:o, s:o," /* amount/fee */ | 373 | refund_obj = json_pack ("{s:o," /* amount */ |
380 | " s:o," /* h_contract_terms */ | 374 | " s:o," /* h_contract_terms */ |
381 | " s:I," /* rtransaction id */ | 375 | " s:I," /* rtransaction id */ |
382 | " s:o, s:o}", /* merchant_pub, merchant_sig */ | 376 | " s:o, s:o}", /* merchant_pub, merchant_sig */ |
383 | "refund_amount", TALER_JSON_from_amount (amount), | 377 | "refund_amount", TALER_JSON_from_amount (amount), |
384 | "refund_fee", TALER_JSON_from_amount (refund_fee), | ||
385 | "h_contract_terms", GNUNET_JSON_from_data_auto ( | 378 | "h_contract_terms", GNUNET_JSON_from_data_auto ( |
386 | h_contract_terms), | 379 | h_contract_terms), |
387 | "rtransaction_id", (json_int_t) rtransaction_id, | 380 | "rtransaction_id", (json_int_t) rtransaction_id, |
@@ -410,8 +403,6 @@ TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange, | |||
410 | rh->depconf.rtransaction_id = GNUNET_htonll (rtransaction_id); | 403 | rh->depconf.rtransaction_id = GNUNET_htonll (rtransaction_id); |
411 | TALER_amount_hton (&rh->depconf.refund_amount, | 404 | TALER_amount_hton (&rh->depconf.refund_amount, |
412 | amount); | 405 | amount); |
413 | TALER_amount_hton (&rh->depconf.refund_fee, | ||
414 | refund_fee); | ||
415 | 406 | ||
416 | eh = TALER_EXCHANGE_curl_easy_get_ (rh->url); | 407 | eh = TALER_EXCHANGE_curl_easy_get_ (rh->url); |
417 | if ( (NULL == eh) || | 408 | if ( (NULL == eh) || |
diff --git a/src/lib/exchange_api_withdraw2.c b/src/lib/exchange_api_withdraw2.c index f9468927a..25f669143 100644 --- a/src/lib/exchange_api_withdraw2.c +++ b/src/lib/exchange_api_withdraw2.c | |||
@@ -429,8 +429,6 @@ TALER_EXCHANGE_withdraw2 ( | |||
429 | 429 | ||
430 | TALER_amount_hton (&req.amount_with_fee, | 430 | TALER_amount_hton (&req.amount_with_fee, |
431 | &wh->requested_amount); | 431 | &wh->requested_amount); |
432 | TALER_amount_hton (&req.withdraw_fee, | ||
433 | &dk->fee_withdraw); | ||
434 | GNUNET_CRYPTO_hash (pd->coin_ev, | 432 | GNUNET_CRYPTO_hash (pd->coin_ev, |
435 | pd->coin_ev_size, | 433 | pd->coin_ev_size, |
436 | &req.h_coin_envelope); | 434 | &req.h_coin_envelope); |
diff --git a/src/testing/test_auditor_api.c b/src/testing/test_auditor_api.c index 7b6996264..0ff28b29b 100644 --- a/src/testing/test_auditor_api.c +++ b/src/testing/test_auditor_api.c | |||
@@ -353,7 +353,6 @@ run (void *cls, | |||
353 | TALER_TESTING_cmd_refund ("refund-ok", | 353 | TALER_TESTING_cmd_refund ("refund-ok", |
354 | MHD_HTTP_OK, | 354 | MHD_HTTP_OK, |
355 | "EUR:5", | 355 | "EUR:5", |
356 | "EUR:0.01", | ||
357 | "deposit-refund-1"), | 356 | "deposit-refund-1"), |
358 | /** | 357 | /** |
359 | * Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone | 358 | * Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone |
diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index 0c3f48379..a2bf90014 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c | |||
@@ -528,18 +528,15 @@ run (void *cls, | |||
528 | TALER_TESTING_cmd_refund ("refund-ok", | 528 | TALER_TESTING_cmd_refund ("refund-ok", |
529 | MHD_HTTP_OK, | 529 | MHD_HTTP_OK, |
530 | "EUR:5", | 530 | "EUR:5", |
531 | "EUR:0.01", | ||
532 | "deposit-refund-1"), | 531 | "deposit-refund-1"), |
533 | TALER_TESTING_cmd_refund ("refund-ok-double", | 532 | TALER_TESTING_cmd_refund ("refund-ok-double", |
534 | MHD_HTTP_OK, | 533 | MHD_HTTP_OK, |
535 | "EUR:5", | 534 | "EUR:5", |
536 | "EUR:0.01", | ||
537 | "deposit-refund-1"), | 535 | "deposit-refund-1"), |
538 | /* Previous /refund(s) had id == 0. */ | 536 | /* Previous /refund(s) had id == 0. */ |
539 | TALER_TESTING_cmd_refund_with_id ("refund-conflicting", | 537 | TALER_TESTING_cmd_refund_with_id ("refund-conflicting", |
540 | MHD_HTTP_CONFLICT, | 538 | MHD_HTTP_CONFLICT, |
541 | "EUR:5", | 539 | "EUR:5", |
542 | "EUR:0.01", | ||
543 | "deposit-refund-1", | 540 | "deposit-refund-1", |
544 | 1), | 541 | 1), |
545 | /** | 542 | /** |
@@ -573,7 +570,6 @@ run (void *cls, | |||
573 | TALER_TESTING_cmd_refund ("refund-fail", | 570 | TALER_TESTING_cmd_refund ("refund-fail", |
574 | MHD_HTTP_GONE, | 571 | MHD_HTTP_GONE, |
575 | "EUR:4.99", | 572 | "EUR:4.99", |
576 | "EUR:0.01", | ||
577 | "deposit-refund-2"), | 573 | "deposit-refund-2"), |
578 | TALER_TESTING_cmd_check_bank_empty ("check-empty-after-refund"), | 574 | TALER_TESTING_cmd_check_bank_empty ("check-empty-after-refund"), |
579 | /** | 575 | /** |
@@ -607,7 +603,6 @@ run (void *cls, | |||
607 | TALER_TESTING_cmd_refund ("refund-ok-fast", | 603 | TALER_TESTING_cmd_refund ("refund-ok-fast", |
608 | MHD_HTTP_OK, | 604 | MHD_HTTP_OK, |
609 | "EUR:5", | 605 | "EUR:5", |
610 | "EUR:0.01", | ||
611 | "deposit-refund-1b"), | 606 | "deposit-refund-1b"), |
612 | /** | 607 | /** |
613 | * Run transfers. This will do the transfer as refund deadline | 608 | * Run transfers. This will do the transfer as refund deadline |
diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index 9aac3d1e3..053372197 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c | |||
@@ -173,12 +173,6 @@ run (void *cls, | |||
173 | TALER_TESTING_cmd_refund ("refund-currency-mismatch", | 173 | TALER_TESTING_cmd_refund ("refund-currency-mismatch", |
174 | MHD_HTTP_BAD_REQUEST, | 174 | MHD_HTTP_BAD_REQUEST, |
175 | "USD:5", | 175 | "USD:5", |
176 | "USD:0.01", | ||
177 | "deposit-refund-1"), | ||
178 | TALER_TESTING_cmd_refund ("refund-fee-above-amount", | ||
179 | MHD_HTTP_BAD_REQUEST, | ||
180 | "EUR:5", | ||
181 | "EUR:10", | ||
182 | "deposit-refund-1"), | 176 | "deposit-refund-1"), |
183 | TALER_TESTING_cmd_flip_upload ("flip-upload", | 177 | TALER_TESTING_cmd_flip_upload ("flip-upload", |
184 | CONFIG_FILE, | 178 | CONFIG_FILE, |
@@ -186,7 +180,6 @@ run (void *cls, | |||
186 | TALER_TESTING_cmd_refund ("refund-bad-sig", | 180 | TALER_TESTING_cmd_refund ("refund-bad-sig", |
187 | MHD_HTTP_FORBIDDEN, | 181 | MHD_HTTP_FORBIDDEN, |
188 | "EUR:5", | 182 | "EUR:5", |
189 | "EUR:0.01", | ||
190 | "deposit-refund-1"), | 183 | "deposit-refund-1"), |
191 | 184 | ||
192 | /* This next deposit CMD is only used to provide a | 185 | /* This next deposit CMD is only used to provide a |
@@ -207,17 +200,14 @@ run (void *cls, | |||
207 | TALER_TESTING_cmd_refund ("refund-deposit-not-found", | 200 | TALER_TESTING_cmd_refund ("refund-deposit-not-found", |
208 | MHD_HTTP_NOT_FOUND, | 201 | MHD_HTTP_NOT_FOUND, |
209 | "EUR:5", | 202 | "EUR:5", |
210 | "EUR:0.01", | ||
211 | "deposit-refund-to-fail"), | 203 | "deposit-refund-to-fail"), |
212 | TALER_TESTING_cmd_refund ("refund-insufficient-funds", | 204 | TALER_TESTING_cmd_refund ("refund-insufficient-funds", |
213 | MHD_HTTP_PRECONDITION_FAILED, | 205 | MHD_HTTP_PRECONDITION_FAILED, |
214 | "EUR:50", | 206 | "EUR:50", |
215 | "EUR:0.01", | ||
216 | "deposit-refund-1"), | 207 | "deposit-refund-1"), |
217 | TALER_TESTING_cmd_refund ("refund-fee-too-low", | 208 | TALER_TESTING_cmd_refund ("refund-fee-too-low", |
218 | MHD_HTTP_BAD_REQUEST, | 209 | MHD_HTTP_BAD_REQUEST, |
219 | "EUR:5", | 210 | "EUR:5", |
220 | "EUR:0.000001", | ||
221 | "deposit-refund-1"), | 211 | "deposit-refund-1"), |
222 | TALER_TESTING_cmd_end () | 212 | TALER_TESTING_cmd_end () |
223 | }; | 213 | }; |
diff --git a/src/testing/testing_api_cmd_refund.c b/src/testing/testing_api_cmd_refund.c index 47f5a0609..c27311fbf 100644 --- a/src/testing/testing_api_cmd_refund.c +++ b/src/testing/testing_api_cmd_refund.c | |||
@@ -44,11 +44,6 @@ struct RefundState | |||
44 | const char *refund_amount; | 44 | const char *refund_amount; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Expected refund fee. | ||
48 | */ | ||
49 | const char *refund_fee; | ||
50 | |||
51 | /** | ||
52 | * Reference to any command that can provide a coin to refund. | 47 | * Reference to any command that can provide a coin to refund. |
53 | */ | 48 | */ |
54 | const char *coin_reference; | 49 | const char *coin_reference; |
@@ -133,7 +128,6 @@ refund_run (void *cls, | |||
133 | struct TALER_CoinSpendPublicKeyP coin; | 128 | struct TALER_CoinSpendPublicKeyP coin; |
134 | const json_t *contract_terms; | 129 | const json_t *contract_terms; |
135 | struct GNUNET_HashCode h_contract_terms; | 130 | struct GNUNET_HashCode h_contract_terms; |
136 | struct TALER_Amount refund_fee; | ||
137 | struct TALER_Amount refund_amount; | 131 | struct TALER_Amount refund_amount; |
138 | const struct TALER_MerchantPrivateKeyP *merchant_priv; | 132 | const struct TALER_MerchantPrivateKeyP *merchant_priv; |
139 | const struct TALER_TESTING_Command *coin_cmd; | 133 | const struct TALER_TESTING_Command *coin_cmd; |
@@ -153,19 +147,6 @@ refund_run (void *cls, | |||
153 | TALER_TESTING_interpreter_fail (is); | 147 | TALER_TESTING_interpreter_fail (is); |
154 | return; | 148 | return; |
155 | } | 149 | } |
156 | if (GNUNET_OK != | ||
157 | TALER_string_to_amount (rs->refund_fee, | ||
158 | &refund_fee)) | ||
159 | { | ||
160 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
161 | "Failed to parse amount `%s' at %u/%s\n", | ||
162 | rs->refund_fee, | ||
163 | is->ip, | ||
164 | cmd->label); | ||
165 | TALER_TESTING_interpreter_fail (is); | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | coin_cmd = TALER_TESTING_interpreter_lookup_command (is, | 150 | coin_cmd = TALER_TESTING_interpreter_lookup_command (is, |
170 | rs->coin_reference); | 151 | rs->coin_reference); |
171 | if (NULL == coin_cmd) | 152 | if (NULL == coin_cmd) |
@@ -211,7 +192,6 @@ refund_run (void *cls, | |||
211 | } | 192 | } |
212 | rs->rh = TALER_EXCHANGE_refund (rs->exchange, | 193 | rs->rh = TALER_EXCHANGE_refund (rs->exchange, |
213 | &refund_amount, | 194 | &refund_amount, |
214 | &refund_fee, | ||
215 | &h_contract_terms, | 195 | &h_contract_terms, |
216 | &coin, | 196 | &coin, |
217 | rs->refund_transaction_id, | 197 | rs->refund_transaction_id, |
@@ -254,7 +234,6 @@ refund_cleanup (void *cls, | |||
254 | * @param label command label. | 234 | * @param label command label. |
255 | * @param expected_response_code expected HTTP status code. | 235 | * @param expected_response_code expected HTTP status code. |
256 | * @param refund_amount the amount to ask a refund for. | 236 | * @param refund_amount the amount to ask a refund for. |
257 | * @param refund_fee expected refund fee. | ||
258 | * @param coin_reference reference to a command that can | 237 | * @param coin_reference reference to a command that can |
259 | * provide a coin to be refunded. | 238 | * provide a coin to be refunded. |
260 | * | 239 | * |
@@ -264,7 +243,6 @@ struct TALER_TESTING_Command | |||
264 | TALER_TESTING_cmd_refund (const char *label, | 243 | TALER_TESTING_cmd_refund (const char *label, |
265 | unsigned int expected_response_code, | 244 | unsigned int expected_response_code, |
266 | const char *refund_amount, | 245 | const char *refund_amount, |
267 | const char *refund_fee, | ||
268 | const char *coin_reference) | 246 | const char *coin_reference) |
269 | { | 247 | { |
270 | struct RefundState *rs; | 248 | struct RefundState *rs; |
@@ -273,7 +251,6 @@ TALER_TESTING_cmd_refund (const char *label, | |||
273 | 251 | ||
274 | rs->expected_response_code = expected_response_code; | 252 | rs->expected_response_code = expected_response_code; |
275 | rs->refund_amount = refund_amount; | 253 | rs->refund_amount = refund_amount; |
276 | rs->refund_fee = refund_fee; | ||
277 | rs->coin_reference = coin_reference; | 254 | rs->coin_reference = coin_reference; |
278 | { | 255 | { |
279 | struct TALER_TESTING_Command cmd = { | 256 | struct TALER_TESTING_Command cmd = { |
@@ -295,7 +272,6 @@ TALER_TESTING_cmd_refund (const char *label, | |||
295 | * @param label command label. | 272 | * @param label command label. |
296 | * @param expected_response_code expected HTTP status code. | 273 | * @param expected_response_code expected HTTP status code. |
297 | * @param refund_amount the amount to ask a refund for. | 274 | * @param refund_amount the amount to ask a refund for. |
298 | * @param refund_fee expected refund fee. | ||
299 | * @param coin_reference reference to a command that can | 275 | * @param coin_reference reference to a command that can |
300 | * provide a coin to be refunded. | 276 | * provide a coin to be refunded. |
301 | * @param refund_transaction_id transaction id to use | 277 | * @param refund_transaction_id transaction id to use |
@@ -308,7 +284,6 @@ TALER_TESTING_cmd_refund_with_id | |||
308 | (const char *label, | 284 | (const char *label, |
309 | unsigned int expected_response_code, | 285 | unsigned int expected_response_code, |
310 | const char *refund_amount, | 286 | const char *refund_amount, |
311 | const char *refund_fee, | ||
312 | const char *coin_reference, | 287 | const char *coin_reference, |
313 | uint64_t refund_transaction_id) | 288 | uint64_t refund_transaction_id) |
314 | { | 289 | { |
@@ -317,7 +292,6 @@ TALER_TESTING_cmd_refund_with_id | |||
317 | rs = GNUNET_new (struct RefundState); | 292 | rs = GNUNET_new (struct RefundState); |
318 | rs->expected_response_code = expected_response_code; | 293 | rs->expected_response_code = expected_response_code; |
319 | rs->refund_amount = refund_amount; | 294 | rs->refund_amount = refund_amount; |
320 | rs->refund_fee = refund_fee; | ||
321 | rs->coin_reference = coin_reference; | 295 | rs->coin_reference = coin_reference; |
322 | rs->refund_transaction_id = refund_transaction_id; | 296 | rs->refund_transaction_id = refund_transaction_id; |
323 | { | 297 | { |