summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_batch-withdraw.c15
-rw-r--r--src/exchange/taler-exchange-httpd_db.c4
-rw-r--r--src/exchange/taler-exchange-httpd_deposit.c5
-rw-r--r--src/exchange/taler-exchange-httpd_melt.c1
-rw-r--r--src/exchange/taler-exchange-httpd_purses_create.c1
-rw-r--r--src/exchange/taler-exchange-httpd_purses_deposit.c1
-rw-r--r--src/exchange/taler-exchange-httpd_purses_merge.c3
-rw-r--r--src/exchange/taler-exchange-httpd_recoup-refresh.c1
-rw-r--r--src/exchange/taler-exchange-httpd_recoup.c1
-rw-r--r--src/exchange/taler-exchange-httpd_refund.c14
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c82
-rw-r--r--src/exchange/taler-exchange-httpd_responses.h2
12 files changed, 84 insertions, 46 deletions
diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c b/src/exchange/taler-exchange-httpd_batch-withdraw.c
index d1311f8ad..52f420369 100644
--- a/src/exchange/taler-exchange-httpd_batch-withdraw.c
+++ b/src/exchange/taler-exchange-httpd_batch-withdraw.c
@@ -456,6 +456,21 @@ parse_planchets (const struct TEH_RequestContext *rc,
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
}
pc->collectable.reserve_pub = *wc->reserve_pub;
+ for (unsigned int k = 0; k<i; k++)
+ {
+ const struct PlanchetContext *kpc = &wc->planchets[k];
+
+ if (0 ==
+ TALER_blinded_planchet_cmp (&kpc->blinded_planchet,
+ &pc->blinded_planchet))
+ {
+ GNUNET_break_op (0);
+ return TALER_MHD_reply_with_error (rc->connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "duplicate planchet");
+ }
+ }
}
ksh = TEH_keys_get_state ();
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 53b935ba4..f0c551398 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -61,15 +61,19 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin,
NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
case TALER_EXCHANGEDB_CKS_DENOM_CONFLICT:
+ /* FIXME-Oec: insufficient_funds != denom conflict! */
*mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_GENERIC_COIN_CONFLICTING_DENOMINATION_KEY,
+ &h_denom_pub,
&coin->coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
case TALER_EXCHANGEDB_CKS_AGE_CONFLICT:
+ /* FIXME-Oec: insufficient_funds != Age conflict! */
*mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_GENERIC_COIN_CONFLICTING_AGE_HASH,
+ &h_denom_pub,
&coin->coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c
index 7ca56e104..f5e185078 100644
--- a/src/exchange/taler-exchange-httpd_deposit.c
+++ b/src/exchange/taler-exchange-httpd_deposit.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2021 Taler Systems SA
+ Copyright (C) 2014-2022 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -178,10 +178,12 @@ deposit_transaction (void *cls,
}
if (in_conflict)
{
+ /* FIXME: conficting contract != insufficient funds */
*mhd_ret
= TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_DEPOSIT_CONFLICTING_CONTRACT,
+ &dc->deposit->coin.denom_pub_hash,
&dc->deposit->coin.coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -191,6 +193,7 @@ deposit_transaction (void *cls,
= TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS,
+ &dc->deposit->coin.denom_pub_hash,
&dc->deposit->coin.coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
diff --git a/src/exchange/taler-exchange-httpd_melt.c b/src/exchange/taler-exchange-httpd_melt.c
index 3d6f05c0a..c6a8cc62f 100644
--- a/src/exchange/taler-exchange-httpd_melt.c
+++ b/src/exchange/taler-exchange-httpd_melt.c
@@ -196,6 +196,7 @@ melt_transaction (void *cls,
= TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS,
+ &rmc->refresh_session.coin.denom_pub_hash,
&rmc->refresh_session.coin.coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
diff --git a/src/exchange/taler-exchange-httpd_purses_create.c b/src/exchange/taler-exchange-httpd_purses_create.c
index 112a24dc5..d6c942c65 100644
--- a/src/exchange/taler-exchange-httpd_purses_create.c
+++ b/src/exchange/taler-exchange-httpd_purses_create.c
@@ -319,6 +319,7 @@ create_transaction (void *cls,
= TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS,
+ &coin->cpi.denom_pub_hash,
&coin->cpi.coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
diff --git a/src/exchange/taler-exchange-httpd_purses_deposit.c b/src/exchange/taler-exchange-httpd_purses_deposit.c
index 051df85cf..45d0c6f7f 100644
--- a/src/exchange/taler-exchange-httpd_purses_deposit.c
+++ b/src/exchange/taler-exchange-httpd_purses_deposit.c
@@ -229,6 +229,7 @@ deposit_transaction (void *cls,
= TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS,
+ &coin->cpi.denom_pub_hash,
&coin->cpi.coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
diff --git a/src/exchange/taler-exchange-httpd_purses_merge.c b/src/exchange/taler-exchange-httpd_purses_merge.c
index d87fb16de..5f09f1983 100644
--- a/src/exchange/taler-exchange-httpd_purses_merge.c
+++ b/src/exchange/taler-exchange-httpd_purses_merge.c
@@ -325,14 +325,13 @@ merge_transaction (void *cls,
GNUNET_JSON_pack_data_auto ("merge_sig",
&merge_sig),
GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("partner_base_url",
+ GNUNET_JSON_pack_string ("partner_url",
partner_url)),
GNUNET_JSON_pack_data_auto ("reserve_pub",
&reserve_pub));
GNUNET_free (partner_url);
return GNUNET_DB_STATUS_HARD_ERROR;
}
- // FIXME: if ! kyc check, return 451!
return qs;
}
diff --git a/src/exchange/taler-exchange-httpd_recoup-refresh.c b/src/exchange/taler-exchange-httpd_recoup-refresh.c
index a00eeba4e..79e99950d 100644
--- a/src/exchange/taler-exchange-httpd_recoup-refresh.c
+++ b/src/exchange/taler-exchange-httpd_recoup-refresh.c
@@ -146,6 +146,7 @@ recoup_refresh_transaction (void *cls,
*mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS,
+ &pc->coin->denom_pub_hash,
&pc->coin->coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
diff --git a/src/exchange/taler-exchange-httpd_recoup.c b/src/exchange/taler-exchange-httpd_recoup.c
index 6bda8af9e..bf17d9c20 100644
--- a/src/exchange/taler-exchange-httpd_recoup.c
+++ b/src/exchange/taler-exchange-httpd_recoup.c
@@ -149,6 +149,7 @@ recoup_transaction (void *cls,
*mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS,
+ &pc->coin->denom_pub_hash,
&pc->coin->coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c
index 3718fdedf..33ead7c69 100644
--- a/src/exchange/taler-exchange-httpd_refund.c
+++ b/src/exchange/taler-exchange-httpd_refund.c
@@ -158,10 +158,10 @@ refund_transaction (void *cls,
}
if (conflict)
{
- TEH_plugin->rollback (TEH_plugin->cls);
*mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT,
+ &refund->coin.denom_pub_hash,
&refund->coin.coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -175,10 +175,10 @@ refund_transaction (void *cls,
}
if (! refund_ok)
{
- TEH_plugin->rollback (TEH_plugin->cls);
*mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (
connection,
TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT,
+ &refund->coin.denom_pub_hash,
&refund->coin.coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -200,7 +200,6 @@ static MHD_RESULT
verify_and_execute_refund (struct MHD_Connection *connection,
struct TALER_EXCHANGEDB_Refund *refund)
{
- struct TALER_DenominationHashP denom_hash;
struct RefundContext rctx = {
.refund = refund
};
@@ -228,15 +227,16 @@ verify_and_execute_refund (struct MHD_Connection *connection,
qs = TEH_plugin->get_coin_denomination (TEH_plugin->cls,
&refund->coin.coin_pub,
&rctx.known_coin_id,
- &denom_hash);
+ &refund->coin.denom_pub_hash);
if (0 > qs)
{
MHD_RESULT res;
char *dhs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
- dhs = GNUNET_STRINGS_data_to_string_alloc (&denom_hash,
- sizeof (denom_hash));
+ dhs = GNUNET_STRINGS_data_to_string_alloc (
+ &refund->coin.denom_pub_hash,
+ sizeof (refund->coin.denom_pub_hash));
res = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_EXCHANGE_REFUND_COIN_NOT_FOUND,
@@ -251,7 +251,7 @@ verify_and_execute_refund (struct MHD_Connection *connection,
struct TEH_DenominationKey *dk;
MHD_RESULT mret;
- dk = TEH_keys_denomination_by_hash (&denom_hash,
+ dk = TEH_keys_denomination_by_hash (&refund->coin.denom_pub_hash,
connection,
&mret);
if (NULL == dk)
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 11cc0b930..e5309f9e3 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -70,18 +70,19 @@ TEH_RESPONSE_compile_transaction_history (
/* internal sanity check before we hand out a bogus sig... */
TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++;
if (GNUNET_OK !=
- TALER_wallet_deposit_verify (&deposit->amount_with_fee,
- &deposit->deposit_fee,
- &h_wire,
- &deposit->h_contract_terms,
- &deposit->h_age_commitment,
- NULL /* h_extensions! */,
- &deposit->h_denom_pub,
- deposit->timestamp,
- &deposit->merchant_pub,
- deposit->refund_deadline,
- coin_pub,
- &deposit->csig))
+ TALER_wallet_deposit_verify (
+ &deposit->amount_with_fee,
+ &deposit->deposit_fee,
+ &h_wire,
+ &deposit->h_contract_terms,
+ &deposit->h_age_commitment,
+ NULL /* h_extensions! */,
+ &deposit->h_denom_pub,
+ deposit->timestamp,
+ &deposit->merchant_pub,
+ deposit->refund_deadline,
+ coin_pub,
+ &deposit->csig))
{
GNUNET_break (0);
json_decref (history);
@@ -109,8 +110,6 @@ TEH_RESPONSE_compile_transaction_history (
&deposit->h_contract_terms),
GNUNET_JSON_pack_data_auto ("h_wire",
&h_wire),
- GNUNET_JSON_pack_data_auto ("h_denom_pub",
- &deposit->h_denom_pub),
GNUNET_JSON_pack_allow_null (
deposit->no_age_commitment ?
GNUNET_JSON_pack_string (
@@ -135,13 +134,14 @@ TEH_RESPONSE_compile_transaction_history (
#if ENABLE_SANITY_CHECKS
TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++;
if (GNUNET_OK !=
- TALER_wallet_melt_verify (&melt->amount_with_fee,
- &melt->melt_fee,
- &melt->rc,
- &melt->h_denom_pub,
- &melt->h_age_commitment,
- coin_pub,
- &melt->coin_sig))
+ TALER_wallet_melt_verify (
+ &melt->amount_with_fee,
+ &melt->melt_fee,
+ &melt->rc,
+ &melt->h_denom_pub,
+ &melt->h_age_commitment,
+ coin_pub,
+ &melt->coin_sig))
{
GNUNET_break (0);
json_decref (history);
@@ -166,8 +166,6 @@ TEH_RESPONSE_compile_transaction_history (
&melt->melt_fee),
GNUNET_JSON_pack_data_auto ("rc",
&melt->rc),
- GNUNET_JSON_pack_data_auto ("h_denom_pub",
- &melt->h_denom_pub),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_data_auto ("h_age_commitment",
phac)),
@@ -189,12 +187,13 @@ TEH_RESPONSE_compile_transaction_history (
#if ENABLE_SANITY_CHECKS
TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++;
if (GNUNET_OK !=
- TALER_merchant_refund_verify (coin_pub,
- &refund->h_contract_terms,
- refund->rtransaction_id,
- &refund->refund_amount,
- &refund->merchant_pub,
- &refund->merchant_sig))
+ TALER_merchant_refund_verify (
+ coin_pub,
+ &refund->h_contract_terms,
+ refund->rtransaction_id,
+ &refund->refund_amount,
+ &refund->merchant_pub,
+ &refund->merchant_sig))
{
GNUNET_break (0);
json_decref (history);
@@ -319,8 +318,6 @@ TEH_RESPONSE_compile_transaction_history (
&epub),
GNUNET_JSON_pack_data_auto ("reserve_pub",
&recoup->reserve_pub),
- GNUNET_JSON_pack_data_auto ("h_denom_pub",
- &recoup->h_denom_pub),
GNUNET_JSON_pack_data_auto ("coin_sig",
&recoup->coin_sig),
GNUNET_JSON_pack_data_auto ("coin_blind",
@@ -376,8 +373,6 @@ TEH_RESPONSE_compile_transaction_history (
&epub),
GNUNET_JSON_pack_data_auto ("old_coin_pub",
&pr->old_coin_pub),
- GNUNET_JSON_pack_data_auto ("h_denom_pub",
- &pr->coin.denom_pub_hash),
GNUNET_JSON_pack_data_auto ("coin_sig",
&pr->coin_sig),
GNUNET_JSON_pack_data_auto ("coin_blind",
@@ -558,18 +553,31 @@ MHD_RESULT
TEH_RESPONSE_reply_coin_insufficient_funds (
struct MHD_Connection *connection,
enum TALER_ErrorCode ec,
+ const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_CoinSpendPublicKeyP *coin_pub)
{
struct TALER_EXCHANGEDB_TransactionList *tl;
enum GNUNET_DB_QueryStatus qs;
json_t *history;
- // FIXME: maybe start read-committed transaction here?
- // => check all callers (that they aborted already!)
+ TEH_plugin->rollback (TEH_plugin->cls);
+ // FIXME: maybe start read-only transaction here?
+ if (GNUNET_OK !=
+ TEH_plugin->start_read_committed (TEH_plugin->cls,
+ "get_coin_transactions"))
+ {
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_START_FAILED,
+ NULL);
+ }
+ // FIXME: simplify, 3rd arg is always 'true' now?
qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls,
coin_pub,
- GNUNET_NO,
+ true,
&tl);
+ TEH_plugin->rollback (TEH_plugin->cls);
if (0 > qs)
{
return TALER_MHD_reply_with_error (
@@ -597,6 +605,8 @@ TEH_RESPONSE_reply_coin_insufficient_funds (
TALER_JSON_pack_ec (ec),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub),
+ GNUNET_JSON_pack_data_auto ("h_denom_pub",
+ h_denom_pub),
GNUNET_JSON_pack_array_steal ("history",
history));
}
diff --git a/src/exchange/taler-exchange-httpd_responses.h b/src/exchange/taler-exchange-httpd_responses.h
index 2c4ac018c..dde4c2c87 100644
--- a/src/exchange/taler-exchange-httpd_responses.h
+++ b/src/exchange/taler-exchange-httpd_responses.h
@@ -113,6 +113,7 @@ TEH_RESPONSE_reply_invalid_denom_cipher_for_operation (
*
* @param connection connection to the client
* @param ec error code to return
+ * @param h_denom_pub hash of the denomination of the coin
* @param coin_pub public key of the coin
* @return MHD result code
*/
@@ -120,6 +121,7 @@ MHD_RESULT
TEH_RESPONSE_reply_coin_insufficient_funds (
struct MHD_Connection *connection,
enum TALER_ErrorCode ec,
+ const struct TALER_DenominationHashP *h_denom_pub,
const struct TALER_CoinSpendPublicKeyP *coin_pub);