commit 51ef739f19b05877f201ae179369d5ea7f29c09a
parent 5fdd3bb2bbf2021845e25f43e997e59afe490421
Author: ms <ms@taler.net>
Date: Mon, 31 Jan 2022 15:08:05 +0100
block wire transfers of zero
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
@@ -29,6 +29,7 @@ import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.transactions.transaction
import tech.libeufin.util.*
+import java.math.BigDecimal
/**
* Helps to communicate Camt values without having
@@ -252,7 +253,8 @@ fun wireTransfer(
amount: String,
): String {
// sanity check on the amount, no currency allowed here.
- parseDecimal(amount)
+ val checkAmount = parseDecimal(amount)
+ if (checkAmount == BigDecimal.ZERO) throw badRequest("Wire transfers of zero not possible.")
val timeStamp = getUTCnow().toInstant().toEpochMilli()
val transactionRef = getRandomString(8)
transaction {