summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-07-05 12:56:55 +0200
committerChristian Grothoff <christian@grothoff.org>2022-07-05 12:56:55 +0200
commit7201ce3166127e45f924c3119c3037917d32e594 (patch)
tree040aa858fbf78611081fb73239c71ee1ea735ec8 /src/exchange
parent82cff16eea29fda6636b48d5980b48b1bc01236f (diff)
downloadexchange-7201ce3166127e45f924c3119c3037917d32e594.tar.gz
exchange-7201ce3166127e45f924c3119c3037917d32e594.tar.bz2
exchange-7201ce3166127e45f924c3119c3037917d32e594.zip
-handle withdraw CS nonce reuse more nicely
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_withdraw.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c
index 86d2c62b0..8d001488d 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -97,6 +97,7 @@ withdraw_transaction (void *cls,
enum GNUNET_DB_QueryStatus qs;
bool found = false;
bool balance_ok = false;
+ bool nonce_ok = false;
struct GNUNET_TIME_Timestamp now;
uint64_t ruuid;
const struct TALER_CsNonce *nonce;
@@ -108,16 +109,13 @@ withdraw_transaction (void *cls,
(TALER_DENOMINATION_CS == bp->cipher)
? &bp->details.cs_blinded_planchet.nonce
: NULL;
- // FIXME: what error is returned on nonce reuse?
- // Should expand function to return this error
- // specifically, and then we should return a
- // TALER_EC_EXCHANGE_WITHDRAW_NONCE_REUSE,
qs = TEH_plugin->do_withdraw (TEH_plugin->cls,
nonce,
&wc->collectable,
now,
&found,
&balance_ok,
+ &nonce_ok,
&wc->kyc,
&ruuid);
if (0 > qs)
@@ -146,6 +144,15 @@ withdraw_transaction (void *cls,
&wc->collectable.reserve_pub);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+ if (! nonce_ok)
+ {
+ TEH_plugin->rollback (TEH_plugin->cls);
+ *mhd_ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_EXCHANGE_WITHDRAW_NONCE_REUSE,
+ NULL);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
if ( (TEH_KYC_NONE != TEH_kyc_config.mode) &&
(! wc->kyc.ok) &&
(TALER_EXCHANGEDB_KYC_W2W == wc->kyc.type) )