summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-06-10 15:42:05 +0200
committerMS <ms@taler.net>2021-06-10 15:42:05 +0200
commit0556451225e4990bc2b88c7eb58c65ef531db6aa (patch)
tree9e23d4c830e04b9f7cbecd07d26d52e227e6112d
parent1be15d793a894723d2cfb0fbff4a016916051610 (diff)
downloadbank-0556451225e4990bc2b88c7eb58c65ef531db6aa.tar.gz
bank-0556451225e4990bc2b88c7eb58c65ef531db6aa.tar.bz2
bank-0556451225e4990bc2b88c7eb58c65ef531db6aa.zip
conflict, when using one reserve pub twice.
-rw-r--r--talerbank/app/views.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index d03faee..ad7b2b4 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -905,19 +905,24 @@ def twg_add_incoming(request, user_account, acct_id):
debit_account = BankAccount.objects.get(user=debit_user)
subject = f"{reserve_pub}"
- wtrans = wire_transfer(
- amount,
- debit_account,
- exchange_account,
- subject,
- )
+ # check if reserve pub exists already.
+ try:
+ BankTransactions.objects.get(subject=subject)
- return JsonResponse(
- {
- "row_id": wtrans.id,
- "timestamp": dict(t_ms=(int(wtrans.date.timestamp()) * 1000)),
- }
- )
+ except BankTransactions.DoesNotExist:
+
+ wtrans = wire_transfer(
+ amount,
+ debit_account,
+ exchange_account,
+ return JsonResponse(
+ {
+ "row_id": wtrans.id,
+ "timestamp": dict(t_ms=(int(wtrans.date.timestamp()) * 1000)),
+ }
+ )
+ # Here means this public key was used already: must fail.
+ return HttpResponse(status=409) # CONFLICT.
@csrf_exempt