summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-05-01 19:22:32 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-05 16:34:59 +0200
commit5ac448738dfe213bf27d89abe253455ce0a38acf (patch)
treec9d26a336cb16e306e96c5fa27572db39c51471b /src/exchange
parent9d3336f8f7eca7210ed76d9f2bbdfa185cdce009 (diff)
downloadexchange-5ac448738dfe213bf27d89abe253455ce0a38acf.tar.gz
exchange-5ac448738dfe213bf27d89abe253455ce0a38acf.tar.bz2
exchange-5ac448738dfe213bf27d89abe253455ce0a38acf.zip
fix status code
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_deposit.c30
-rw-r--r--src/exchange/taler-exchange-httpd_refund.c99
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c2
-rw-r--r--src/exchange/taler-exchange-httpd_withdraw.c4
4 files changed, 42 insertions, 93 deletions
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c
index 3f895857..65251863 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,
}
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
- "{s:s, s:o, s:o}",
- "status", "DEPOSIT_OK",
- "sig", GNUNET_JSON_from_data_auto (&sig),
- "pub", GNUNET_JSON_from_data_auto (&pub));
+ "{s:o, s:o}",
+ "exchange_sig",
+ GNUNET_JSON_from_data_auto (&sig),
+ "exchange_pub",
+ GNUNET_JSON_from_data_auto (&pub));
}
@@ -312,15 +313,22 @@ TEH_handler_deposit (struct MHD_Connection *connection,
struct GNUNET_HashCode my_h_wire;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("wire", &wire),
- TALER_JSON_spec_amount ("contribution", &deposit.amount_with_fee),
+ TALER_JSON_spec_amount ("contribution",
+ &deposit.amount_with_fee),
GNUNET_JSON_spec_fixed_auto ("denom_pub_hash",
&deposit.coin.denom_pub_hash),
- TALER_JSON_spec_denomination_signature ("ub_sig", &deposit.coin.denom_sig),
- GNUNET_JSON_spec_fixed_auto ("merchant_pub", &deposit.merchant_pub),
- GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &deposit.h_contract_terms),
- GNUNET_JSON_spec_fixed_auto ("h_wire", &deposit.h_wire),
- GNUNET_JSON_spec_fixed_auto ("coin_sig", &deposit.csig),
- GNUNET_JSON_spec_absolute_time ("timestamp", &deposit.timestamp),
+ TALER_JSON_spec_denomination_signature ("ub_sig",
+ &deposit.coin.denom_sig),
+ GNUNET_JSON_spec_fixed_auto ("merchant_pub",
+ &deposit.merchant_pub),
+ GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
+ &deposit.h_contract_terms),
+ GNUNET_JSON_spec_fixed_auto ("h_wire",
+ &deposit.h_wire),
+ GNUNET_JSON_spec_fixed_auto ("coin_sig",
+ &deposit.csig),
+ GNUNET_JSON_spec_absolute_time ("timestamp",
+ &deposit.timestamp),
GNUNET_JSON_spec_absolute_time ("refund_deadline",
&deposit.refund_deadline),
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 7c2b149f..a6a2c3d6 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,
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
"no online signing key");
}
- return TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_OK,
- "{s:s, s:o, s:o}",
- "status", "REFUND_OK",
- "sig", GNUNET_JSON_from_data_auto (&sig),
- "pub", GNUNET_JSON_from_data_auto (&pub));
+ return TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_OK,
+ "{s:o, s:o, s:o}",
+ "refund_fee", TALER_JSON_from_amount (&refund->refund_fee),
+ "exchange_sig", GNUNET_JSON_from_data_auto (&sig),
+ "exchange_pub", GNUNET_JSON_from_data_auto (&pub));
}
@@ -246,18 +247,15 @@ refund_transaction (void *cls,
}
/* check currency is compatible */
- if ( (GNUNET_YES !=
- TALER_amount_cmp_currency (&refund->details.refund_amount,
- &dep->amount_with_fee)) ||
- (GNUNET_YES !=
- TALER_amount_cmp_currency (&refund->details.refund_fee,
- &dep->deposit_fee)) )
+ if (GNUNET_YES !=
+ TALER_amount_cmp_currency (&refund->details.refund_amount,
+ &dep->amount_with_fee))
{
GNUNET_break_op (0); /* currency mismatch */
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
tl);
*mhd_ret = TALER_MHD_reply_with_error (connection,
- MHD_HTTP_PRECONDITION_FAILED,
+ MHD_HTTP_BAD_REQUEST,
TALER_EC_REFUND_CURRENCY_MISMATCH,
"currencies involved do not match");
return GNUNET_DB_STATUS_HARD_ERROR;
@@ -339,15 +337,14 @@ refund_transaction (void *cls,
* the fee structure, so this is not done here.
*
* @param connection the MHD connection to handle
- * @param refund information about the refund
+ * @param[in,out] refund information about the refund
* @return MHD result code
*/
static MHD_RESULT
verify_and_execute_refund (struct MHD_Connection *connection,
- const struct TALER_EXCHANGEDB_Refund *refund)
+ struct TALER_EXCHANGEDB_Refund *refund)
{
struct GNUNET_HashCode denom_hash;
- struct TALER_Amount expect_fee;
{
struct TALER_RefundRequestPS rr = {
@@ -361,8 +358,6 @@ verify_and_execute_refund (struct MHD_Connection *connection,
TALER_amount_hton (&rr.refund_amount,
&refund->details.refund_amount);
- TALER_amount_hton (&rr.refund_fee,
- &refund->details.refund_fee);
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND,
&rr,
@@ -429,43 +424,12 @@ verify_and_execute_refund (struct MHD_Connection *connection,
ec,
"denomination not found, but coin known");
}
- TALER_amount_ntoh (&expect_fee,
+ TALER_amount_ntoh (&refund->details.refund_fee,
&dki->issue.properties.fee_refund);
}
TEH_KS_release (key_state);
}
- /* Check refund fee matches fee of denomination key! */
- if (GNUNET_YES !=
- TALER_amount_cmp_currency (&expect_fee,
- &refund->details.refund_fee) )
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_REFUND_FEE_CURRENCY_MISMATCH,
- "refund_fee");
- }
- {
- int fee_cmp;
-
- fee_cmp = TALER_amount_cmp (&refund->details.refund_fee,
- &expect_fee);
- if (-1 == fee_cmp)
- {
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_REFUND_FEE_TOO_LOW,
- "refund_fee");
- }
- if (1 == fee_cmp)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Refund fee proposed by merchant is higher than necessary.\n");
- }
- }
-
-
/* Finally run the actual transaction logic */
{
MHD_RESULT mhd_ret;
@@ -502,16 +466,20 @@ TEH_handler_refund (struct MHD_Connection *connection,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const json_t *root)
{
- struct TALER_EXCHANGEDB_Refund refund;
+ struct TALER_EXCHANGEDB_Refund refund = {
+ .details.refund_fee.currency = {0} /* set to invalid, just to be sure */
+ };
struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_amount ("refund_amount", &refund.details.refund_amount),
- TALER_JSON_spec_amount ("refund_fee", &refund.details.refund_fee),
+ TALER_JSON_spec_amount ("refund_amount",
+ &refund.details.refund_amount),
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
&refund.details.h_contract_terms),
- GNUNET_JSON_spec_fixed_auto ("merchant_pub", &refund.details.merchant_pub),
+ GNUNET_JSON_spec_fixed_auto ("merchant_pub",
+ &refund.details.merchant_pub),
GNUNET_JSON_spec_uint64 ("rtransaction_id",
&refund.details.rtransaction_id),
- GNUNET_JSON_spec_fixed_auto ("merchant_sig", &refund.details.merchant_sig),
+ GNUNET_JSON_spec_fixed_auto ("merchant_sig",
+ &refund.details.merchant_sig),
GNUNET_JSON_spec_end ()
};
@@ -527,27 +495,6 @@ TEH_handler_refund (struct MHD_Connection *connection,
if (GNUNET_NO == res)
return MHD_YES; /* failure */
}
- if (GNUNET_YES !=
- TALER_amount_cmp_currency (&refund.details.refund_amount,
- &refund.details.refund_fee) )
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_REFUND_FEE_CURRENCY_MISMATCH,
- "refund_amount or refund_fee");
- }
- if (-1 == TALER_amount_cmp (&refund.details.refund_amount,
- &refund.details.refund_fee) )
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_REFUND_FEE_ABOVE_AMOUNT,
- "refund_amount");
- }
{
MHD_RESULT res;
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 06673afc..7924ad54 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 (
TALER_amount_hton (&rr.refund_amount,
&refund->refund_amount);
- TALER_amount_hton (&rr.refund_fee,
- &refund->refund_fee);
#if ENABLE_SANITY_CHECKS
/* internal sanity check before we hand out a bogus sig... */
if (GNUNET_OK !=
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c
index 4d662e71..c4c72d6a 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,
#endif
wc->collectable.denom_pub_hash = wc->denom_pub_hash;
wc->collectable.amount_with_fee = wc->amount_required;
- TALER_amount_ntoh (&wc->collectable.withdraw_fee,
- &wc->dki->issue.properties.fee_withdraw);
wc->collectable.reserve_pub = wc->wsrd.reserve_pub;
wc->collectable.h_coin_envelope = wc->wsrd.h_coin_envelope;
wc->collectable.reserve_sig = wc->signature;
@@ -436,8 +434,6 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
}
TALER_amount_hton (&wc.wsrd.amount_with_fee,
&wc.amount_required);
- TALER_amount_hton (&wc.wsrd.withdraw_fee,
- &fee_withdraw);
}
/* verify signature! */