From 0556451225e4990bc2b88c7eb58c65ef531db6aa Mon Sep 17 00:00:00 2001 From: MS Date: Thu, 10 Jun 2021 15:42:05 +0200 Subject: conflict, when using one reserve pub twice. --- talerbank/app/views.py | 29 +++++++++++++++++------------ 1 file 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 -- cgit v1.2.3