summaryrefslogtreecommitdiff
path: root/nexus/src
diff options
context:
space:
mode:
authorMS <ms@taler.net>2020-06-18 17:10:23 +0200
committerMS <ms@taler.net>2020-06-18 17:11:18 +0200
commitb540026026e0f37996c73073429d024c08be97d1 (patch)
tree75a421be751d61de1e3ecaf7e61832c45c02f05b /nexus/src
parent60bdc1ccd72f1be6df506775abb227bc93c595d6 (diff)
downloadlibeufin-b540026026e0f37996c73073429d024c08be97d1.tar.gz
libeufin-b540026026e0f37996c73073429d024c08be97d1.tar.bz2
libeufin-b540026026e0f37996c73073429d024c08be97d1.zip
Not ingesting outgoing payments at the TWG level.
Diffstat (limited to 'nexus/src')
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt8
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt61
2 files changed, 1 insertions, 68 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index cd2e2d56..95288395 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -41,11 +41,6 @@ import java.sql.Connection
* in the PAIN-table.
*/
object TalerRequestedPayments : LongIdTable() {
- // this id gets assigned when the bank confirms the
- // corresponding outgoing payment. It is "abstract"
- // in the sense that a "early" prepared payment might
- // get a "high" id because the bank confirmed it "late".
- val abstractId = long("abstractId").nullable()
val preparedPayment = reference("payment", PaymentInitiationsTable)
val requestUId = text("request_uid")
val amount = text("amount")
@@ -56,7 +51,6 @@ object TalerRequestedPayments : LongIdTable() {
class TalerRequestedPaymentEntity(id: EntityID<Long>) : LongEntity(id) {
companion object : LongEntityClass<TalerRequestedPaymentEntity>(TalerRequestedPayments)
- var abstractId by TalerRequestedPayments.abstractId
var preparedPayment by PaymentInitiationEntity referencedOn TalerRequestedPayments.preparedPayment
var requestUId by TalerRequestedPayments.requestUId
var amount by TalerRequestedPayments.amount
@@ -321,7 +315,6 @@ object TalerFacadeStateTable : IntIdTable() {
val facade = reference("facade", FacadesTable)
// highest ID seen in the raw transactions table.
val highestSeenMsgID = long("highestSeenMsgID").default(0)
- val highestOutgoingAbstractID = long("highestOutgoingAbstractID").default(0)
}
class TalerFacadeStateEntity(id: EntityID<Int>) : IntEntity(id) {
@@ -335,7 +328,6 @@ class TalerFacadeStateEntity(id: EntityID<Int>) : IntEntity(id) {
var intervalIncrement by TalerFacadeStateTable.intervalIncrement
var facade by FacadeEntity referencedOn TalerFacadeStateTable.facade
var highestSeenMsgID by TalerFacadeStateTable.highestSeenMsgID
- var highestOutgoingAbstractID by TalerFacadeStateTable.highestOutgoingAbstractID
}
fun dbCreateTables(dbName: String) {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index c2d90502..4741ecbc 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -39,7 +39,6 @@ import org.jetbrains.exposed.dao.id.IdTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction
import tech.libeufin.nexus.bankaccount.addPreparedPayment
-import tech.libeufin.nexus.ebics.doEbicsUploadTransaction
import tech.libeufin.util.*
import kotlin.math.abs
import kotlin.math.min
@@ -118,36 +117,6 @@ data class Payto(
val bic: String = "NOTGIVEN"
)
-fun parsePayto(paytoUri: String): Payto {
- /**
- * First try to parse a "iban"-type payto URI. If that fails,
- * then assume a test is being run under the "x-taler-bank" type.
- * If that one fails too, throw exception.
- *
- * Note: since the Nexus doesn't have the notion of "x-taler-bank",
- * such URIs must yield a iban-compatible tuple of values. Therefore,
- * the plain bank account number maps to a "iban", and the <bank hostname>
- * maps to a "bic".
- */
-
- /**
- * payto://iban/BIC/IBAN?name=<name>
- * payto://x-taler-bank/<bank hostname>/<plain account number>
- */
- val ibanMatch = Regex("payto://iban/([A-Z0-9]+)/([A-Z0-9]+)\\?receiver-name=(\\w+)").find(paytoUri)
- if (ibanMatch != null) {
- val (bic, iban, name) = ibanMatch.destructured
- return Payto(name, iban, bic.replace("/", ""))
- }
- val xTalerBankMatch = Regex("payto://x-taler-bank/localhost/([0-9]+)").find(paytoUri)
- if (xTalerBankMatch != null) {
- val xTalerBankAcctNo = xTalerBankMatch.destructured.component1()
- return Payto("Taler Exchange", xTalerBankAcctNo, "localhost")
- }
-
- throw NexusError(HttpStatusCode.BadRequest, "invalid payto URI ($paytoUri)")
-}
-
/** Sort query results in descending order for negative deltas, and ascending otherwise. */
fun <T : Entity<Long>> SizedIterable<T>.orderTaler(delta: Int): List<T> {
return if (delta < 0) {
@@ -425,29 +394,6 @@ private fun ingestIncoming(payment: RawBankTransactionEntity, txDtls: Transactio
return
}
-private fun ingestOutgoing(
- txDtls: TransactionDetails,
- fcid: String) {
- val subject = txDtls.unstructuredRemittanceInformation
- logger.debug("Ingesting outgoing payment: subject")
- val wtid = extractWtidFromSubject(subject)
- if (wtid == null) {
- logger.warn("did not find wire transfer ID in outgoing payment")
- return
- }
- val talerRequested = TalerRequestedPaymentEntity.find {
- TalerRequestedPayments.wtid eq subject
- }.firstOrNull()
- if (talerRequested == null) {
- logger.info("Payment '${subject}' shows in history, but was never requested!")
- return
- }
- logger.debug("Payment: ${subject} was requested, and gets now marked as 'confirmed'")
- val fs = getTalerFacadeState(fcid)
- fs.highestOutgoingAbstractID++
- talerRequested.abstractId = fs.highestOutgoingAbstractID
-}
-
/**
* Crawls the database to find ALL the users that have a Taler
* facade and process their histories respecting the TWG policy.
@@ -476,9 +422,6 @@ fun ingestTalerTransactions() {
logger.warn("batch transactions not supported")
} else {
when (tx.creditDebitIndicator) {
- CreditDebitIndicator.DBIT -> ingestOutgoing(
- txDtls = tx.details[0], fcid = facade.id.value
- )
CreditDebitIndicator.CRDT -> ingestIncoming(it, txDtls = tx.details[0])
}
}
@@ -518,9 +461,7 @@ private suspend fun historyOutgoing(call: ApplicationCall) {
val subscriberBankAccount = getTalerFacadeBankAccount(expectNonNull(call.parameters["fcid"]))
val reqPayments = mutableListOf<TalerRequestedPaymentEntity>()
val reqPaymentsWithUnconfirmed = TalerRequestedPaymentEntity.find {
- if (delta < 0) {
- TalerRequestedPayments.abstractId less start
- } else TalerRequestedPayments.abstractId greater start
+ startCmpOp
}.orderTaler(delta)
reqPaymentsWithUnconfirmed.forEach {
if (it.preparedPayment.rawConfirmation != null) {