diff options
author | ms <ms@taler.net> | 2021-09-19 15:30:47 +0200 |
---|---|---|
committer | ms <ms@taler.net> | 2021-09-19 15:30:47 +0200 |
commit | fab22e862f8183e90926353d5a95b15d30b8e5f2 (patch) | |
tree | 0a2655884f356d9d13e4ff8912277dfd21d485db | |
parent | 86b3ff28ec21c6e182eefda472d02af9306cc345 (diff) | |
download | libeufin-fab22e862f8183e90926353d5a95b15d30b8e5f2.tar.gz libeufin-fab22e862f8183e90926353d5a95b15d30b8e5f2.tar.bz2 libeufin-fab22e862f8183e90926353d5a95b15d30b8e5f2.zip |
detect double withdraw
-rw-r--r-- | sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt index f51e287e..296f83d7 100644 --- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt +++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -1038,16 +1038,25 @@ fun serverMain(dbName: String, port: Int) { * is as well collected in this request. */ post("/api/withdrawal-operation/{wopid}") { + val wopid: String = ensureNonNull(call.parameters["wopid"]) - logger.debug("Confirming withdraw operation: $wopid") val body = call.receiveJson<TalerWithdrawalConfirmation>() - logger.debug("Withdrawal confirmation valid.") + transaction { var wo = TalerWithdrawalEntity.find { TalerWithdrawalsTable.wopid eq UUID.fromString(wopid) }.firstOrNull() ?: throw SandboxError( HttpStatusCode.NotFound, "Withdrawal operation $wopid not found." ) + if (wo.transferDone) { + throw SandboxError( + HttpStatusCode.Conflict, + "This withdraw operation was already funded. Aborting" + ) + } + if (wo.selectionDone) { + logger.warn("This withdraw operation was already confirmed, but not funded. Trying again") + } wireTransfer( "sandbox-account-customer", "sandbox-account-exchange", |