summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorms <ms@taler.net>2021-09-19 15:30:47 +0200
committerms <ms@taler.net>2021-09-19 15:30:47 +0200
commitfab22e862f8183e90926353d5a95b15d30b8e5f2 (patch)
tree0a2655884f356d9d13e4ff8912277dfd21d485db
parent86b3ff28ec21c6e182eefda472d02af9306cc345 (diff)
downloadlibeufin-fab22e862f8183e90926353d5a95b15d30b8e5f2.tar.gz
libeufin-fab22e862f8183e90926353d5a95b15d30b8e5f2.tar.bz2
libeufin-fab22e862f8183e90926353d5a95b15d30b8e5f2.zip
detect double withdraw
-rw-r--r--sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt13
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",