gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] 03/07: Withdrawal.


From: gnunet
Subject: [libeufin] 03/07: Withdrawal.
Date: Mon, 20 Dec 2021 17:44:46 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

commit 0e95165db58f183559364624561cf1c169692ff4
Author: ms <ms@taler.net>
AuthorDate: Sun Dec 19 21:37:37 2021 +0100

    Withdrawal.
    
    Select the 'suggested' exchange, if the wallet didn't specify one.
---
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 34ffeaa1..652991f2 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -1041,12 +1041,12 @@ val sandboxApp: Application.() -> Unit = {
                         }.firstOrNull() ?: throw SandboxError(
                             HttpStatusCode.NotFound, "Withdrawal operation 
$wopid not found."
                         )
+                        /**
+                         * Check for idempotency.  Note: to spare one 'if' 
statement,
+                         * the check happens even for 'confirmed' (= already 
paid) withdrawal
+                         * operations.
+                         */
                         if (wo.selectionDone) {
-                            if (wo.confirmationDone) {
-                                logger.info("Wallet performs again this 
operation that was paid out earlier: idempotent")
-                                return@newSuspendedTransaction wo.selectionDone
-                            }
-                            // Selected already but NOT paid, check 
consistency.
                             if (body.reserve_pub != wo.reservePub) throw 
SandboxError(
                                 HttpStatusCode.Conflict,
                                 "Selecting a different reserve from the one 
already selected"
@@ -1055,12 +1055,18 @@ val sandboxApp: Application.() -> Unit = {
                                 HttpStatusCode.Conflict,
                                 "Selecting a different exchange from the one 
already selected"
                             )
+                            return@newSuspendedTransaction wo.confirmationDone
                         }
+                        // Flow here means never selected, hence must as well 
never be paid.
+                        if (wo.confirmationDone) throw internalServerError(
+                            "Withdrawal ${wo.wopid} knew NO exchange and 
reserve pub, " +
+                                    "but is marked as paid!"
+                        )
                         wo.reservePub = body.reserve_pub
-                        wo.selectedExchangePayto = body.selected_exchange
+                        val demobank = ensureDemobank(call)
+                        wo.selectedExchangePayto = body.selected_exchange ?: 
demobank.suggestedExchangePayto
                         wo.selectionDone = true
-                        wo.confirmationDone
-                        false // not confirmed (AKA transferred)
+                        wo.confirmationDone // == false
                     }
                     call.respond(object {
                         val transfer_done: Boolean = transferDone

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]